Skip to content

The agent engineering platform.

langchain_chroma: Pass through kwargs to Chroma collection.delete (#25970)

Daniel Cooke7835c0651fef
diff --git a/libs/partners/chroma/langchain_chroma/vectorstores.py b/libs/partners/chroma/langchain_chroma/vectorstores.py
index 76ad86d67a..90c59ef2be 100644
--- a/libs/partners/chroma/langchain_chroma/vectorstores.py
+++ b/libs/partners/chroma/langchain_chroma/vectorstores.py
@@ -1145,4 +1145,4 @@ class Chroma(VectorStore):
ids: List of ids to delete.
kwargs: Additional keyword arguments.
"""
- self._collection.delete(ids=ids)
+ self._collection.delete(ids=ids, **kwargs)
diff --git a/libs/partners/chroma/tests/integration_tests/test_vectorstores.py b/libs/partners/chroma/tests/integration_tests/test_vectorstores.py
index 921ed22c6e..382b24cb54 100644
--- a/libs/partners/chroma/tests/integration_tests/test_vectorstores.py
+++ b/libs/partners/chroma/tests/integration_tests/test_vectorstores.py
@@ -528,3 +528,23 @@ def test_reset_collection(client: chromadb.ClientAPI) -> None:
assert vectorstore._collection.count() == 0
# Clean up
vectorstore.delete_collection()
+
+
+def test_delete_where_clause(client: chromadb.ClientAPI) -> None:
+ """Tests delete_where_clause method."""
+ vectorstore = Chroma(
+ client=client,
+ collection_name="test_collection",
+ embedding_function=FakeEmbeddings(),
+ )
+ vectorstore.add_documents(
+ [
+ Document(page_content="foo", metadata={"test": "bar"}),
+ Document(page_content="bar", metadata={"test": "foo"}),
+ ]
+ )
+ assert vectorstore._collection.count() == 2
+ vectorstore.delete(where={"test": "bar"})
+ assert vectorstore._collection.count() == 1
+ # Clean up
+ vectorstore.delete_collection()