diff --git a/libs/langchain/langchain/retrievers/self_query/base.py b/libs/langchain/langchain/retrievers/self_query/base.py index 47a34815f1..14773ee1e5 100644 --- a/libs/langchain/langchain/retrievers/self_query/base.py +++ b/libs/langchain/langchain/retrievers/self_query/base.py @@ -15,7 +15,6 @@ from langchain_community.vectorstores import ( MyScale, OpenSearchVectorSearch, PGVector, - Pinecone, Qdrant, Redis, SupabaseVectorStore, @@ -27,6 +26,9 @@ from langchain_community.vectorstores import ( from langchain_community.vectorstores import ( ElasticsearchStore as ElasticsearchStoreCommunity, ) +from langchain_community.vectorstores import ( + Pinecone as CommunityPinecone, +) from langchain_core.callbacks.manager import ( AsyncCallbackManagerForRetrieverRun, CallbackManagerForRetrieverRun, @@ -73,7 +75,7 @@ def _get_builtin_translator(vectorstore: VectorStore) -> Visitor: BUILTIN_TRANSLATORS: Dict[Type[VectorStore], Type[Visitor]] = { AstraDB: AstraDBTranslator, PGVector: PGVectorTranslator, - Pinecone: PineconeTranslator, + CommunityPinecone: PineconeTranslator, Chroma: ChromaTranslator, DashVector: DashvectorTranslator, Dingo: DingoDBTranslator, @@ -107,19 +109,27 @@ def _get_builtin_translator(vectorstore: VectorStore) -> Visitor: else: try: from langchain_astradb.vectorstores import AstraDBVectorStore - - if isinstance(vectorstore, AstraDBVectorStore): - return AstraDBTranslator() except ImportError: pass + else: + if isinstance(vectorstore, AstraDBVectorStore): + return AstraDBTranslator() try: from langchain_elasticsearch.vectorstores import ElasticsearchStore - - if isinstance(vectorstore, ElasticsearchStore): - return ElasticsearchTranslator() except ImportError: pass + else: + if isinstance(vectorstore, ElasticsearchStore): + return ElasticsearchTranslator() + + try: + from langchain_pinecone import Pinecone + except ImportError: + pass + else: + if isinstance(vectorstore, Pinecone): + return PineconeTranslator() raise ValueError( f"Self query retriever with Vector Store type {vectorstore.__class__}"