Harrison/chroma fix (#6390)

Co-authored-by: Junu Moon(Fran) <francomoon7@gmail.com>
master
Harrison Chase 12 months ago committed by GitHub
parent 5c1fa3e70e
commit 10bff4ecc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -109,29 +109,18 @@ class Chroma(VectorStore):
) -> List[Document]: ) -> List[Document]:
"""Query the chroma collection.""" """Query the chroma collection."""
try: try:
import chromadb import chromadb # noqa: F401
except ImportError: except ImportError:
raise ValueError( raise ValueError(
"Could not import chromadb python package. " "Could not import chromadb python package. "
"Please install it with `pip install chromadb`." "Please install it with `pip install chromadb`."
) )
return self._collection.query(
for i in range(n_results, 0, -1): query_texts=query_texts,
try: query_embeddings=query_embeddings,
return self._collection.query( n_results=n_results,
query_texts=query_texts, where=where,
query_embeddings=query_embeddings, **kwargs,
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}"
) )
def add_texts( def add_texts(

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "langchain" name = "langchain"
version = "0.0.203" version = "0.0.204"
description = "Building applications with LLMs through composability" description = "Building applications with LLMs through composability"
authors = [] authors = []
license = "MIT" license = "MIT"

Loading…
Cancel
Save