Add workaround for not having async vector store methods (#2733)

This allows us to use the async API for the Retrieval chains, though it is not guaranteed to be thread safe.
This commit is contained in:
Ankush Gola
2023-04-11 18:49:08 -07:00
committed by GitHub
parent 0806951c07
commit c1521ddbdb
2 changed files with 33 additions and 3 deletions

View File

@@ -1,4 +1,6 @@
"""Test Chroma functionality."""
import pytest
from langchain.docstore.document import Document
from langchain.vectorstores import Chroma
from tests.integration_tests.vectorstores.fake_embeddings import FakeEmbeddings
@@ -14,6 +16,17 @@ def test_chroma() -> None:
assert output == [Document(page_content="foo")]
@pytest.mark.asyncio
async def test_chroma_async() -> 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 = await docsearch.asimilarity_search("foo", k=1)
assert output == [Document(page_content="foo")]
def test_chroma_with_metadatas() -> None:
"""Test end to end construction and search."""
texts = ["foo", "bar", "baz"]