superduper-qdrant 0.6.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.
@@ -1,5 +1,5 @@
1
1
  from .qdrant import QdrantVectorSearcher as VectorSearcher
2
2
 
3
- __version__ = "0.6.0"
3
+ __version__ = "0.9.0"
4
4
 
5
5
  __all__ = ['VectorSearcher']
@@ -28,31 +28,46 @@ class QdrantVectorSearcher(BaseVectorSearcher):
28
28
 
29
29
  def __init__(
30
30
  self,
31
- uuid: str,
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
- self.vector_name: t.Optional[str] = config_dict.pop("vector_name", None)
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.collection_name = uuid
55
+ self.identifier = identifier
42
56
  self.measure = measure
43
57
 
44
- self.collection_name = re.sub("\W+", "", uuid)
45
- if not self.client.collection_exists(self.collection_name):
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.collection_name,
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, db):
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.collection_name).vectors_count
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.collection_name,
88
+ collection_name=self.identifier,
74
89
  vectors_config=models.VectorParams(size=self.dimensions, distance=distance),
75
90
  )
76
91
 
@@ -82,17 +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.collection_name, points=points)
110
+ self.client.upsert(collection_name=self.identifier, points=points)
111
+
112
+ def drop(self):
113
+ """Drop the vector index."""
114
+ if self.client.collection_exists(self.identifier):
115
+ self.client.delete_collection(self.identifier)
96
116
 
97
117
  def delete(self, ids: t.Sequence[str]) -> None:
98
118
  """Delete vectors from the index.
@@ -100,7 +120,7 @@ class QdrantVectorSearcher(BaseVectorSearcher):
100
120
  :param ids: List of IDs to delete
101
121
  """
102
122
  self.client.delete(
103
- collection_name=self.collection_name,
123
+ collection_name=self.identifier,
104
124
  points_selector=models.Filter(
105
125
  must=[
106
126
  models.FieldCondition(
@@ -155,12 +175,12 @@ class QdrantVectorSearcher(BaseVectorSearcher):
155
175
  )
156
176
 
157
177
  search_result = self.client.query_points(
158
- collection_name=self.collection_name,
178
+ collection_name=self.identifier,
159
179
  query=query,
160
180
  limit=n,
161
181
  query_filter=query_filter,
162
182
  with_payload=[ID_PAYLOAD_KEY],
163
- using=self.vector_name,
183
+ using=None,
164
184
  ).points
165
185
 
166
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.6.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,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,7 +0,0 @@
1
- superduper_qdrant/__init__.py,sha256=2kymmBosHgXZPfBBgXY_j6StgxP0yJOtCCjOh1kG-ok,112
2
- superduper_qdrant/qdrant.py,sha256=Wkmo2N7tnA7zguC6RVtD5-XVXR3GqVAfcgzPxj7objM,6254
3
- superduper_qdrant-0.6.0.dist-info/licenses/LICENSE,sha256=fq2WxmjewRN4VfDClVl-6CiVFZedp4y5_iGqQiXHBN8,11353
4
- superduper_qdrant-0.6.0.dist-info/METADATA,sha256=XREh1ha84W_dcLeRfioueUahLEd61on4qog0riHHVn8,13638
5
- superduper_qdrant-0.6.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
6
- superduper_qdrant-0.6.0.dist-info/top_level.txt,sha256=sq-9pdkTJIhMAzMoSI_UlucyRUrPk4Da78PFG_hPcd8,18
7
- superduper_qdrant-0.6.0.dist-info/RECORD,,