mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-23 23:29:21 +00:00
langchain_chroma: Pass through kwargs to Chroma collection.delete (#25970)
Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
parent
85caaa773f
commit
7835c0651f
@ -1145,4 +1145,4 @@ class Chroma(VectorStore):
|
|||||||
ids: List of ids to delete.
|
ids: List of ids to delete.
|
||||||
kwargs: Additional keyword arguments.
|
kwargs: Additional keyword arguments.
|
||||||
"""
|
"""
|
||||||
self._collection.delete(ids=ids)
|
self._collection.delete(ids=ids, **kwargs)
|
||||||
|
@ -528,3 +528,23 @@ def test_reset_collection(client: chromadb.ClientAPI) -> None:
|
|||||||
assert vectorstore._collection.count() == 0
|
assert vectorstore._collection.count() == 0
|
||||||
# Clean up
|
# Clean up
|
||||||
vectorstore.delete_collection()
|
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()
|
||||||
|
Loading…
Reference in New Issue
Block a user