Skip to content

Commit

Permalink
core[minor]: Update pgvector transalor for langchain_postgres (#23217)
Browse files Browse the repository at this point in the history
The SelfQuery PGVectorTranslator is not correct. The operator is "eq"
and not "$eq".
This patch use a new version of PGVectorTranslator from
langchain_postgres.

It's necessary to release a new version of langchain_postgres (see
[here](langchain-ai/langchain-postgres#75)
before accepting this PR in langchain.
  • Loading branch information
pprados committed Jun 21, 2024
1 parent 401d469 commit 1c2b9cc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libs/langchain/langchain/retrievers/self_query/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,12 @@ def _get_builtin_translator(vectorstore: VectorStore) -> Visitor:

try:
from langchain_postgres import PGVector
from langchain_postgres import PGVectorTranslator as NewPGVectorTranslator
except ImportError:
pass
else:
if isinstance(vectorstore, PGVector):
return PGVectorTranslator()
return NewPGVectorTranslator()

raise ValueError(
f"Self query retriever with Vector Store type {vectorstore.__class__}"
Expand Down

0 comments on commit 1c2b9cc

Please sign in to comment.