Reputation: 45
I need to search for all documents in a collection using the langchain PGVector lib
Upvotes: 0
Views: 274
Reputation: 11
No, there is no supported method.
In ChromaDB, there is a get method, but it has not been implemented in PGVector yet.
If necessary, it can be implemented as shown below.
from langchain_openai import OpenAIEmbeddings
from langchain_postgres import PGVector
from sqlalchemy.orm import Session
embeddings = OpenAIEmbeddings(
model="...",
openai_api_key="..."
)
vectorstore = PGVector(
embeddings=embeddings, collection_name="mobile_plan",
connection="postgresql+psycopg://postgres:mypassword@localhost/mydb", use_jsonb=True)
with Session(vectorstore.session_maker.bind) as session:
docs = session.query(vectorstore.EmbeddingStore.document).all()
print(docs[0])
print(len(docs))
Upvotes: 0