|
|
|
@ -126,3 +126,25 @@ def test_chroma_with_persistence() -> None:
|
|
|
|
|
# Persist doesn't need to be called again
|
|
|
|
|
# Data will be automatically persisted on object deletion
|
|
|
|
|
# Or on program exit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_chroma_mmr() -> None:
|
|
|
|
|
"""Test end to end construction and search."""
|
|
|
|
|
texts = ["foo", "bar", "baz"]
|
|
|
|
|
docsearch = Chroma.from_texts(
|
|
|
|
|
collection_name="test_collection", texts=texts, embedding=FakeEmbeddings()
|
|
|
|
|
)
|
|
|
|
|
output = docsearch.max_marginal_relevance_search("foo", k=1)
|
|
|
|
|
assert output == [Document(page_content="foo")]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_chroma_mmr_by_vector() -> None:
|
|
|
|
|
"""Test end to end construction and search."""
|
|
|
|
|
texts = ["foo", "bar", "baz"]
|
|
|
|
|
embeddings = FakeEmbeddings()
|
|
|
|
|
docsearch = Chroma.from_texts(
|
|
|
|
|
collection_name="test_collection", texts=texts, embedding=embeddings
|
|
|
|
|
)
|
|
|
|
|
embedded_query = embeddings.embed_query("foo")
|
|
|
|
|
output = docsearch.max_marginal_relevance_search_by_vector(embedded_query, k=1)
|
|
|
|
|
assert output == [Document(page_content="foo")]
|
|
|
|
|