diff --git a/libs/langchain/langchain/retrievers/self_query/base.py b/libs/langchain/langchain/retrievers/self_query/base.py index 7a13362d55348..cae199a75d7a9 100644 --- a/libs/langchain/langchain/retrievers/self_query/base.py +++ b/libs/langchain/langchain/retrievers/self_query/base.py @@ -170,6 +170,7 @@ def _get_builtin_translator(vectorstore: VectorStore) -> Visitor: return Neo4jTranslator() try: + # Trying langchain_chroma import if exists from langchain_chroma import Chroma except ImportError: pass @@ -204,6 +205,16 @@ def _get_builtin_translator(vectorstore: VectorStore) -> Visitor: if isinstance(vectorstore, HanaDB): return HanaTranslator() + try: + # Trying langchain_weaviate (weaviate v4) import if exists + from langchain_weaviate.vectorstores import WeaviateVectorStore + + except ImportError: + pass + else: + if isinstance(vectorstore, WeaviateVectorStore): + return WeaviateTranslator() + raise ValueError( f"Self query retriever with Vector Store type {vectorstore.__class__}" f" not supported."