From d383c0cb435273de83595160c14a2cb45dcecf2a Mon Sep 17 00:00:00 2001 From: StephaneBereux <47181830+StephaneBereux@users.noreply.github.com> Date: Wed, 10 May 2023 01:43:00 +0200 Subject: [PATCH] fixed the filtering error in chromadb (#1621) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed two small bugs (as reported in issue #1619 ) in the filtering by metadata for `chroma` databases : - ```langchain.vectorstores.chroma.similarity_search``` takes a ```filter``` input parameter but do not forward it to ```langchain.vectorstores.chroma.similarity_search_with_score``` - ```langchain.vectorstores.chroma.similarity_search_by_vector``` doesn't take this parameter in input, although it could be very useful, without any additional complexity - and it would thus be coherent with the syntax of the two other functions. Co-authored-by: Davis Chase <130488702+dev2049@users.noreply.github.com> --- langchain/vectorstores/chroma.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/langchain/vectorstores/chroma.py b/langchain/vectorstores/chroma.py index 9f90f4e7..b4387fb1 100644 --- a/langchain/vectorstores/chroma.py +++ b/langchain/vectorstores/chroma.py @@ -190,8 +190,9 @@ class Chroma(VectorStore): ) -> List[Document]: """Return docs most similar to embedding vector. Args: - embedding: Embedding to look up documents similar to. - k: Number of Documents to return. Defaults to 4. + embedding (str): Embedding to look up documents similar to. + k (int): Number of Documents to return. Defaults to 4. + filter (Optional[Dict[str, str]]): Filter by metadata. Defaults to None. Returns: List of Documents most similar to the query vector. """