superduper-qdrant 0.7.0__py3-none-any.whl → 0.9.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- superduper_qdrant/__init__.py +1 -1
- superduper_qdrant/qdrant.py +37 -20
- {superduper_qdrant-0.7.0.dist-info → superduper_qdrant-0.9.1.dist-info}/METADATA +1 -1
- superduper_qdrant-0.9.1.dist-info/RECORD +7 -0
- {superduper_qdrant-0.7.0.dist-info → superduper_qdrant-0.9.1.dist-info}/WHEEL +1 -1
- superduper_qdrant-0.7.0.dist-info/RECORD +0 -7
- {superduper_qdrant-0.7.0.dist-info → superduper_qdrant-0.9.1.dist-info}/licenses/LICENSE +0 -0
- {superduper_qdrant-0.7.0.dist-info → superduper_qdrant-0.9.1.dist-info}/top_level.txt +0 -0
superduper_qdrant/__init__.py
CHANGED
superduper_qdrant/qdrant.py
CHANGED
@@ -28,31 +28,48 @@ class QdrantVectorSearcher(BaseVectorSearcher):
|
|
28
28
|
|
29
29
|
def __init__(
|
30
30
|
self,
|
31
|
-
|
31
|
+
identifier: str,
|
32
32
|
dimensions: int,
|
33
33
|
measure: t.Optional[str] = None,
|
34
|
+
component: str = 'VectorIndex',
|
34
35
|
):
|
35
36
|
config_dict = deepcopy(CFG.vector_search_kwargs)
|
36
|
-
|
37
|
+
try:
|
38
|
+
plugin, uri = CFG.vector_search_engine.split("://")
|
39
|
+
if not uri.startswith("http"):
|
40
|
+
uri = f"http://{uri}"
|
41
|
+
if uri:
|
42
|
+
config_dict['location'] = uri
|
43
|
+
except ValueError as e:
|
44
|
+
if 'not enough values to unpack' in str(e):
|
45
|
+
plugin = CFG.vector_search_engine
|
46
|
+
else:
|
47
|
+
raise e
|
48
|
+
|
49
|
+
assert (
|
50
|
+
plugin == "qdrant"
|
51
|
+
), "Only 'qdrant' vector search engine is supported in QdrantVectorSearcher."
|
52
|
+
|
37
53
|
# Use an in-memory instance by default
|
38
54
|
# https://github.com/qdrant/qdrant-client#local-mode
|
39
55
|
config_dict = config_dict or {"location": ":memory:"}
|
40
56
|
self.client = QdrantClient(**config_dict)
|
41
|
-
self.
|
57
|
+
self.identifier = identifier
|
42
58
|
self.measure = measure
|
43
59
|
|
44
|
-
self.
|
45
|
-
if not self.client.collection_exists(self.
|
60
|
+
self.identifier = re.sub("\W+", "", identifier)
|
61
|
+
if not self.client.collection_exists(self.identifier):
|
46
62
|
measure = (
|
47
63
|
measure.name if isinstance(measure, VectorIndexMeasureType) else measure
|
48
64
|
)
|
49
65
|
distance = self._distance_mapping(measure)
|
50
66
|
self.client.create_collection(
|
51
|
-
collection_name=self.
|
67
|
+
collection_name=self.identifier,
|
52
68
|
vectors_config=models.VectorParams(size=dimensions, distance=distance),
|
53
69
|
)
|
70
|
+
self.component = component
|
54
71
|
|
55
|
-
def initialize(self
|
72
|
+
def initialize(self):
|
56
73
|
"""Initialize the vector index.
|
57
74
|
|
58
75
|
:param db: Datalayer instance
|
@@ -60,7 +77,7 @@ class QdrantVectorSearcher(BaseVectorSearcher):
|
|
60
77
|
pass
|
61
78
|
|
62
79
|
def __len__(self):
|
63
|
-
return self.client.get_collection(self.
|
80
|
+
return self.client.get_collection(self.identifier).vectors_count
|
64
81
|
|
65
82
|
def _create_collection(self):
|
66
83
|
measure = (
|
@@ -70,7 +87,7 @@ class QdrantVectorSearcher(BaseVectorSearcher):
|
|
70
87
|
)
|
71
88
|
distance = self._distance_mapping(measure)
|
72
89
|
self.client.create_collection(
|
73
|
-
collection_name=self.
|
90
|
+
collection_name=self.identifier,
|
74
91
|
vectors_config=models.VectorParams(size=self.dimensions, distance=distance),
|
75
92
|
)
|
76
93
|
|
@@ -82,22 +99,22 @@ class QdrantVectorSearcher(BaseVectorSearcher):
|
|
82
99
|
"""
|
83
100
|
points = []
|
84
101
|
for item in items:
|
102
|
+
if hasattr(item.vector, "tolist"):
|
103
|
+
vector = item.vector.tolist()
|
104
|
+
else:
|
105
|
+
vector = item.vector
|
85
106
|
point = models.PointStruct(
|
86
107
|
id=self._convert_id(item.id),
|
87
|
-
vector=
|
88
|
-
{self.vector_name: item.vector.tolist()}
|
89
|
-
if self.vector_name
|
90
|
-
else item.vector.tolist()
|
91
|
-
),
|
108
|
+
vector=vector,
|
92
109
|
payload={ID_PAYLOAD_KEY: item.id},
|
93
110
|
)
|
94
111
|
points.append(point)
|
95
|
-
self.client.upsert(collection_name=self.
|
112
|
+
self.client.upsert(collection_name=self.identifier, points=points)
|
96
113
|
|
97
114
|
def drop(self):
|
98
115
|
"""Drop the vector index."""
|
99
|
-
if self.client.collection_exists(self.
|
100
|
-
self.client.delete_collection(self.
|
116
|
+
if self.client.collection_exists(self.identifier):
|
117
|
+
self.client.delete_collection(self.identifier)
|
101
118
|
|
102
119
|
def delete(self, ids: t.Sequence[str]) -> None:
|
103
120
|
"""Delete vectors from the index.
|
@@ -105,7 +122,7 @@ class QdrantVectorSearcher(BaseVectorSearcher):
|
|
105
122
|
:param ids: List of IDs to delete
|
106
123
|
"""
|
107
124
|
self.client.delete(
|
108
|
-
collection_name=self.
|
125
|
+
collection_name=self.identifier,
|
109
126
|
points_selector=models.Filter(
|
110
127
|
must=[
|
111
128
|
models.FieldCondition(
|
@@ -160,12 +177,12 @@ class QdrantVectorSearcher(BaseVectorSearcher):
|
|
160
177
|
)
|
161
178
|
|
162
179
|
search_result = self.client.query_points(
|
163
|
-
collection_name=self.
|
180
|
+
collection_name=self.identifier,
|
164
181
|
query=query,
|
165
182
|
limit=n,
|
166
183
|
query_filter=query_filter,
|
167
184
|
with_payload=[ID_PAYLOAD_KEY],
|
168
|
-
using=
|
185
|
+
using=None,
|
169
186
|
).points
|
170
187
|
|
171
188
|
ids = [hit.payload[ID_PAYLOAD_KEY] for hit in search_result if hit.payload]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: superduper_qdrant
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.9.1
|
4
4
|
Summary: SuperDuper Lance is a Python library that provides a high-level API for working with Lance vector search database.
|
5
5
|
Maintainer-email: "superduper.io, Inc." <opensource@superduper.io>
|
6
6
|
License:
|
@@ -0,0 +1,7 @@
|
|
1
|
+
superduper_qdrant/__init__.py,sha256=FgAGJy3NEKJSNEVB0VHJEXdTqfUk7NngxovQWwycXTc,112
|
2
|
+
superduper_qdrant/qdrant.py,sha256=qlWOcbO3ZT7GPuGpoYvf5VYDVWvYcWW7TQsccq4wXsw,6909
|
3
|
+
superduper_qdrant-0.9.1.dist-info/licenses/LICENSE,sha256=fq2WxmjewRN4VfDClVl-6CiVFZedp4y5_iGqQiXHBN8,11353
|
4
|
+
superduper_qdrant-0.9.1.dist-info/METADATA,sha256=R4EJDetZJrMFvnR2z7F8yewxbN1_A-3AQq3NLOJmoDI,13638
|
5
|
+
superduper_qdrant-0.9.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
+
superduper_qdrant-0.9.1.dist-info/top_level.txt,sha256=sq-9pdkTJIhMAzMoSI_UlucyRUrPk4Da78PFG_hPcd8,18
|
7
|
+
superduper_qdrant-0.9.1.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
superduper_qdrant/__init__.py,sha256=42MYMwS_4ytzPgI3s1BqB6j8adwNC7wxi_vl5OmTxHM,112
|
2
|
-
superduper_qdrant/qdrant.py,sha256=l61OUQB6WNHwh-sJny5D0NdsfHbRImaw_T-RyUjU-C0,6440
|
3
|
-
superduper_qdrant-0.7.0.dist-info/licenses/LICENSE,sha256=fq2WxmjewRN4VfDClVl-6CiVFZedp4y5_iGqQiXHBN8,11353
|
4
|
-
superduper_qdrant-0.7.0.dist-info/METADATA,sha256=G_f-oVYWi7irDXyEAns-uLs0o_q-Jtc-Tiojhk0DABo,13638
|
5
|
-
superduper_qdrant-0.7.0.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
6
|
-
superduper_qdrant-0.7.0.dist-info/top_level.txt,sha256=sq-9pdkTJIhMAzMoSI_UlucyRUrPk4Da78PFG_hPcd8,18
|
7
|
-
superduper_qdrant-0.7.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|