Skip to content

PGVector AssertionError('_async_engine not found') with a RAG tool #30346

Closed Answered by cj2001
cj2001 asked this question in Q&A
Discussion options

You must be logged in to vote

I am going to close this discussion because I found the answer elsewhere. However, for the sake of documenting the solution, the answer came from this issue.

The bottom line is that the retriever needs an async engine. Just passing the connection string is not sufficient. So the change in the retriever tool looks like this:

from langchain.tools.retriever import create_retriever_tool
from langchain_postgres.vectorstores import PGVector
from langchain_openai import OpenAIEmbeddings

from sqlalchemy.ext.asyncio import create_async_engine

embeddings = OpenAIEmbeddings()

COLLECTION_NAME = "..."
PGDATABASE = '...'
CONNECTION_STRING = f"postgresql+psycopg://{settings.PGUSER}:{settings.PGPASSWORD}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by cj2001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant