Skip to content

Commit

Permalink
community: chroma error patch(attribute changed on chroma) (langchain…
Browse files Browse the repository at this point in the history
…-ai#27827)

There was a change of attribute name which was "max_batch_size". It's
now "get_max_batch_size" method.
I want to use "create_batches" which is right down below.

Please check this PR link.
reference: chroma-core/chroma#2305

---------

Signed-off-by: Prithvi Kannan <[email protected]>
Co-authored-by: Prithvi Kannan <[email protected]>
Co-authored-by: Bagatur <[email protected]>
Co-authored-by: Erick Friis <[email protected]>
Co-authored-by: Jun Yamog <[email protected]>
Co-authored-by: Bagatur <[email protected]>
Co-authored-by: ono-hiroki <[email protected]>
Co-authored-by: Dobiichi-Origami <[email protected]>
Co-authored-by: Chester Curme <[email protected]>
Co-authored-by: Duy Huynh <[email protected]>
Co-authored-by: Rashmi Pawar <[email protected]>
Co-authored-by: sifatj <[email protected]>
Co-authored-by: Eric Pinzur <[email protected]>
Co-authored-by: Daniel Vu Dao <[email protected]>
Co-authored-by: Ofer Mendelevitch <[email protected]>
Co-authored-by: Stéphane Philippart <[email protected]>
  • Loading branch information
16 people authored and yanomaly committed Nov 8, 2024
1 parent a5fae44 commit 029febc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion libs/community/langchain_community/vectorstores/chroma.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,9 @@ def update_documents(self, ids: List[str], documents: List[Document]) -> None:
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
Expand Down Expand Up @@ -824,7 +827,10 @@ def from_texts(
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

Expand Down
4 changes: 4 additions & 0 deletions libs/partners/chroma/langchain_chroma/vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,8 @@ def update_documents(self, ids: List[str], documents: List[Document]) -> None:
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
Expand Down Expand Up @@ -1070,6 +1072,8 @@ def from_texts(
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
Expand Down

0 comments on commit 029febc

Please sign in to comment.