mirror of
https://github.com/hwchase17/langchain
synced 2024-11-18 09:25:54 +00:00
langchain[patch]: fix ElasticsearchStore reference for self query (#19907)
Initializing self query with an ElasticsearchStore from the partners packages failed previously, see https://github.com/langchain-ai/langchain/discussions/18976.
This commit is contained in:
parent
3218463f6a
commit
22dbcc9441
@ -1,4 +1,5 @@
|
||||
"""Retriever that generates and executes structured queries over its own data source."""
|
||||
|
||||
import logging
|
||||
from typing import Any, Dict, List, Optional, Sequence, Tuple, Type, Union
|
||||
|
||||
@ -8,7 +9,6 @@ from langchain_community.vectorstores import (
|
||||
DashVector,
|
||||
DeepLake,
|
||||
Dingo,
|
||||
ElasticsearchStore,
|
||||
Milvus,
|
||||
MongoDBAtlasVectorSearch,
|
||||
MyScale,
|
||||
@ -22,6 +22,9 @@ from langchain_community.vectorstores import (
|
||||
Vectara,
|
||||
Weaviate,
|
||||
)
|
||||
from langchain_community.vectorstores import (
|
||||
ElasticsearchStore as ElasticsearchStoreCommunity,
|
||||
)
|
||||
from langchain_core.documents import Document
|
||||
from langchain_core.language_models import BaseLanguageModel
|
||||
from langchain_core.pydantic_v1 import Field, root_validator
|
||||
@ -73,7 +76,7 @@ def _get_builtin_translator(vectorstore: VectorStore) -> Visitor:
|
||||
Qdrant: QdrantTranslator,
|
||||
MyScale: MyScaleTranslator,
|
||||
DeepLake: DeepLakeTranslator,
|
||||
ElasticsearchStore: ElasticsearchTranslator,
|
||||
ElasticsearchStoreCommunity: ElasticsearchTranslator,
|
||||
Milvus: MilvusTranslator,
|
||||
SupabaseVectorStore: SupabaseVectorTranslator,
|
||||
TimescaleVector: TimescaleVectorTranslator,
|
||||
@ -98,6 +101,14 @@ def _get_builtin_translator(vectorstore: VectorStore) -> Visitor:
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
try:
|
||||
from langchain_elasticsearch.vectorstores import ElasticsearchStore
|
||||
|
||||
if isinstance(vectorstore, ElasticsearchStore):
|
||||
return ElasticsearchTranslator()
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
raise ValueError(
|
||||
f"Self query retriever with Vector Store type {vectorstore.__class__}"
|
||||
f" not supported."
|
||||
|
Loading…
Reference in New Issue
Block a user