diff --git a/integrations/chroma/src/haystack_integrations/components/retrievers/chroma/retriever.py b/integrations/chroma/src/haystack_integrations/components/retrievers/chroma/retriever.py index b9a771801..9388171f4 100644 --- a/integrations/chroma/src/haystack_integrations/components/retrievers/chroma/retriever.py +++ b/integrations/chroma/src/haystack_integrations/components/retrievers/chroma/retriever.py @@ -40,8 +40,8 @@ def run( :raises ValueError: If the specified document store is not found or is not a MemoryDocumentStore instance. """ - if not top_k: - top_k = 3 + top_k = top_k or self.top_k + return {"documents": self.document_store.search([query], top_k)[0]} def to_dict(self) -> Dict[str, Any]: @@ -77,8 +77,7 @@ def run( :raises ValueError: If the specified document store is not found or is not a MemoryDocumentStore instance. """ - if not top_k: - top_k = 3 + top_k = top_k or self.top_k query_embeddings = [query_embedding] return {"documents": self.document_store.search_embeddings(query_embeddings, top_k)[0]}