From ca87b0edcf607daf80158c13ec182a4f578b6667 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 2 May 2024 09:46:22 -0700 Subject: [PATCH] Feature/bump chromadb dep to 0.5.0 (#700) * [DEP]: Bump chromadb version Remove specific version pin * Fix: chromadb tests failing due to sort order variance Fix: linting error * Add OllamaEmbeddingFunction to function registry Linting --- integrations/chroma/pyproject.toml | 2 +- .../src/haystack_integrations/document_stores/chroma/utils.py | 2 ++ integrations/chroma/tests/test_document_store.py | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/integrations/chroma/pyproject.toml b/integrations/chroma/pyproject.toml index 96ee2f9f8..f4cf6ecc2 100644 --- a/integrations/chroma/pyproject.toml +++ b/integrations/chroma/pyproject.toml @@ -26,7 +26,7 @@ classifiers = [ ] dependencies = [ "haystack-ai", - "chromadb<0.4.20", # FIXME: investigate why filtering tests broke on 0.4.20 + "chromadb", "typing_extensions>=4.8.0" ] diff --git a/integrations/chroma/src/haystack_integrations/document_stores/chroma/utils.py b/integrations/chroma/src/haystack_integrations/document_stores/chroma/utils.py index 08d6db618..5c31070ad 100644 --- a/integrations/chroma/src/haystack_integrations/document_stores/chroma/utils.py +++ b/integrations/chroma/src/haystack_integrations/document_stores/chroma/utils.py @@ -9,6 +9,7 @@ GoogleVertexEmbeddingFunction, HuggingFaceEmbeddingFunction, InstructorEmbeddingFunction, + OllamaEmbeddingFunction, ONNXMiniLM_L6_V2, OpenAIEmbeddingFunction, SentenceTransformerEmbeddingFunction, @@ -25,6 +26,7 @@ "GoogleVertexEmbeddingFunction": GoogleVertexEmbeddingFunction, "HuggingFaceEmbeddingFunction": HuggingFaceEmbeddingFunction, "InstructorEmbeddingFunction": InstructorEmbeddingFunction, + "OllamaEmbeddingFunction": OllamaEmbeddingFunction, "ONNXMiniLM_L6_V2": ONNXMiniLM_L6_V2, "OpenAIEmbeddingFunction": OpenAIEmbeddingFunction, "Text2VecEmbeddingFunction": Text2VecEmbeddingFunction, diff --git a/integrations/chroma/tests/test_document_store.py b/integrations/chroma/tests/test_document_store.py index 5b827a984..cddc66e3f 100644 --- a/integrations/chroma/tests/test_document_store.py +++ b/integrations/chroma/tests/test_document_store.py @@ -1,6 +1,7 @@ # SPDX-FileCopyrightText: 2023-present John Doe # # SPDX-License-Identifier: Apache-2.0 +import operator import uuid from typing import List from unittest import mock @@ -56,6 +57,9 @@ def assert_documents_are_equal(self, received: List[Document], expected: List[Do This can happen for example when the Document Store sets a score to returned Documents. Since we can't know what the score will be, we can't compare the Documents reliably. """ + received.sort(key=operator.attrgetter("id")) + expected.sort(key=operator.attrgetter("id")) + for doc_received, doc_expected in zip(received, expected): assert doc_received.content == doc_expected.content assert doc_received.meta == doc_expected.meta