Skip to content

Commit

Permalink
fix: Chroma DocumentStore creation for pre-existing collection name (#…
Browse files Browse the repository at this point in the history
…157)

* fix: Error on Chroma DocumentStore creation for pre-existing collection name

* linting done
  • Loading branch information
sahusiddharth authored Jan 5, 2024
1 parent 3e314ea commit 10dcef0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion integrations/chroma/src/chroma_haystack/document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(
self._embedding_function_params = embedding_function_params
# Create the client instance
self._chroma_client = chromadb.Client()
self._collection = self._chroma_client.create_collection(
self._collection = self._chroma_client.get_or_create_collection(
name=collection_name,
embedding_function=get_embedding_function(embedding_function, **embedding_function_params),
)
Expand Down
5 changes: 5 additions & 0 deletions integrations/chroma/tests/test_document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ def test_from_json(self):
assert ds._embedding_function == function_name
assert ds._embedding_function_params == {"api_key": "1234567890"}

@pytest.mark.integration
def test_same_collection_name_reinitialization(self):
ChromaDocumentStore("test_name")
ChromaDocumentStore("test_name")

@pytest.mark.skip(reason="Filter on array contents is not supported.")
@pytest.mark.unit
def test_filter_document_array(self, document_store: ChromaDocumentStore, filterable_docs: List[Document]):
Expand Down

0 comments on commit 10dcef0

Please sign in to comment.