langchain[patch]: Migrate retrievers to use optional langchain community imports (#21155)

This commit is contained in:
Eugene Yurtsev 2024-05-01 14:44:44 -04:00 committed by GitHub
parent 43110daea5
commit bec3eee3fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
38 changed files with 1000 additions and 183 deletions

View File

@ -28,7 +28,8 @@ if TYPE_CHECKING:
from langchain_community.retrievers.arxiv import (
ArxivRetriever,
)
from langchain_community.retrievers.azure_cognitive_search import (
from langchain_community.retrievers.azure_ai_search import (
AzureAISearchRetriever,
AzureCognitiveSearchRetriever,
)
from langchain_community.retrievers.bedrock import (
@ -100,6 +101,9 @@ if TYPE_CHECKING:
from langchain_community.retrievers.qdrant_sparse_vector_retriever import (
QdrantSparseVectorRetriever,
)
from langchain_community.retrievers.rememberizer import (
RememberizerRetriever,
)
from langchain_community.retrievers.remote_retriever import (
RemoteLangChainRetriever,
)
@ -112,6 +116,7 @@ if TYPE_CHECKING:
from langchain_community.retrievers.tfidf import (
TFIDFRetriever,
)
from langchain_community.retrievers.thirdai_neuraldb import NeuralDBRetriever
from langchain_community.retrievers.vespa_retriever import (
VespaRetriever,
)
@ -131,46 +136,6 @@ if TYPE_CHECKING:
ZillizRetriever,
)
__all__ = [
"AmazonKendraRetriever",
"AmazonKnowledgeBasesRetriever",
"ArceeRetriever",
"ArxivRetriever",
"AzureCognitiveSearchRetriever",
"BM25Retriever",
"BreebsRetriever",
"ChaindeskRetriever",
"ChatGPTPluginRetriever",
"CohereRagRetriever",
"DocArrayRetriever",
"DriaRetriever",
"ElasticSearchBM25Retriever",
"EmbedchainRetriever",
"GoogleCloudEnterpriseSearchRetriever",
"GoogleDocumentAIWarehouseRetriever",
"GoogleVertexAIMultiTurnSearchRetriever",
"GoogleVertexAISearchRetriever",
"KNNRetriever",
"KayAiRetriever",
"LlamaIndexGraphRetriever",
"LlamaIndexRetriever",
"MetalRetriever",
"MilvusRetriever",
"OutlineRetriever",
"PineconeHybridSearchRetriever",
"PubMedRetriever",
"QdrantSparseVectorRetriever",
"RemoteLangChainRetriever",
"SVMRetriever",
"TFIDFRetriever",
"TavilySearchAPIRetriever",
"VespaRetriever",
"WeaviateHybridSearchRetriever",
"WikipediaRetriever",
"YouRetriever",
"ZepRetriever",
"ZillizRetriever",
]
_module_lookup = {
"AmazonKendraRetriever": "langchain_community.retrievers.kendra",
@ -224,4 +189,46 @@ def __getattr__(name: str) -> Any:
raise AttributeError(f"module {__name__} has no attribute {name}")
__all__ = list(_module_lookup.keys())
__all__ = [
"AmazonKendraRetriever",
"AmazonKnowledgeBasesRetriever",
"ArceeRetriever",
"ArxivRetriever",
"AzureCognitiveSearchRetriever",
"AzureAISearchRetriever",
"BM25Retriever",
"BreebsRetriever",
"ChaindeskRetriever",
"ChatGPTPluginRetriever",
"CohereRagRetriever",
"DocArrayRetriever",
"DriaRetriever",
"ElasticSearchBM25Retriever",
"EmbedchainRetriever",
"GoogleCloudEnterpriseSearchRetriever",
"GoogleDocumentAIWarehouseRetriever",
"GoogleVertexAIMultiTurnSearchRetriever",
"GoogleVertexAISearchRetriever",
"KNNRetriever",
"KayAiRetriever",
"LlamaIndexGraphRetriever",
"LlamaIndexRetriever",
"MetalRetriever",
"MilvusRetriever",
"NeuralDBRetriever",
"OutlineRetriever",
"PineconeHybridSearchRetriever",
"PubMedRetriever",
"QdrantSparseVectorRetriever",
"RememberizerRetriever",
"RemoteLangChainRetriever",
"SVMRetriever",
"TFIDFRetriever",
"TavilySearchAPIRetriever",
"VespaRetriever",
"WeaviateHybridSearchRetriever",
"WikipediaRetriever",
"YouRetriever",
"ZepRetriever",
"ZillizRetriever",
]

View File

@ -32,6 +32,8 @@ EXPECTED_ALL = [
"RememberizerRetriever",
"SVMRetriever",
"TavilySearchAPIRetriever",
"NeuralDBRetriever",
"RememberizerRetriever",
"TFIDFRetriever",
"BM25Retriever",
"VespaRetriever",

View File

@ -17,7 +17,7 @@ the backbone of a retriever, but there are other types of retrievers as well.
Document, Serializable, Callbacks,
CallbackManagerForRetrieverRun, AsyncCallbackManagerForRetrieverRun
"""
from typing import Any
from typing import TYPE_CHECKING, Any
from langchain._api.module_import import create_importer
from langchain.retrievers.contextual_compression import ContextualCompressionRetriever
@ -34,14 +34,96 @@ from langchain.retrievers.time_weighted_retriever import (
)
from langchain.retrievers.web_research import WebResearchRetriever
import_lookup = create_importer(
__package__, fallback_module="langchain_community.retrievers"
if TYPE_CHECKING:
from langchain_community.retrievers import (
AmazonKendraRetriever,
AmazonKnowledgeBasesRetriever,
ArceeRetriever,
ArxivRetriever,
AzureAISearchRetriever,
AzureCognitiveSearchRetriever,
BM25Retriever,
ChaindeskRetriever,
ChatGPTPluginRetriever,
CohereRagRetriever,
DocArrayRetriever,
DriaRetriever,
ElasticSearchBM25Retriever,
EmbedchainRetriever,
GoogleCloudEnterpriseSearchRetriever,
GoogleDocumentAIWarehouseRetriever,
GoogleVertexAIMultiTurnSearchRetriever,
GoogleVertexAISearchRetriever,
KayAiRetriever,
KNNRetriever,
LlamaIndexGraphRetriever,
LlamaIndexRetriever,
MetalRetriever,
MilvusRetriever,
NeuralDBRetriever,
OutlineRetriever,
PineconeHybridSearchRetriever,
PubMedRetriever,
RemoteLangChainRetriever,
SVMRetriever,
TavilySearchAPIRetriever,
TFIDFRetriever,
VespaRetriever,
WeaviateHybridSearchRetriever,
WikipediaRetriever,
ZepRetriever,
ZillizRetriever,
)
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {
"AmazonKendraRetriever": "langchain_community.retrievers",
"AmazonKnowledgeBasesRetriever": "langchain_community.retrievers",
"ArceeRetriever": "langchain_community.retrievers",
"ArxivRetriever": "langchain_community.retrievers",
"AzureAISearchRetriever": "langchain_community.retrievers",
"AzureCognitiveSearchRetriever": "langchain_community.retrievers",
"ChatGPTPluginRetriever": "langchain_community.retrievers",
"ChaindeskRetriever": "langchain_community.retrievers",
"CohereRagRetriever": "langchain_community.retrievers",
"ElasticSearchBM25Retriever": "langchain_community.retrievers",
"EmbedchainRetriever": "langchain_community.retrievers",
"GoogleDocumentAIWarehouseRetriever": "langchain_community.retrievers",
"GoogleCloudEnterpriseSearchRetriever": "langchain_community.retrievers",
"GoogleVertexAIMultiTurnSearchRetriever": "langchain_community.retrievers",
"GoogleVertexAISearchRetriever": "langchain_community.retrievers",
"KayAiRetriever": "langchain_community.retrievers",
"KNNRetriever": "langchain_community.retrievers",
"LlamaIndexGraphRetriever": "langchain_community.retrievers",
"LlamaIndexRetriever": "langchain_community.retrievers",
"MetalRetriever": "langchain_community.retrievers",
"MilvusRetriever": "langchain_community.retrievers",
"OutlineRetriever": "langchain_community.retrievers",
"PineconeHybridSearchRetriever": "langchain_community.retrievers",
"PubMedRetriever": "langchain_community.retrievers",
"RemoteLangChainRetriever": "langchain_community.retrievers",
"SVMRetriever": "langchain_community.retrievers",
"TavilySearchAPIRetriever": "langchain_community.retrievers",
"TFIDFRetriever": "langchain_community.retrievers",
"BM25Retriever": "langchain_community.retrievers",
"VespaRetriever": "langchain_community.retrievers",
"NeuralDBRetriever": "langchain_community.retrievers",
"DriaRetriever": "langchain_community.retrievers",
"WeaviateHybridSearchRetriever": "langchain_community.retrievers",
"WikipediaRetriever": "langchain_community.retrievers",
"ZepRetriever": "langchain_community.retrievers",
"ZillizRetriever": "langchain_community.retrievers",
"DocArrayRetriever": "langchain_community.retrievers",
}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Import retrievers from langchain_community."""
return import_lookup(name)
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
@ -51,14 +133,18 @@ __all__ = [
"ArxivRetriever",
"AzureAISearchRetriever",
"AzureCognitiveSearchRetriever",
"ChatGPTPluginRetriever",
"ContextualCompressionRetriever",
"BM25Retriever",
"ChaindeskRetriever",
"ChatGPTPluginRetriever",
"CohereRagRetriever",
"ContextualCompressionRetriever",
"DocArrayRetriever",
"DriaRetriever",
"ElasticSearchBM25Retriever",
"EmbedchainRetriever",
"GoogleDocumentAIWarehouseRetriever",
"EnsembleRetriever",
"GoogleCloudEnterpriseSearchRetriever",
"GoogleDocumentAIWarehouseRetriever",
"GoogleVertexAIMultiTurnSearchRetriever",
"GoogleVertexAISearchRetriever",
"KayAiRetriever",
@ -69,25 +155,23 @@ __all__ = [
"MetalRetriever",
"MilvusRetriever",
"MultiQueryRetriever",
"MultiVectorRetriever",
"OutlineRetriever",
"ParentDocumentRetriever",
"PineconeHybridSearchRetriever",
"PubMedRetriever",
"RemoteLangChainRetriever",
"SVMRetriever",
"RePhraseQueryRetriever",
"SelfQueryRetriever",
"SVMRetriever",
"TavilySearchAPIRetriever",
"TFIDFRetriever",
"BM25Retriever",
"TimeWeightedVectorStoreRetriever",
"VespaRetriever",
"WeaviateHybridSearchRetriever",
"WebResearchRetriever",
"WikipediaRetriever",
"ZepRetriever",
"NeuralDBRetriever",
"ZillizRetriever",
"DocArrayRetriever",
"RePhraseQueryRetriever",
"WebResearchRetriever",
"EnsembleRetriever",
"ParentDocumentRetriever",
"MultiVectorRetriever",
]

View File

@ -1,3 +1,23 @@
from langchain_community.retrievers.arcee import ArceeRetriever
from typing import TYPE_CHECKING, Any
__all__ = ["ArceeRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import ArceeRetriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"ArceeRetriever": "langchain_community.retrievers"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"ArceeRetriever",
]

View File

@ -1,3 +1,23 @@
from langchain_community.retrievers.arxiv import ArxivRetriever
from typing import TYPE_CHECKING, Any
__all__ = ["ArxivRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import ArxivRetriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"ArxivRetriever": "langchain_community.retrievers"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"ArxivRetriever",
]

View File

@ -1,6 +1,30 @@
from langchain_community.retrievers.azure_ai_search import (
from typing import TYPE_CHECKING, Any
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import (
AzureAISearchRetriever,
AzureCognitiveSearchRetriever,
)
__all__ = ["AzureAISearchRetriever", "AzureCognitiveSearchRetriever"]
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {
"AzureAISearchRetriever": "langchain_community.retrievers",
"AzureCognitiveSearchRetriever": "langchain_community.retrievers",
}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"AzureAISearchRetriever",
"AzureCognitiveSearchRetriever",
]

View File

@ -1,7 +1,33 @@
from typing import TYPE_CHECKING, Any
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import AmazonKnowledgeBasesRetriever
from langchain_community.retrievers.bedrock import (
AmazonKnowledgeBasesRetriever,
RetrievalConfig,
VectorSearchConfig,
)
__all__ = ["VectorSearchConfig", "RetrievalConfig", "AmazonKnowledgeBasesRetriever"]
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {
"VectorSearchConfig": "langchain_community.retrievers.bedrock",
"RetrievalConfig": "langchain_community.retrievers.bedrock",
"AmazonKnowledgeBasesRetriever": "langchain_community.retrievers",
}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"VectorSearchConfig",
"RetrievalConfig",
"AmazonKnowledgeBasesRetriever",
]

View File

@ -1,6 +1,28 @@
from langchain_community.retrievers.bm25 import (
BM25Retriever,
default_preprocessing_func,
)
from typing import TYPE_CHECKING, Any
__all__ = ["default_preprocessing_func", "BM25Retriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import BM25Retriever
from langchain_community.retrievers.bm25 import default_preprocessing_func
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {
"default_preprocessing_func": "langchain_community.retrievers.bm25",
"BM25Retriever": "langchain_community.retrievers",
}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"default_preprocessing_func",
"BM25Retriever",
]

View File

@ -1,3 +1,23 @@
from langchain_community.retrievers.chaindesk import ChaindeskRetriever
from typing import TYPE_CHECKING, Any
__all__ = ["ChaindeskRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import ChaindeskRetriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"ChaindeskRetriever": "langchain_community.retrievers"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"ChaindeskRetriever",
]

View File

@ -1,5 +1,23 @@
from langchain_community.retrievers.chatgpt_plugin_retriever import (
ChatGPTPluginRetriever,
)
from typing import TYPE_CHECKING, Any
__all__ = ["ChatGPTPluginRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import ChatGPTPluginRetriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"ChatGPTPluginRetriever": "langchain_community.retrievers"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"ChatGPTPluginRetriever",
]

View File

@ -1,5 +1,23 @@
from langchain_community.retrievers.cohere_rag_retriever import (
CohereRagRetriever,
)
from typing import TYPE_CHECKING, Any
__all__ = ["CohereRagRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import CohereRagRetriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"CohereRagRetriever": "langchain_community.retrievers"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"CohereRagRetriever",
]

View File

@ -1,3 +1,23 @@
from typing import TYPE_CHECKING, Any
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers.databerry import DataberryRetriever
__all__ = ["DataberryRetriever"]
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"DataberryRetriever": "langchain_community.retrievers.databerry"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"DataberryRetriever",
]

View File

@ -1,3 +1,28 @@
from langchain_community.retrievers.docarray import DocArrayRetriever, SearchType
from typing import TYPE_CHECKING, Any
__all__ = ["SearchType", "DocArrayRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import DocArrayRetriever
from langchain_community.retrievers.docarray import SearchType
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {
"SearchType": "langchain_community.retrievers.docarray",
"DocArrayRetriever": "langchain_community.retrievers",
}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"SearchType",
"DocArrayRetriever",
]

View File

@ -1,5 +1,23 @@
from langchain_community.retrievers.elastic_search_bm25 import (
ElasticSearchBM25Retriever,
)
from typing import TYPE_CHECKING, Any
__all__ = ["ElasticSearchBM25Retriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import ElasticSearchBM25Retriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"ElasticSearchBM25Retriever": "langchain_community.retrievers"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"ElasticSearchBM25Retriever",
]

View File

@ -1,3 +1,23 @@
from langchain_community.retrievers.embedchain import EmbedchainRetriever
from typing import TYPE_CHECKING, Any
__all__ = ["EmbedchainRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import EmbedchainRetriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"EmbedchainRetriever": "langchain_community.retrievers"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"EmbedchainRetriever",
]

View File

@ -1,5 +1,25 @@
from langchain_community.retrievers.google_cloud_documentai_warehouse import (
GoogleDocumentAIWarehouseRetriever,
)
from typing import TYPE_CHECKING, Any
__all__ = ["GoogleDocumentAIWarehouseRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import GoogleDocumentAIWarehouseRetriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {
"GoogleDocumentAIWarehouseRetriever": "langchain_community.retrievers"
}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"GoogleDocumentAIWarehouseRetriever",
]

View File

@ -1,9 +1,31 @@
from langchain_community.retrievers.google_vertex_ai_search import (
from typing import TYPE_CHECKING, Any
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import (
GoogleCloudEnterpriseSearchRetriever,
GoogleVertexAIMultiTurnSearchRetriever,
GoogleVertexAISearchRetriever,
)
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {
"GoogleVertexAISearchRetriever": "langchain_community.retrievers",
"GoogleVertexAIMultiTurnSearchRetriever": "langchain_community.retrievers",
"GoogleCloudEnterpriseSearchRetriever": "langchain_community.retrievers",
}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"GoogleVertexAISearchRetriever",
"GoogleVertexAIMultiTurnSearchRetriever",

View File

@ -1,3 +1,23 @@
from langchain_community.retrievers.kay import KayAiRetriever
from typing import TYPE_CHECKING, Any
__all__ = ["KayAiRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import KayAiRetriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"KayAiRetriever": "langchain_community.retrievers"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"KayAiRetriever",
]

View File

@ -1,10 +1,14 @@
from typing import TYPE_CHECKING, Any
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import AmazonKendraRetriever
from langchain_community.retrievers.kendra import (
AdditionalResultAttribute,
AdditionalResultAttributeValue,
AmazonKendraRetriever,
DocumentAttribute,
DocumentAttributeValue,
DocumentAttributeValueType,
Highlight,
QueryResult,
QueryResultItem,
@ -16,10 +20,37 @@ from langchain_community.retrievers.kendra import (
combined_text,
)
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {
"clean_excerpt": "langchain_community.retrievers.kendra",
"combined_text": "langchain_community.retrievers.kendra",
"Highlight": "langchain_community.retrievers.kendra",
"TextWithHighLights": "langchain_community.retrievers.kendra",
"AdditionalResultAttributeValue": "langchain_community.retrievers.kendra",
"AdditionalResultAttribute": "langchain_community.retrievers.kendra",
"DocumentAttributeValue": "langchain_community.retrievers.kendra",
"DocumentAttribute": "langchain_community.retrievers.kendra",
"ResultItem": "langchain_community.retrievers.kendra",
"QueryResultItem": "langchain_community.retrievers.kendra",
"RetrieveResultItem": "langchain_community.retrievers.kendra",
"QueryResult": "langchain_community.retrievers.kendra",
"RetrieveResult": "langchain_community.retrievers.kendra",
"AmazonKendraRetriever": "langchain_community.retrievers",
}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"clean_excerpt",
"combined_text",
"DocumentAttributeValueType",
"Highlight",
"TextWithHighLights",
"AdditionalResultAttributeValue",

View File

@ -1,3 +1,23 @@
from langchain_community.retrievers.knn import KNNRetriever
from typing import TYPE_CHECKING, Any
__all__ = ["KNNRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import KNNRetriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"KNNRetriever": "langchain_community.retrievers"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"KNNRetriever",
]

View File

@ -1,6 +1,30 @@
from langchain_community.retrievers.llama_index import (
from typing import TYPE_CHECKING, Any
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import (
LlamaIndexGraphRetriever,
LlamaIndexRetriever,
)
__all__ = ["LlamaIndexRetriever", "LlamaIndexGraphRetriever"]
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {
"LlamaIndexRetriever": "langchain_community.retrievers",
"LlamaIndexGraphRetriever": "langchain_community.retrievers",
}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"LlamaIndexRetriever",
"LlamaIndexGraphRetriever",
]

View File

@ -1,3 +1,23 @@
from langchain_community.retrievers.metal import MetalRetriever
from typing import TYPE_CHECKING, Any
__all__ = ["MetalRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import MetalRetriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"MetalRetriever": "langchain_community.retrievers"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"MetalRetriever",
]

View File

@ -1,3 +1,28 @@
from langchain_community.retrievers.milvus import MilvusRetreiver, MilvusRetriever
from typing import TYPE_CHECKING, Any
__all__ = ["MilvusRetriever", "MilvusRetreiver"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import MilvusRetriever
from langchain_community.retrievers.milvus import MilvusRetreiver
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {
"MilvusRetriever": "langchain_community.retrievers",
"MilvusRetreiver": "langchain_community.retrievers.milvus",
}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"MilvusRetriever",
"MilvusRetreiver",
]

View File

@ -1,3 +1,23 @@
from langchain_community.retrievers.outline import OutlineRetriever
from typing import TYPE_CHECKING, Any
__all__ = ["OutlineRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import OutlineRetriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"OutlineRetriever": "langchain_community.retrievers"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"OutlineRetriever",
]

View File

@ -1,5 +1,23 @@
from langchain_community.retrievers.pinecone_hybrid_search import (
PineconeHybridSearchRetriever,
)
from typing import TYPE_CHECKING, Any
__all__ = ["PineconeHybridSearchRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import PineconeHybridSearchRetriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"PineconeHybridSearchRetriever": "langchain_community.retrievers"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"PineconeHybridSearchRetriever",
]

View File

@ -1,3 +1,23 @@
from langchain_community.retrievers.pubmed import PubMedRetriever
from typing import TYPE_CHECKING, Any
__all__ = ["PubMedRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import PubMedRetriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"PubMedRetriever": "langchain_community.retrievers"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"PubMedRetriever",
]

View File

@ -1,5 +1,24 @@
from typing import TYPE_CHECKING, Any
from langchain._api import create_importer
from langchain.retrievers.pubmed import PubMedRetriever
if TYPE_CHECKING:
from langchain_community.retrievers import PubMedRetriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"PubMedRetriever": "langchain_community.retrievers"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"PubMedRetriever",
]

View File

@ -1,3 +1,23 @@
from langchain_community.retrievers.remote_retriever import RemoteLangChainRetriever
from typing import TYPE_CHECKING, Any
__all__ = ["RemoteLangChainRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import RemoteLangChainRetriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"RemoteLangChainRetriever": "langchain_community.retrievers"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"RemoteLangChainRetriever",
]

View File

@ -1,3 +1,23 @@
from langchain_community.retrievers.svm import SVMRetriever
from typing import TYPE_CHECKING, Any
__all__ = ["SVMRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import SVMRetriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"SVMRetriever": "langchain_community.retrievers"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"SVMRetriever",
]

View File

@ -1,6 +1,28 @@
from langchain_community.retrievers.tavily_search_api import (
SearchDepth,
TavilySearchAPIRetriever,
)
from typing import TYPE_CHECKING, Any
__all__ = ["SearchDepth", "TavilySearchAPIRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import TavilySearchAPIRetriever
from langchain_community.retrievers.tavily_search_api import SearchDepth
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {
"SearchDepth": "langchain_community.retrievers.tavily_search_api",
"TavilySearchAPIRetriever": "langchain_community.retrievers",
}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"SearchDepth",
"TavilySearchAPIRetriever",
]

View File

@ -1,3 +1,23 @@
from langchain_community.retrievers.tfidf import TFIDFRetriever
from typing import TYPE_CHECKING, Any
__all__ = ["TFIDFRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import TFIDFRetriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"TFIDFRetriever": "langchain_community.retrievers"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"TFIDFRetriever",
]

View File

@ -1,3 +1,23 @@
from langchain_community.retrievers.vespa_retriever import VespaRetriever
from typing import TYPE_CHECKING, Any
__all__ = ["VespaRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import VespaRetriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"VespaRetriever": "langchain_community.retrievers"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"VespaRetriever",
]

View File

@ -1,5 +1,23 @@
from langchain_community.retrievers.weaviate_hybrid_search import (
WeaviateHybridSearchRetriever,
)
from typing import TYPE_CHECKING, Any
__all__ = ["WeaviateHybridSearchRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import WeaviateHybridSearchRetriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"WeaviateHybridSearchRetriever": "langchain_community.retrievers"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"WeaviateHybridSearchRetriever",
]

View File

@ -1,3 +1,23 @@
from langchain_community.retrievers.wikipedia import WikipediaRetriever
from typing import TYPE_CHECKING, Any
__all__ = ["WikipediaRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import WikipediaRetriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"WikipediaRetriever": "langchain_community.retrievers"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"WikipediaRetriever",
]

View File

@ -1,3 +1,23 @@
from langchain_community.retrievers.you import YouRetriever
from typing import TYPE_CHECKING, Any
__all__ = ["YouRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import YouRetriever
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {"YouRetriever": "langchain_community.retrievers"}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"YouRetriever",
]

View File

@ -1,3 +1,30 @@
from langchain_community.retrievers.zep import SearchScope, SearchType, ZepRetriever
from typing import TYPE_CHECKING, Any
__all__ = ["SearchScope", "SearchType", "ZepRetriever"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import ZepRetriever
from langchain_community.retrievers.zep import SearchScope, SearchType
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {
"SearchScope": "langchain_community.retrievers.zep",
"SearchType": "langchain_community.retrievers.zep",
"ZepRetriever": "langchain_community.retrievers",
}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"SearchScope",
"SearchType",
"ZepRetriever",
]

View File

@ -1,3 +1,28 @@
from langchain_community.retrievers.zilliz import ZillizRetreiver, ZillizRetriever
from typing import TYPE_CHECKING, Any
__all__ = ["ZillizRetriever", "ZillizRetreiver"]
from langchain._api import create_importer
if TYPE_CHECKING:
from langchain_community.retrievers import ZillizRetriever
from langchain_community.retrievers.zilliz import ZillizRetreiver
# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
DEPRECATED_LOOKUP = {
"ZillizRetriever": "langchain_community.retrievers",
"ZillizRetreiver": "langchain_community.retrievers.zilliz",
}
_import_attribute = create_importer(__package__, deprecated_lookups=DEPRECATED_LOOKUP)
def __getattr__(name: str) -> Any:
"""Look up attributes dynamically."""
return _import_attribute(name)
__all__ = [
"ZillizRetriever",
"ZillizRetreiver",
]

View File

@ -8,14 +8,18 @@ EXPECTED_ALL = [
"ArxivRetriever",
"AzureAISearchRetriever",
"AzureCognitiveSearchRetriever",
"ChatGPTPluginRetriever",
"ContextualCompressionRetriever",
"BM25Retriever",
"ChaindeskRetriever",
"ChatGPTPluginRetriever",
"CohereRagRetriever",
"ContextualCompressionRetriever",
"DocArrayRetriever",
"DriaRetriever",
"ElasticSearchBM25Retriever",
"EmbedchainRetriever",
"GoogleDocumentAIWarehouseRetriever",
"EnsembleRetriever",
"GoogleCloudEnterpriseSearchRetriever",
"GoogleDocumentAIWarehouseRetriever",
"GoogleVertexAIMultiTurnSearchRetriever",
"GoogleVertexAISearchRetriever",
"KayAiRetriever",
@ -26,27 +30,25 @@ EXPECTED_ALL = [
"MetalRetriever",
"MilvusRetriever",
"MultiQueryRetriever",
"MultiVectorRetriever",
"NeuralDBRetriever",
"OutlineRetriever",
"ParentDocumentRetriever",
"PineconeHybridSearchRetriever",
"PubMedRetriever",
"RemoteLangChainRetriever",
"SVMRetriever",
"RePhraseQueryRetriever",
"SelfQueryRetriever",
"SVMRetriever",
"TavilySearchAPIRetriever",
"TFIDFRetriever",
"BM25Retriever",
"TimeWeightedVectorStoreRetriever",
"VespaRetriever",
"WeaviateHybridSearchRetriever",
"WebResearchRetriever",
"WikipediaRetriever",
"ZepRetriever",
"ZillizRetriever",
"DocArrayRetriever",
"RePhraseQueryRetriever",
"WebResearchRetriever",
"EnsembleRetriever",
"ParentDocumentRetriever",
"MultiVectorRetriever",
]