superduper-qdrant 0.7.0__py3-none-any.whl → 0.9.0__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 +35 -20
- {superduper_qdrant-0.7.0.dist-info → superduper_qdrant-0.9.0.dist-info}/METADATA +1 -1
- superduper_qdrant-0.9.0.dist-info/RECORD +7 -0
- {superduper_qdrant-0.7.0.dist-info → superduper_qdrant-0.9.0.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.0.dist-info}/licenses/LICENSE +0 -0
- {superduper_qdrant-0.7.0.dist-info → superduper_qdrant-0.9.0.dist-info}/top_level.txt +0 -0
superduper_qdrant/__init__.py
CHANGED
superduper_qdrant/qdrant.py
CHANGED
@@ -28,31 +28,46 @@ 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 uri:
|
40
|
+
config_dict['location'] = uri
|
41
|
+
except ValueError as e:
|
42
|
+
if 'not enough values to unpack' in str(e):
|
43
|
+
plugin = CFG.vector_search_engine
|
44
|
+
else:
|
45
|
+
raise e
|
46
|
+
|
47
|
+
assert (
|
48
|
+
plugin == "qdrant"
|
49
|
+
), "Only 'qdrant' vector search engine is supported in QdrantVectorSearcher."
|
50
|
+
|
37
51
|
# Use an in-memory instance by default
|
38
52
|
# https://github.com/qdrant/qdrant-client#local-mode
|
39
53
|
config_dict = config_dict or {"location": ":memory:"}
|
40
54
|
self.client = QdrantClient(**config_dict)
|
41
|
-
self.
|
55
|
+
self.identifier = identifier
|
42
56
|
self.measure = measure
|
43
57
|
|
44
|
-
self.
|
45
|
-
if not self.client.collection_exists(self.
|
58
|
+
self.identifier = re.sub("\W+", "", identifier)
|
59
|
+
if not self.client.collection_exists(self.identifier):
|
46
60
|
measure = (
|
47
61
|
measure.name if isinstance(measure, VectorIndexMeasureType) else measure
|
48
62
|
)
|
49
63
|
distance = self._distance_mapping(measure)
|
50
64
|
self.client.create_collection(
|
51
|
-
collection_name=self.
|
65
|
+
collection_name=self.identifier,
|
52
66
|
vectors_config=models.VectorParams(size=dimensions, distance=distance),
|
53
67
|
)
|
68
|
+
self.component = component
|
54
69
|
|
55
|
-
def initialize(self
|
70
|
+
def initialize(self):
|
56
71
|
"""Initialize the vector index.
|
57
72
|
|
58
73
|
:param db: Datalayer instance
|
@@ -60,7 +75,7 @@ class QdrantVectorSearcher(BaseVectorSearcher):
|
|
60
75
|
pass
|
61
76
|
|
62
77
|
def __len__(self):
|
63
|
-
return self.client.get_collection(self.
|
78
|
+
return self.client.get_collection(self.identifier).vectors_count
|
64
79
|
|
65
80
|
def _create_collection(self):
|
66
81
|
measure = (
|
@@ -70,7 +85,7 @@ class QdrantVectorSearcher(BaseVectorSearcher):
|
|
70
85
|
)
|
71
86
|
distance = self._distance_mapping(measure)
|
72
87
|
self.client.create_collection(
|
73
|
-
collection_name=self.
|
88
|
+
collection_name=self.identifier,
|
74
89
|
vectors_config=models.VectorParams(size=self.dimensions, distance=distance),
|
75
90
|
)
|
76
91
|
|
@@ -82,22 +97,22 @@ class QdrantVectorSearcher(BaseVectorSearcher):
|
|
82
97
|
"""
|
83
98
|
points = []
|
84
99
|
for item in items:
|
100
|
+
if hasattr(item.vector, "tolist"):
|
101
|
+
vector = item.vector.tolist()
|
102
|
+
else:
|
103
|
+
vector = item.vector
|
85
104
|
point = models.PointStruct(
|
86
105
|
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
|
-
),
|
106
|
+
vector=vector,
|
92
107
|
payload={ID_PAYLOAD_KEY: item.id},
|
93
108
|
)
|
94
109
|
points.append(point)
|
95
|
-
self.client.upsert(collection_name=self.
|
110
|
+
self.client.upsert(collection_name=self.identifier, points=points)
|
96
111
|
|
97
112
|
def drop(self):
|
98
113
|
"""Drop the vector index."""
|
99
|
-
if self.client.collection_exists(self.
|
100
|
-
self.client.delete_collection(self.
|
114
|
+
if self.client.collection_exists(self.identifier):
|
115
|
+
self.client.delete_collection(self.identifier)
|
101
116
|
|
102
117
|
def delete(self, ids: t.Sequence[str]) -> None:
|
103
118
|
"""Delete vectors from the index.
|
@@ -105,7 +120,7 @@ class QdrantVectorSearcher(BaseVectorSearcher):
|
|
105
120
|
:param ids: List of IDs to delete
|
106
121
|
"""
|
107
122
|
self.client.delete(
|
108
|
-
collection_name=self.
|
123
|
+
collection_name=self.identifier,
|
109
124
|
points_selector=models.Filter(
|
110
125
|
must=[
|
111
126
|
models.FieldCondition(
|
@@ -160,12 +175,12 @@ class QdrantVectorSearcher(BaseVectorSearcher):
|
|
160
175
|
)
|
161
176
|
|
162
177
|
search_result = self.client.query_points(
|
163
|
-
collection_name=self.
|
178
|
+
collection_name=self.identifier,
|
164
179
|
query=query,
|
165
180
|
limit=n,
|
166
181
|
query_filter=query_filter,
|
167
182
|
with_payload=[ID_PAYLOAD_KEY],
|
168
|
-
using=
|
183
|
+
using=None,
|
169
184
|
).points
|
170
185
|
|
171
186
|
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.0
|
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=5yS0vs-awzI-ds12dAeIhOHgjcMjrxTDZKM9W15p42Q,112
|
2
|
+
superduper_qdrant/qdrant.py,sha256=nHTYNdgWFs7FYHEcl4K4uxlOp_chbCsU6id-17MlJLk,6828
|
3
|
+
superduper_qdrant-0.9.0.dist-info/licenses/LICENSE,sha256=fq2WxmjewRN4VfDClVl-6CiVFZedp4y5_iGqQiXHBN8,11353
|
4
|
+
superduper_qdrant-0.9.0.dist-info/METADATA,sha256=vwEhdwXMt0TBYqRL3xekaksq7-vh5eYL-spAQSbb37k,13638
|
5
|
+
superduper_qdrant-0.9.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
+
superduper_qdrant-0.9.0.dist-info/top_level.txt,sha256=sq-9pdkTJIhMAzMoSI_UlucyRUrPk4Da78PFG_hPcd8,18
|
7
|
+
superduper_qdrant-0.9.0.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
|