superduper-qdrant 0.7.0__tar.gz → 0.9.1__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.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:
@@ -1,5 +1,5 @@
1
1
  from .qdrant import QdrantVectorSearcher as VectorSearcher
2
2
 
3
- __version__ = "0.7.0"
3
+ __version__ = "0.9.1"
4
4
 
5
5
  __all__ = ['VectorSearcher']
@@ -28,31 +28,48 @@ 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 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.collection_name = uuid
57
+ self.identifier = identifier
42
58
  self.measure = measure
43
59
 
44
- self.collection_name = re.sub("\W+", "", uuid)
45
- if not self.client.collection_exists(self.collection_name):
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.collection_name,
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, db):
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.collection_name).vectors_count
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.collection_name,
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.collection_name, points=points)
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.collection_name):
100
- self.client.delete_collection(self.collection_name)
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.collection_name,
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.collection_name,
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=self.vector_name,
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.7.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: