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

Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
Daniel Cooke 2024-09-19 05:21:24 +01:00 committed by GitHub
parent 85caaa773f
commit 7835c0651f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 1 deletions

View File

@ -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)

View File

@ -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()