|
13 | 13 | from urllib.parse import urlparse |
14 | 14 |
|
15 | 15 | import chromadb |
| 16 | + |
| 17 | +if not chromadb.__version__.startswith("0.6.3"): # pragma: nocover |
| 18 | + logging.error( |
| 19 | + f""" |
| 20 | + Found ChromaDB {chromadb.__version__}, which is incompatible with your VectorCode installation. Please install vectorcode[chroma0]. |
| 21 | +
|
| 22 | + For example: |
| 23 | + uv tool install vectorcode[chroma0] |
| 24 | + """ |
| 25 | + ) |
| 26 | + sys.exit(1) |
16 | 27 | import httpx |
17 | 28 | from chromadb.api import AsyncClientAPI |
18 | 29 | from chromadb.api.models.AsyncCollection import AsyncCollection |
| 30 | +from chromadb.api.types import IncludeEnum |
19 | 31 | from chromadb.config import APIVersion, Settings |
20 | 32 | from tree_sitter import Point |
21 | 33 |
|
@@ -124,16 +136,6 @@ class _Chroma0ClientManager: |
124 | 136 | __clients: dict[str, _Chroma0ClientModel] |
125 | 137 |
|
126 | 138 | def __new__(cls) -> "_Chroma0ClientManager": |
127 | | - if not chromadb.__version__.startswith("0.6.3"): # pragma: nocover |
128 | | - _logger.error( |
129 | | - f""" |
130 | | - Found ChromaDB {chromadb.__version__}, which is incompatible with your VectorCode installation. Please install vectorcode[chroma0]. |
131 | | -
|
132 | | - For example: |
133 | | - uv tool install vectorcode[chroma0] |
134 | | - """ |
135 | | - ) |
136 | | - sys.exit(1) |
137 | 139 | if cls.singleton is None: |
138 | 140 | cls.singleton = super().__new__(cls) |
139 | 141 | cls.singleton.__clients = {} |
@@ -277,9 +279,9 @@ async def query(self): |
277 | 279 | query_result = await collection.query( |
278 | 280 | query_embeddings=keywords_embeddings, |
279 | 281 | include=[ |
280 | | - "metadatas", |
281 | | - "documents", |
282 | | - "distances", |
| 282 | + IncludeEnum.metadatas, |
| 283 | + IncludeEnum.documents, |
| 284 | + IncludeEnum.distances, |
283 | 285 | ], |
284 | 286 | n_results=query_count, |
285 | 287 | where=query_filter, |
@@ -433,8 +435,8 @@ async def list_collection_content( |
433 | 435 | content = CollectionContent() |
434 | 436 | raw_content = await collection.get( |
435 | 437 | include=[ |
436 | | - "metadatas", |
437 | | - "documents", |
| 438 | + IncludeEnum.metadatas, |
| 439 | + IncludeEnum.documents, |
438 | 440 | ] |
439 | 441 | ) |
440 | 442 | metadatas = raw_content.get("metadatas", []) |
@@ -527,7 +529,7 @@ async def get_chunks(self, file_path) -> list[Chunk]: |
527 | 529 |
|
528 | 530 | raw_results = await collection.get( |
529 | 531 | where={"path": file_path}, |
530 | | - include=["metadatas", "documents"], |
| 532 | + include=[IncludeEnum.metadatas, IncludeEnum.documents], |
531 | 533 | ) |
532 | 534 | assert raw_results["metadatas"] is not None |
533 | 535 | assert raw_results["documents"] is not None |
|
0 commit comments