fix chroma updated upsert interface (#7643)

new chroma release seems to not support empty dicts for metadata.

related to #7633
This commit is contained in:
Bagatur
2023-07-13 09:27:14 -04:00
committed by GitHub
parent a673a51efa
commit c17a80f11c
2 changed files with 48 additions and 3 deletions

View File

@@ -281,3 +281,21 @@ def test_init_from_client_settings() -> None:
client_settings = chromadb.config.Settings()
Chroma(client_settings=client_settings)
def test_chroma_add_documents_no_metadata() -> None:
db = Chroma(embedding_function=FakeEmbeddings())
db.add_documents([Document(page_content="foo")])
def test_chroma_add_documents_mixed_metadata() -> None:
db = Chroma(embedding_function=FakeEmbeddings())
docs = [
Document(page_content="foo"),
Document(page_content="bar", metadata={"baz": 1}),
]
db.add_documents(docs)
search = db.similarity_search("foo bar")
assert sorted(search, key=lambda d: d.page_content) == sorted(
docs, key=lambda d: d.page_content
)