Skip to content

The agent engineering platform.

community: chroma error patch(attribute changed on chroma) (#27827)

SHJUNf6b2f8209942
diff --git a/libs/community/langchain_community/vectorstores/chroma.py b/libs/community/langchain_community/vectorstores/chroma.py
index 40ba2415b6..1ab7ddad14 100644
--- a/libs/community/langchain_community/vectorstores/chroma.py
+++ b/libs/community/langchain_community/vectorstores/chroma.py
@@ -753,6 +753,9 @@ class Chroma(VectorStore):
embeddings = self._embedding_function.embed_documents(text)
if hasattr(
+ self._collection._client,
+ "get_max_batch_size", # for Chroma 0.5.1 and above
+ ) or hasattr(
self._collection._client, "max_batch_size"
): # for Chroma 0.4.10 and above
from chromadb.utils.batch_utils import create_batches
@@ -824,7 +827,10 @@ class Chroma(VectorStore):
ids = [str(uuid.uuid4()) for _ in texts]
if hasattr(
chroma_collection._client, # type: ignore[has-type]
- "max_batch_size", # type: ignore[has-type]
+ "get_max_batch_size", # for Chroma 0.5.1 and above
+ ) or hasattr(
+ chroma_collection._client, # type: ignore[has-type]
+ "max_batch_size",
): # for Chroma 0.4.10 and above
from chromadb.utils.batch_utils import create_batches
diff --git a/libs/partners/chroma/langchain_chroma/vectorstores.py b/libs/partners/chroma/langchain_chroma/vectorstores.py
index 945057f4ad..35146fdcc7 100644
--- a/libs/partners/chroma/langchain_chroma/vectorstores.py
+++ b/libs/partners/chroma/langchain_chroma/vectorstores.py
@@ -997,6 +997,8 @@ class Chroma(VectorStore):
embeddings = self._embedding_function.embed_documents(text)
if hasattr(
+ self._collection._client, "get_max_batch_size"
+ ) or hasattr( # for Chroma 0.5.1 and above
self._collection._client, "max_batch_size"
): # for Chroma 0.4.10 and above
from chromadb.utils.batch_utils import create_batches
@@ -1070,6 +1072,8 @@ class Chroma(VectorStore):
if ids is None:
ids = [str(uuid.uuid4()) for _ in texts]
if hasattr(
+ chroma_collection._client, "get_max_batch_size"
+ ) or hasattr( # for Chroma 0.5.1 and above
chroma_collection._client, "max_batch_size"
): # for Chroma 0.4.10 and above
from chromadb.utils.batch_utils import create_batches