llama-index-vector-stores-chroma 0.1.7__py3-none-any.whl → 0.1.9__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.

@@ -48,6 +48,10 @@ def _transform_chroma_filter_operator(operator: str) -> str:
48
48
  return "$gte"
49
49
  elif operator == "<=":
50
50
  return "$lte"
51
+ elif operator == "in":
52
+ return "$in"
53
+ elif operator == "nin":
54
+ return "$nin"
51
55
  else:
52
56
  raise ValueError(f"Filter operator {operator} not supported")
53
57
 
@@ -144,7 +148,7 @@ class ChromaVectorStore(BasePydanticVectorStore):
144
148
  persist_dir: Optional[str]
145
149
  collection_kwargs: Dict[str, Any] = Field(default_factory=dict)
146
150
 
147
- _collection: Any = PrivateAttr()
151
+ _collection: Collection = PrivateAttr()
148
152
 
149
153
  def __init__(
150
154
  self,
@@ -231,6 +235,32 @@ class ChromaVectorStore(BasePydanticVectorStore):
231
235
  def class_name(cls) -> str:
232
236
  return "ChromaVectorStore"
233
237
 
238
+ def get_nodes(
239
+ self,
240
+ node_ids: Optional[List[str]],
241
+ filters: Optional[List[MetadataFilters]] = None,
242
+ ) -> List[BaseNode]:
243
+ """Get nodes from index.
244
+
245
+ Args:
246
+ node_ids (List[str]): list of node ids
247
+ filters (List[MetadataFilters]): list of metadata filters
248
+
249
+ """
250
+ if not self._collection:
251
+ raise ValueError("Collection not initialized")
252
+
253
+ node_ids = node_ids or []
254
+
255
+ if filters:
256
+ where = _to_chroma_filter(filters)
257
+ else:
258
+ where = {}
259
+
260
+ result = self._get(None, where=where, ids=node_ids)
261
+
262
+ return result.nodes
263
+
234
264
  def add(self, nodes: List[BaseNode], **add_kwargs: Any) -> List[str]:
235
265
  """Add nodes to index.
236
266
 
@@ -282,6 +312,35 @@ class ChromaVectorStore(BasePydanticVectorStore):
282
312
  """
283
313
  self._collection.delete(where={"document_id": ref_doc_id})
284
314
 
315
+ def delete_nodes(
316
+ self,
317
+ node_ids: Optional[List[str]] = None,
318
+ filters: Optional[List[MetadataFilters]] = None,
319
+ ) -> None:
320
+ """Delete nodes from index.
321
+
322
+ Args:
323
+ node_ids (List[str]): list of node ids
324
+ filters (List[MetadataFilters]): list of metadata filters
325
+
326
+ """
327
+ if not self._collection:
328
+ raise ValueError("Collection not initialized")
329
+
330
+ node_ids = node_ids or []
331
+
332
+ if filters:
333
+ where = _to_chroma_filter(filters)
334
+ else:
335
+ where = {}
336
+
337
+ self._collection.delete(ids=node_ids, where=where)
338
+
339
+ def clear(self) -> None:
340
+ """Clear the collection."""
341
+ ids = self._collection.get()["ids"]
342
+ self._collection.delete(ids=ids)
343
+
285
344
  @property
286
345
  def client(self) -> Any:
287
346
  """Return client."""
@@ -326,7 +385,7 @@ class ChromaVectorStore(BasePydanticVectorStore):
326
385
  **kwargs,
327
386
  )
328
387
 
329
- logger.debug(f"> Top {len(results['documents'])} nodes:")
388
+ logger.debug(f"> Top {len(results['documents'][0])} nodes:")
330
389
  nodes = []
331
390
  similarities = []
332
391
  ids = []
@@ -367,7 +426,9 @@ class ChromaVectorStore(BasePydanticVectorStore):
367
426
 
368
427
  return VectorStoreQueryResult(nodes=nodes, similarities=similarities, ids=ids)
369
428
 
370
- def _get(self, limit: int, where: dict, **kwargs) -> VectorStoreQueryResult:
429
+ def _get(
430
+ self, limit: Optional[int], where: dict, **kwargs
431
+ ) -> VectorStoreQueryResult:
371
432
  results = self._collection.get(
372
433
  limit=limit,
373
434
  where=where,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: llama-index-vector-stores-chroma
3
- Version: 0.1.7
3
+ Version: 0.1.9
4
4
  Summary: llama-index vector_stores chroma integration
5
5
  License: MIT
6
6
  Author: Your Name
@@ -0,0 +1,5 @@
1
+ llama_index/vector_stores/chroma/__init__.py,sha256=QNMK-nHKEt-wmks5mhWfdOKDybpmsqrL4neV-HCA6N4,101
2
+ llama_index/vector_stores/chroma/base.py,sha256=_PxgEShceRgIq_f4l-T19GlUQSQm_4akn7BYlUluPk4,14842
3
+ llama_index_vector_stores_chroma-0.1.9.dist-info/METADATA,sha256=Yr549GoPezUy0Hfb-BwH5sgfCVKeTpiHWKXVi2qR3Us,653
4
+ llama_index_vector_stores_chroma-0.1.9.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
5
+ llama_index_vector_stores_chroma-0.1.9.dist-info/RECORD,,
@@ -1,5 +0,0 @@
1
- llama_index/vector_stores/chroma/__init__.py,sha256=QNMK-nHKEt-wmks5mhWfdOKDybpmsqrL4neV-HCA6N4,101
2
- llama_index/vector_stores/chroma/base.py,sha256=OlB4EU_CZZTdlIxyPWEyliydz1__nvLbXpY7H8TNi34,13268
3
- llama_index_vector_stores_chroma-0.1.7.dist-info/METADATA,sha256=NfLG6nmPL5KxbgQjxTnbg4rlYiSzDEKNiiat9ZYcqiM,653
4
- llama_index_vector_stores_chroma-0.1.7.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
5
- llama_index_vector_stores_chroma-0.1.7.dist-info/RECORD,,