Skip to content

Commit 6ab55be

Browse files
committed
Bump Version 0.5.11
1 parent ecd5e62 commit 6ab55be

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
66
name = "superduper-framework"
77
description = "🔮 Bring AI to your favourite database 🔮"
88
readme = "README.md"
9-
version = '0.5.10'
9+
version = '0.5.11'
1010
license = {file = "LICENSE"}
1111
maintainers = [{name = "superduper.io, Inc.", email = "[email protected]"}]
1212
keywords = [

snowflake_test.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import json
2+
3+
from superduper_openai import OpenAIEmbedding
4+
from superduper import *
5+
from superduper.components.datatype import Vector
6+
7+
CFG.auto_schema = True
8+
CFG.vector_search_engine = 'snowflake'
9+
CFG.data_backend = 'snowflake://softwareuser:SU4yv6DfUPUL0CPDdsCDDSLttVc@ngkjqqn-superduperdbeu/myuser_db/data'
10+
11+
m = OpenAIEmbedding(
12+
'test',
13+
model='text-embedding-ada-002',
14+
example='test',
15+
)
16+
17+
db = superduper()
18+
db.cfg.auto_schema = True
19+
20+
with open('text.json') as f:
21+
data = json.load(f)
22+
23+
db['test'].insert(data).execute()
24+
25+
vector_index = VectorIndex(
26+
'test',
27+
indexing_listener=Listener(
28+
'test',
29+
model=m,
30+
select=db['test'].select(),
31+
key='txt'
32+
),
33+
measure='l2'
34+
)
35+
36+
db.apply(vector_index, force=True)
37+
38+
for r in db['test'].like({'txt': 'Axel Covin'}, n=1, vector_index='test').select().execute():
39+
print(r['txt'])

superduper/components/model.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,9 @@ def _prepare_inputs_from_select(
574574
mapping = Mapping(X, self.signature)
575575
if in_memory:
576576
docs = list(self.db.execute(select.select_using_ids(ids)))
577+
pid = select.table_or_collection.primary_id
578+
lookup = {r[pid]: r for r in docs}
579+
docs = [lookup[id_] for id_ in ids]
577580
X_data = list(map(lambda x: mapping(x), docs))
578581
else:
579582
assert isinstance(self.db, Datalayer)

text.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)