core[minor]: Update pgvector transalor for langchain_postgres (#23217)

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](https://github.com/langchain-ai/langchain-postgres/pull/75)
before accepting this PR in langchain.
This commit is contained in:
Philippe PRADOS
2024-06-21 16:37:09 +02:00
committed by GitHub
parent 401d469a92
commit 1c2b9cc9ab

View File

@@ -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__}"