The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
community: add len() implementation to Chroma (#19419)
Adrian Valente2763d8cbe5c8
diff --git a/libs/community/langchain_community/vectorstores/chroma.py b/libs/community/langchain_community/vectorstores/chroma.pyindex 3bcb389cff..7723285faf 100644--- a/libs/community/langchain_community/vectorstores/chroma.py+++ b/libs/community/langchain_community/vectorstores/chroma.py@@ -795,3 +795,7 @@ class Chroma(VectorStore):ids: List of ids to delete."""self._collection.delete(ids=ids)++ def __len__(self) -> int:+ """Count the number of documents in the collection."""+ return self._collection.count()diff --git a/libs/community/tests/integration_tests/vectorstores/test_chroma.py b/libs/community/tests/integration_tests/vectorstores/test_chroma.pyindex 58e9bcf454..0a0cf529d0 100644--- a/libs/community/tests/integration_tests/vectorstores/test_chroma.py+++ b/libs/community/tests/integration_tests/vectorstores/test_chroma.py@@ -21,6 +21,7 @@ def test_chroma() -> None:)output = docsearch.similarity_search("foo", k=1)assert output == [Document(page_content="foo")]+ assert len(docsearch) == 3async def test_chroma_async() -> None: