mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-14 17:07:25 +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."""
|
"""Retriever that generates and executes structured queries over its own data source."""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Dict, List, Optional, Sequence, Tuple, Type, Union
|
from typing import Any, Dict, List, Optional, Sequence, Tuple, Type, Union
|
||||||
|
|
||||||
@ -8,7 +9,6 @@ from langchain_community.vectorstores import (
|
|||||||
DashVector,
|
DashVector,
|
||||||
DeepLake,
|
DeepLake,
|
||||||
Dingo,
|
Dingo,
|
||||||
ElasticsearchStore,
|
|
||||||
Milvus,
|
Milvus,
|
||||||
MongoDBAtlasVectorSearch,
|
MongoDBAtlasVectorSearch,
|
||||||
MyScale,
|
MyScale,
|
||||||
@ -22,6 +22,9 @@ from langchain_community.vectorstores import (
|
|||||||
Vectara,
|
Vectara,
|
||||||
Weaviate,
|
Weaviate,
|
||||||
)
|
)
|
||||||
|
from langchain_community.vectorstores import (
|
||||||
|
ElasticsearchStore as ElasticsearchStoreCommunity,
|
||||||
|
)
|
||||||
from langchain_core.documents import Document
|
from langchain_core.documents import Document
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
from langchain_core.pydantic_v1 import Field, root_validator
|
from langchain_core.pydantic_v1 import Field, root_validator
|
||||||
@ -73,7 +76,7 @@ def _get_builtin_translator(vectorstore: VectorStore) -> Visitor:
|
|||||||
Qdrant: QdrantTranslator,
|
Qdrant: QdrantTranslator,
|
||||||
MyScale: MyScaleTranslator,
|
MyScale: MyScaleTranslator,
|
||||||
DeepLake: DeepLakeTranslator,
|
DeepLake: DeepLakeTranslator,
|
||||||
ElasticsearchStore: ElasticsearchTranslator,
|
ElasticsearchStoreCommunity: ElasticsearchTranslator,
|
||||||
Milvus: MilvusTranslator,
|
Milvus: MilvusTranslator,
|
||||||
SupabaseVectorStore: SupabaseVectorTranslator,
|
SupabaseVectorStore: SupabaseVectorTranslator,
|
||||||
TimescaleVector: TimescaleVectorTranslator,
|
TimescaleVector: TimescaleVectorTranslator,
|
||||||
@ -98,6 +101,14 @@ def _get_builtin_translator(vectorstore: VectorStore) -> Visitor:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
from langchain_elasticsearch.vectorstores import ElasticsearchStore
|
||||||
|
|
||||||
|
if isinstance(vectorstore, ElasticsearchStore):
|
||||||
|
return ElasticsearchTranslator()
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Self query retriever with Vector Store type {vectorstore.__class__}"
|
f"Self query retriever with Vector Store type {vectorstore.__class__}"
|
||||||
f" not supported."
|
f" not supported."
|
||||||
|
Loading…
Reference in New Issue
Block a user