llama-index-vector-stores-chroma 0.4.0__py3-none-any.whl → 0.4.2__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.
Potentially problematic release.
This version of llama-index-vector-stores-chroma might be problematic. Click here for more details.
- llama_index/vector_stores/chroma/base.py +44 -24
- llama_index_vector_stores_chroma-0.4.2.dist-info/METADATA +13 -0
- llama_index_vector_stores_chroma-0.4.2.dist-info/RECORD +7 -0
- {llama_index_vector_stores_chroma-0.4.0.dist-info → llama_index_vector_stores_chroma-0.4.2.dist-info}/WHEEL +1 -1
- llama_index_vector_stores_chroma-0.4.2.dist-info/licenses/LICENSE +21 -0
- llama_index_vector_stores_chroma-0.4.0.dist-info/METADATA +0 -20
- llama_index_vector_stores_chroma-0.4.0.dist-info/RECORD +0 -6
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
4
|
import math
|
|
5
|
-
from typing import Any, Dict, Generator, List, Optional, cast
|
|
5
|
+
from typing import Any, Dict, Generator, List, Optional, Union, cast
|
|
6
6
|
|
|
7
7
|
import chromadb
|
|
8
8
|
from chromadb.api.models.Collection import Collection
|
|
@@ -95,7 +95,8 @@ MAX_CHUNK_SIZE = 41665 # One less than the max chunk size for ChromaDB
|
|
|
95
95
|
def chunk_list(
|
|
96
96
|
lst: List[BaseNode], max_chunk_size: int
|
|
97
97
|
) -> Generator[List[BaseNode], None, None]:
|
|
98
|
-
"""
|
|
98
|
+
"""
|
|
99
|
+
Yield successive max_chunk_size-sized chunks from lst.
|
|
99
100
|
|
|
100
101
|
Args:
|
|
101
102
|
lst (List[BaseNode]): list of nodes with embeddings
|
|
@@ -103,13 +104,15 @@ def chunk_list(
|
|
|
103
104
|
|
|
104
105
|
Yields:
|
|
105
106
|
Generator[List[BaseNode], None, None]: list of nodes with embeddings
|
|
107
|
+
|
|
106
108
|
"""
|
|
107
109
|
for i in range(0, len(lst), max_chunk_size):
|
|
108
110
|
yield lst[i : i + max_chunk_size]
|
|
109
111
|
|
|
110
112
|
|
|
111
113
|
class ChromaVectorStore(BasePydanticVectorStore):
|
|
112
|
-
"""
|
|
114
|
+
"""
|
|
115
|
+
Chroma vector store.
|
|
113
116
|
|
|
114
117
|
In this vector store, embeddings are stored within a ChromaDB collection.
|
|
115
118
|
|
|
@@ -142,7 +145,7 @@ class ChromaVectorStore(BasePydanticVectorStore):
|
|
|
142
145
|
|
|
143
146
|
collection_name: Optional[str]
|
|
144
147
|
host: Optional[str]
|
|
145
|
-
port: Optional[str]
|
|
148
|
+
port: Optional[Union[str, int]]
|
|
146
149
|
ssl: bool
|
|
147
150
|
headers: Optional[Dict[str, str]]
|
|
148
151
|
persist_dir: Optional[str]
|
|
@@ -155,7 +158,7 @@ class ChromaVectorStore(BasePydanticVectorStore):
|
|
|
155
158
|
chroma_collection: Optional[Any] = None,
|
|
156
159
|
collection_name: Optional[str] = None,
|
|
157
160
|
host: Optional[str] = None,
|
|
158
|
-
port: Optional[str] = None,
|
|
161
|
+
port: Optional[Union[str, int]] = None,
|
|
159
162
|
ssl: bool = False,
|
|
160
163
|
headers: Optional[Dict[str, str]] = None,
|
|
161
164
|
persist_dir: Optional[str] = None,
|
|
@@ -199,7 +202,7 @@ class ChromaVectorStore(BasePydanticVectorStore):
|
|
|
199
202
|
cls,
|
|
200
203
|
collection_name: str,
|
|
201
204
|
host: Optional[str] = None,
|
|
202
|
-
port: Optional[str] = None,
|
|
205
|
+
port: Optional[Union[str, int]] = None,
|
|
203
206
|
ssl: bool = False,
|
|
204
207
|
headers: Optional[Dict[str, str]] = None,
|
|
205
208
|
persist_dir: Optional[str] = None,
|
|
@@ -240,7 +243,8 @@ class ChromaVectorStore(BasePydanticVectorStore):
|
|
|
240
243
|
node_ids: Optional[List[str]],
|
|
241
244
|
filters: Optional[List[MetadataFilters]] = None,
|
|
242
245
|
) -> List[BaseNode]:
|
|
243
|
-
"""
|
|
246
|
+
"""
|
|
247
|
+
Get nodes from index.
|
|
244
248
|
|
|
245
249
|
Args:
|
|
246
250
|
node_ids (List[str]): list of node ids
|
|
@@ -262,7 +266,8 @@ class ChromaVectorStore(BasePydanticVectorStore):
|
|
|
262
266
|
return result.nodes
|
|
263
267
|
|
|
264
268
|
def add(self, nodes: List[BaseNode], **add_kwargs: Any) -> List[str]:
|
|
265
|
-
"""
|
|
269
|
+
"""
|
|
270
|
+
Add nodes to index.
|
|
266
271
|
|
|
267
272
|
Args:
|
|
268
273
|
nodes: List[BaseNode]: list of nodes with embeddings
|
|
@@ -317,7 +322,8 @@ class ChromaVectorStore(BasePydanticVectorStore):
|
|
|
317
322
|
node_ids: Optional[List[str]] = None,
|
|
318
323
|
filters: Optional[List[MetadataFilters]] = None,
|
|
319
324
|
) -> None:
|
|
320
|
-
"""
|
|
325
|
+
"""
|
|
326
|
+
Delete nodes from index.
|
|
321
327
|
|
|
322
328
|
Args:
|
|
323
329
|
node_ids (List[str]): list of node ids
|
|
@@ -331,10 +337,10 @@ class ChromaVectorStore(BasePydanticVectorStore):
|
|
|
331
337
|
|
|
332
338
|
if filters:
|
|
333
339
|
where = _to_chroma_filter(filters)
|
|
334
|
-
|
|
335
|
-
where = None
|
|
340
|
+
self._collection.delete(ids=node_ids, where=where)
|
|
336
341
|
|
|
337
|
-
|
|
342
|
+
else:
|
|
343
|
+
self._collection.delete(ids=node_ids)
|
|
338
344
|
|
|
339
345
|
def clear(self) -> None:
|
|
340
346
|
"""Clear the collection."""
|
|
@@ -347,7 +353,8 @@ class ChromaVectorStore(BasePydanticVectorStore):
|
|
|
347
353
|
return self._collection
|
|
348
354
|
|
|
349
355
|
def query(self, query: VectorStoreQuery, **kwargs: Any) -> VectorStoreQueryResult:
|
|
350
|
-
"""
|
|
356
|
+
"""
|
|
357
|
+
Query index for top k most similar nodes.
|
|
351
358
|
|
|
352
359
|
Args:
|
|
353
360
|
query_embedding (List[float]): query embedding
|
|
@@ -378,12 +385,19 @@ class ChromaVectorStore(BasePydanticVectorStore):
|
|
|
378
385
|
def _query(
|
|
379
386
|
self, query_embeddings: List["float"], n_results: int, where: dict, **kwargs
|
|
380
387
|
) -> VectorStoreQueryResult:
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
388
|
+
if where:
|
|
389
|
+
results = self._collection.query(
|
|
390
|
+
query_embeddings=query_embeddings,
|
|
391
|
+
n_results=n_results,
|
|
392
|
+
where=where,
|
|
393
|
+
**kwargs,
|
|
394
|
+
)
|
|
395
|
+
else:
|
|
396
|
+
results = self._collection.query(
|
|
397
|
+
query_embeddings=query_embeddings,
|
|
398
|
+
n_results=n_results,
|
|
399
|
+
**kwargs,
|
|
400
|
+
)
|
|
387
401
|
|
|
388
402
|
logger.debug(f"> Top {len(results['documents'][0])} nodes:")
|
|
389
403
|
nodes = []
|
|
@@ -429,11 +443,17 @@ class ChromaVectorStore(BasePydanticVectorStore):
|
|
|
429
443
|
def _get(
|
|
430
444
|
self, limit: Optional[int], where: dict, **kwargs
|
|
431
445
|
) -> VectorStoreQueryResult:
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
446
|
+
if where:
|
|
447
|
+
results = self._collection.get(
|
|
448
|
+
limit=limit,
|
|
449
|
+
where=where,
|
|
450
|
+
**kwargs,
|
|
451
|
+
)
|
|
452
|
+
else:
|
|
453
|
+
results = self._collection.get(
|
|
454
|
+
limit=limit,
|
|
455
|
+
**kwargs,
|
|
456
|
+
)
|
|
437
457
|
|
|
438
458
|
logger.debug(f"> Top {len(results['documents'])} nodes:")
|
|
439
459
|
nodes = []
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: llama-index-vector-stores-chroma
|
|
3
|
+
Version: 0.4.2
|
|
4
|
+
Summary: llama-index vector_stores chroma integration
|
|
5
|
+
Author-email: Your Name <you@example.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: <4.0,>=3.10
|
|
9
|
+
Requires-Dist: chromadb>=0.5.17
|
|
10
|
+
Requires-Dist: llama-index-core<0.13,>=0.12.0
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# LlamaIndex Vector_Stores Integration: Chroma
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
llama_index/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
llama_index/vector_stores/chroma/__init__.py,sha256=QNMK-nHKEt-wmks5mhWfdOKDybpmsqrL4neV-HCA6N4,101
|
|
3
|
+
llama_index/vector_stores/chroma/base.py,sha256=Sv1ZGpa_e9ZCRfhfMi8xLmcd_A586Z0TpoRESCcxglE,15359
|
|
4
|
+
llama_index_vector_stores_chroma-0.4.2.dist-info/METADATA,sha256=4xusRlNXdisiDzItXkZtXo-aL7Lx3iD2FMlBjBr885g,413
|
|
5
|
+
llama_index_vector_stores_chroma-0.4.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
6
|
+
llama_index_vector_stores_chroma-0.4.2.dist-info/licenses/LICENSE,sha256=JPQLUZD9rKvCTdu192Nk0V5PAwklIg6jANii3UmTyMs,1065
|
|
7
|
+
llama_index_vector_stores_chroma-0.4.2.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Jerry Liu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: llama-index-vector-stores-chroma
|
|
3
|
-
Version: 0.4.0
|
|
4
|
-
Summary: llama-index vector_stores chroma integration
|
|
5
|
-
License: MIT
|
|
6
|
-
Author: Your Name
|
|
7
|
-
Author-email: you@example.com
|
|
8
|
-
Requires-Python: >=3.9,<4.0
|
|
9
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
-
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
-
Requires-Dist: chromadb (>=0.5.17)
|
|
16
|
-
Requires-Dist: llama-index-core (>=0.12.0,<0.13.0)
|
|
17
|
-
Description-Content-Type: text/markdown
|
|
18
|
-
|
|
19
|
-
# LlamaIndex Vector_Stores Integration: Chroma
|
|
20
|
-
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
llama_index/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
llama_index/vector_stores/chroma/__init__.py,sha256=QNMK-nHKEt-wmks5mhWfdOKDybpmsqrL4neV-HCA6N4,101
|
|
3
|
-
llama_index/vector_stores/chroma/base.py,sha256=bMnmCNGwNSPbuCUi_J_DUfvpucNibq8l2U9C4AZOwXY,14845
|
|
4
|
-
llama_index_vector_stores_chroma-0.4.0.dist-info/METADATA,sha256=jicQJ7vcOH6oPwjdE5ty21WYwzU9jRrb4xuE1xffnq4,696
|
|
5
|
-
llama_index_vector_stores_chroma-0.4.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
6
|
-
llama_index_vector_stores_chroma-0.4.0.dist-info/RECORD,,
|