superduper-qdrant 0.7.0__tar.gz → 0.9.0__tar.gz

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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: superduper_qdrant
3
- Version: 0.7.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:
@@ -1,5 +1,5 @@
1
1
  from .qdrant import QdrantVectorSearcher as VectorSearcher
2
2
 
3
- __version__ = "0.7.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,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.collection_name, points=points)
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.collection_name):
100
- self.client.delete_collection(self.collection_name)
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.collection_name,
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.collection_name,
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=self.vector_name,
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.7.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: