Skip to content

The agent engineering platform.

Harrison/chroma fix (#6390)

Harrison Chase10bff4ecc420
diff --git a/langchain/vectorstores/chroma.py b/langchain/vectorstores/chroma.py
index 6b9be25eb8..59801f2b5a 100644
--- a/langchain/vectorstores/chroma.py
+++ b/langchain/vectorstores/chroma.py
@@ -109,29 +109,18 @@ class Chroma(VectorStore):
) -> List[Document]:
"""Query the chroma collection."""
try:
- import chromadb
+ import chromadb # noqa: F401
except ImportError:
raise ValueError(
"Could not import chromadb python package. "
"Please install it with `pip install chromadb`."
)
-
- for i in range(n_results, 0, -1):
- try:
- return self._collection.query(
- query_texts=query_texts,
- query_embeddings=query_embeddings,
- n_results=i,
- where=where,
- **kwargs,
- )
- except chromadb.errors.NotEnoughElementsException:
- logger.error(
- f"Chroma collection {self._collection.name} "
- f"contains fewer than {i} elements."
- )
- raise chromadb.errors.NotEnoughElementsException(
- f"No documents found for Chroma collection {self._collection.name}"
+ return self._collection.query(
+ query_texts=query_texts,
+ query_embeddings=query_embeddings,
+ n_results=n_results,
+ where=where,
+ **kwargs,
)
def add_texts(
diff --git a/pyproject.toml b/pyproject.toml
index b93fb33681..256304e363 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langchain"
-version = "0.0.203"
+version = "0.0.204"
description = "Building applications with LLMs through composability"
authors = []
license = "MIT"