cognee-community-vector-adapter-qdrant 0.0.2__tar.gz → 0.0.3__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.
- cognee_community_vector_adapter_qdrant-0.0.3/PKG-INFO +52 -0
- cognee_community_vector_adapter_qdrant-0.0.3/README.md +38 -0
- {cognee_community_vector_adapter_qdrant-0.0.2 → cognee_community_vector_adapter_qdrant-0.0.3}/cognee_community_vector_adapter_qdrant/__init__.py +1 -1
- {cognee_community_vector_adapter_qdrant-0.0.2 → cognee_community_vector_adapter_qdrant-0.0.3}/cognee_community_vector_adapter_qdrant/qdrant_adapter.py +27 -11
- {cognee_community_vector_adapter_qdrant-0.0.2 → cognee_community_vector_adapter_qdrant-0.0.3}/pyproject.toml +2 -2
- cognee_community_vector_adapter_qdrant-0.0.2/PKG-INFO +0 -28
- cognee_community_vector_adapter_qdrant-0.0.2/README.md +0 -14
- {cognee_community_vector_adapter_qdrant-0.0.2 → cognee_community_vector_adapter_qdrant-0.0.3}/cognee_community_vector_adapter_qdrant/register.py +0 -0
|
@@ -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,38 @@
|
|
|
1
|
+
# Cognee Qdrant Adapter
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
If published, the package can be simply installed via pip:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install cognee-community-vector-adapter-qdrant
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
In case it is not published yet, you can use poetry to locally build the adapter package:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install poetry
|
|
15
|
+
poetry install # run this command in the directory containing the pyproject.toml file
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Connection Setup
|
|
19
|
+
|
|
20
|
+
For a quick local setup, you can run a docker container that qdrant provides (https://qdrant.tech/documentation/quickstart/).
|
|
21
|
+
After this, you will be able to connect to the Qdrant DB through the appropriate ports. The command for running the docker
|
|
22
|
+
container looks something like the following:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
docker run -p 6333:6333 -p 6334:6334 \
|
|
26
|
+
-v "$(pwd)/qdrant_storage:/qdrant/storage:z" \
|
|
27
|
+
qdrant/qdrant
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
Import and register the adapter in your code:
|
|
33
|
+
```python
|
|
34
|
+
from cognee_community_vector_adapter_qdrant import register
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Example
|
|
38
|
+
See example in `example.py` file.
|
|
@@ -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
|
|
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__(
|
|
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(),
|
|
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(
|
|
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(
|
|
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
|
|
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
|
|
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(
|
|
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 [
|
|
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()
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "cognee-community-vector-adapter-qdrant"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.3"
|
|
4
4
|
description = "Qdrant vector database adapter for cognee"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.11,<=3.13"
|
|
7
7
|
dependencies = [
|
|
8
8
|
"qdrant-client>=1.14.2",
|
|
9
|
-
"cognee>=0.2.
|
|
9
|
+
"cognee>=0.2.4",
|
|
10
10
|
]
|
|
@@ -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,14 +0,0 @@
|
|
|
1
|
-
# Cognee Qdrant Adapter
|
|
2
|
-
|
|
3
|
-
## Install
|
|
4
|
-
|
|
5
|
-
Install [`qdrant-client`](https://pypi.org/project/qdrant-client/) in your project.
|
|
6
|
-
|
|
7
|
-
Put this line of code somewhere at the start of the execution, before cognee is initiated.
|
|
8
|
-
|
|
9
|
-
```python
|
|
10
|
-
import packages.vector.qdrant.register
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Example
|
|
14
|
-
See example in `example.py` file.
|