cognee-community-vector-adapter-qdrant 0.0.2__py3-none-any.whl → 0.0.3__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,3 +1,3 @@
1
1
  from .qdrant_adapter import QDrantAdapter
2
2
 
3
- __all__ = ["QDrantAdapter"]
3
+ __all__ = ["QDrantAdapter"]
@@ -2,14 +2,16 @@ import asyncio
2
2
  from typing import Dict, List, Optional
3
3
  from qdrant_client import AsyncQdrantClient, models
4
4
 
5
- from cognee.exceptions import InvalidValueError
6
5
  from cognee.shared.logging_utils import get_logger
7
6
 
8
7
  from cognee.infrastructure.engine import DataPoint
9
8
  from cognee.infrastructure.engine.utils import parse_id
9
+ from cognee.infrastructure.databases.exceptions import MissingQueryParameterError
10
10
  from cognee.infrastructure.databases.vector import VectorDBInterface
11
11
  from cognee.infrastructure.databases.vector.models.ScoredResult import ScoredResult
12
- from cognee.infrastructure.databases.vector.embeddings.EmbeddingEngine import EmbeddingEngine
12
+ from cognee.infrastructure.databases.vector.embeddings.EmbeddingEngine import (
13
+ EmbeddingEngine,
14
+ )
13
15
  from cognee.infrastructure.databases.vector.exceptions import CollectionNotFoundError
14
16
 
15
17
  logger = get_logger("QDrantAdapter")
@@ -21,7 +23,6 @@ class IndexSchema(DataPoint):
21
23
  metadata: dict = {"index_fields": ["text"]}
22
24
 
23
25
 
24
-
25
26
  def create_hnsw_config(hnsw_config: Dict):
26
27
  if hnsw_config is not None:
27
28
  return models.HnswConfig()
@@ -46,7 +47,9 @@ class QDrantAdapter(VectorDBInterface):
46
47
  api_key: str = None
47
48
  qdrant_path: str = None
48
49
 
49
- def __init__(self, url, api_key, embedding_engine: EmbeddingEngine, qdrant_path=None):
50
+ def __init__(
51
+ self, url, api_key, embedding_engine: EmbeddingEngine, qdrant_path=None
52
+ ):
50
53
  self.embedding_engine = embedding_engine
51
54
 
52
55
  if qdrant_path is not None:
@@ -86,14 +89,17 @@ class QDrantAdapter(VectorDBInterface):
86
89
  collection_name=collection_name,
87
90
  vectors_config={
88
91
  "text": models.VectorParams(
89
- size=self.embedding_engine.get_vector_size(), distance="Cosine"
92
+ size=self.embedding_engine.get_vector_size(),
93
+ distance="Cosine",
90
94
  )
91
95
  },
92
96
  )
93
97
 
94
98
  await client.close()
95
99
 
96
- async def create_data_points(self, collection_name: str, data_points: List[DataPoint]):
100
+ async def create_data_points(
101
+ self, collection_name: str, data_points: List[DataPoint]
102
+ ):
97
103
  from qdrant_client.http.exceptions import UnexpectedResponse
98
104
 
99
105
  client = self.get_qdrant_client()
@@ -145,7 +151,9 @@ class QDrantAdapter(VectorDBInterface):
145
151
 
146
152
  async def retrieve(self, collection_name: str, data_point_ids: list[str]):
147
153
  client = self.get_qdrant_client()
148
- results = await client.retrieve(collection_name, data_point_ids, with_payload=True)
154
+ results = await client.retrieve(
155
+ collection_name, data_point_ids, with_payload=True
156
+ )
149
157
  await client.close()
150
158
  return results
151
159
 
@@ -160,7 +168,7 @@ class QDrantAdapter(VectorDBInterface):
160
168
  from qdrant_client.http.exceptions import UnexpectedResponse
161
169
 
162
170
  if query_text is None and query_vector is None:
163
- raise InvalidValueError(message="One of query_text or query_vector must be provided!")
171
+ raise MissingQueryParameterError()
164
172
 
165
173
  if not await self.has_collection(collection_name):
166
174
  return []
@@ -172,6 +180,9 @@ class QDrantAdapter(VectorDBInterface):
172
180
  client = self.get_qdrant_client()
173
181
  if limit == 0:
174
182
  collection_size = await client.count(collection_name=collection_name)
183
+ limit = collection_size.count
184
+ if limit == 0:
185
+ return []
175
186
 
176
187
  results = await client.search(
177
188
  collection_name=collection_name,
@@ -181,7 +192,7 @@ class QDrantAdapter(VectorDBInterface):
181
192
  if query_vector is not None
182
193
  else (await self.embed_data([query_text]))[0],
183
194
  ),
184
- limit=limit if limit > 0 else collection_size.count,
195
+ limit=limit,
185
196
  with_vectors=with_vector,
186
197
  )
187
198
 
@@ -236,11 +247,16 @@ class QDrantAdapter(VectorDBInterface):
236
247
  client = self.get_qdrant_client()
237
248
 
238
249
  # Perform batch search with the dynamically generated requests
239
- results = await client.search_batch(collection_name=collection_name, requests=requests)
250
+ results = await client.search_batch(
251
+ collection_name=collection_name, requests=requests
252
+ )
240
253
 
241
254
  await client.close()
242
255
 
243
- return [filter(lambda result: result.score > 0.9, result_group) for result_group in results]
256
+ return [
257
+ filter(lambda result: result.score > 0.9, result_group)
258
+ for result_group in results
259
+ ]
244
260
 
245
261
  async def delete_data_points(self, collection_name: str, data_point_ids: list[str]):
246
262
  client = self.get_qdrant_client()
@@ -0,0 +1,52 @@
1
+ Metadata-Version: 2.3
2
+ Name: cognee-community-vector-adapter-qdrant
3
+ Version: 0.0.3
4
+ Summary: Qdrant vector database adapter for cognee
5
+ Requires-Python: >=3.11,<=3.13
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Programming Language :: Python :: 3.11
8
+ Classifier: Programming Language :: Python :: 3.12
9
+ Classifier: Programming Language :: Python :: 3.13
10
+ Requires-Dist: cognee (>=0.2.4)
11
+ Requires-Dist: qdrant-client (>=1.14.2)
12
+ Description-Content-Type: text/markdown
13
+
14
+ # Cognee Qdrant Adapter
15
+
16
+ ## Installation
17
+
18
+ If published, the package can be simply installed via pip:
19
+
20
+ ```bash
21
+ pip install cognee-community-vector-adapter-qdrant
22
+ ```
23
+
24
+ In case it is not published yet, you can use poetry to locally build the adapter package:
25
+
26
+ ```bash
27
+ pip install poetry
28
+ poetry install # run this command in the directory containing the pyproject.toml file
29
+ ```
30
+
31
+ ## Connection Setup
32
+
33
+ For a quick local setup, you can run a docker container that qdrant provides (https://qdrant.tech/documentation/quickstart/).
34
+ After this, you will be able to connect to the Qdrant DB through the appropriate ports. The command for running the docker
35
+ container looks something like the following:
36
+
37
+ ```
38
+ docker run -p 6333:6333 -p 6334:6334 \
39
+ -v "$(pwd)/qdrant_storage:/qdrant/storage:z" \
40
+ qdrant/qdrant
41
+ ```
42
+
43
+ ## Usage
44
+
45
+ Import and register the adapter in your code:
46
+ ```python
47
+ from cognee_community_vector_adapter_qdrant import register
48
+ ```
49
+
50
+ ## Example
51
+ See example in `example.py` file.
52
+
@@ -0,0 +1,6 @@
1
+ cognee_community_vector_adapter_qdrant/__init__.py,sha256=OYsRMTyBnNuusKB3rkQmwCppfdEf__AuXMw_Ma1k6lQ,71
2
+ cognee_community_vector_adapter_qdrant/qdrant_adapter.py,sha256=7asKZ88lMtkEK12p0oZpOR5BdxVPFE7S74fghp5B6ec,9042
3
+ cognee_community_vector_adapter_qdrant/register.py,sha256=K0cIQGN3an79wWCMXAIgwsymkloHGV2_joy7G-4aiB8,158
4
+ cognee_community_vector_adapter_qdrant-0.0.3.dist-info/METADATA,sha256=j3c11rgh4DzvPAvyYo8h5SnvCplSAy8SwWf9S770iQ0,1466
5
+ cognee_community_vector_adapter_qdrant-0.0.3.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
6
+ cognee_community_vector_adapter_qdrant-0.0.3.dist-info/RECORD,,
@@ -1,28 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: cognee-community-vector-adapter-qdrant
3
- Version: 0.0.2
4
- Summary: Qdrant vector database adapter for cognee
5
- Requires-Python: >=3.11,<=3.13
6
- Classifier: Programming Language :: Python :: 3
7
- Classifier: Programming Language :: Python :: 3.11
8
- Classifier: Programming Language :: Python :: 3.12
9
- Classifier: Programming Language :: Python :: 3.13
10
- Requires-Dist: cognee (>=0.2.1)
11
- Requires-Dist: qdrant-client (>=1.14.2)
12
- Description-Content-Type: text/markdown
13
-
14
- # Cognee Qdrant Adapter
15
-
16
- ## Install
17
-
18
- Install [`qdrant-client`](https://pypi.org/project/qdrant-client/) in your project.
19
-
20
- Put this line of code somewhere at the start of the execution, before cognee is initiated.
21
-
22
- ```python
23
- import packages.vector.qdrant.register
24
- ```
25
-
26
- ## Example
27
- See example in `example.py` file.
28
-
@@ -1,6 +0,0 @@
1
- cognee_community_vector_adapter_qdrant/__init__.py,sha256=PVY2CqYr0JnjErQoDSEobMol0M2BwZFnSOppfJq1cHs,71
2
- cognee_community_vector_adapter_qdrant/qdrant_adapter.py,sha256=TFUSVVrXy-0DZxu-DgjUuPIzvqSaaFvFyt_-pRPKCKQ,8858
3
- cognee_community_vector_adapter_qdrant/register.py,sha256=K0cIQGN3an79wWCMXAIgwsymkloHGV2_joy7G-4aiB8,158
4
- cognee_community_vector_adapter_qdrant-0.0.2.dist-info/METADATA,sha256=UZdDQQJITyPWanHHP-N322-aXVxjRxikua-Yg2reVsA,792
5
- cognee_community_vector_adapter_qdrant-0.0.2.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
6
- cognee_community_vector_adapter_qdrant-0.0.2.dist-info/RECORD,,