Skip to content
Prev Previous commit
Next Next commit
x
  • Loading branch information
eyurtsev committed Jul 12, 2024
commit a4efa8977d608b5e1669d287c5c619851e16f9fa
8 changes: 6 additions & 2 deletions langchain_postgres/vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,11 @@ async def aadd_texts(
await self.__apost_init__() # Lazy async init
embeddings = await self.embedding_function.aembed_documents(list(texts))
return await self.aadd_embeddings(
texts=texts, embeddings=embeddings, metadatas=metadatas, ids=ids, **kwargs
texts=list(texts),
embeddings=embeddings,
metadatas=metadatas,
ids=ids,
**kwargs,
)

def similarity_search(
Expand Down Expand Up @@ -2253,7 +2257,7 @@ async def aget_by_ids(self, ids: Sequence[str], /) -> List[Document]:
.filter(*filter_by)
)

results: List[Any] = (await session.execute(stmt)).scalars().all()
results: Sequence[Any] = (await session.execute(stmt)).scalars().all()

for result in results:
documents.append(
Expand Down
22 changes: 11 additions & 11 deletions tests/unit_tests/test_vectorstore_standard_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
ReadWriteTestSuite,
)

from tests.unit_tests.test_vectorstore import aget_vectorstore, get_vectorstore
from tests.unit_tests.test_vectorstore import get_vectorstore, aget_vectorstore


class TestSync(ReadWriteTestSuite):
@pytest.fixture()
def vectorstore(self) -> VectorStore:
"""Get an empty vectorstore for unit tests."""
with get_vectorstore(embedding=self.get_embeddings()) as vectorstore:
vectorstore.drop_tables()
vectorstore.create_tables_if_not_exists()
vectorstore.create_collection()
yield vectorstore
with get_vectorstore(embedding=self.get_embeddings()) as vstore:
vstore.drop_tables()
vstore.create_tables_if_not_exists()
vstore.create_collection()
yield vstore


class TestAsync(AsyncReadWriteTestSuite):
@pytest.fixture()
async def vectorstore(self) -> VectorStore:
"""Get an empty vectorstore for unit tests."""
async with aget_vectorstore(embedding=self.get_embeddings()) as vectorstore:
await vectorstore.adrop_tables()
await vectorstore.acreate_tables_if_not_exists()
await vectorstore.acreate_collection()
yield vectorstore
async with aget_vectorstore(embedding=self.get_embeddings()) as vstore:
await vstore.adrop_tables()
await vstore.acreate_tables_if_not_exists()
await vstore.acreate_collection()
yield vstore