2023-12-11 21:53:30 +00:00
|
|
|
"""**Retriever** class returns Documents given a text **query**.
|
|
|
|
|
|
|
|
It is more general than a vector store. A retriever does not need to be able to
|
|
|
|
store documents, only to return (or retrieve) it. Vector stores can be used as
|
|
|
|
the backbone of a retriever, but there are other types of retrievers as well.
|
|
|
|
|
|
|
|
**Class hierarchy:**
|
|
|
|
|
|
|
|
.. code-block::
|
|
|
|
|
|
|
|
BaseRetriever --> <name>Retriever # Examples: ArxivRetriever, MergerRetriever
|
|
|
|
|
|
|
|
**Main helpers:**
|
|
|
|
|
|
|
|
.. code-block::
|
|
|
|
|
|
|
|
Document, Serializable, Callbacks,
|
|
|
|
CallbackManagerForRetrieverRun, AsyncCallbackManagerForRetrieverRun
|
|
|
|
"""
|
|
|
|
|
2024-03-12 22:18:54 +00:00
|
|
|
import importlib
|
2024-04-10 17:01:19 +00:00
|
|
|
from typing import TYPE_CHECKING, Any
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
from langchain_community.retrievers.arcee import (
|
2024-04-30 17:13:48 +00:00
|
|
|
ArceeRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.arxiv import (
|
2024-04-30 17:13:48 +00:00
|
|
|
ArxivRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
2024-05-21 01:23:06 +00:00
|
|
|
from langchain_community.retrievers.asknews import (
|
|
|
|
AskNewsRetriever,
|
|
|
|
)
|
2024-05-01 18:44:44 +00:00
|
|
|
from langchain_community.retrievers.azure_ai_search import (
|
|
|
|
AzureAISearchRetriever,
|
2024-04-30 17:13:48 +00:00
|
|
|
AzureCognitiveSearchRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.bedrock import (
|
2024-04-30 17:13:48 +00:00
|
|
|
AmazonKnowledgeBasesRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.bm25 import (
|
2024-04-30 17:13:48 +00:00
|
|
|
BM25Retriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.breebs import (
|
2024-04-30 17:13:48 +00:00
|
|
|
BreebsRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.chaindesk import (
|
2024-04-30 17:13:48 +00:00
|
|
|
ChaindeskRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.chatgpt_plugin_retriever import (
|
2024-04-30 17:13:48 +00:00
|
|
|
ChatGPTPluginRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.cohere_rag_retriever import (
|
2024-04-30 17:13:48 +00:00
|
|
|
CohereRagRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.docarray import (
|
2024-04-30 17:13:48 +00:00
|
|
|
DocArrayRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.dria_index import (
|
2024-04-30 17:13:48 +00:00
|
|
|
DriaRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.elastic_search_bm25 import (
|
2024-04-30 17:13:48 +00:00
|
|
|
ElasticSearchBM25Retriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.embedchain import (
|
2024-04-30 17:13:48 +00:00
|
|
|
EmbedchainRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.google_cloud_documentai_warehouse import (
|
2024-04-30 17:13:48 +00:00
|
|
|
GoogleDocumentAIWarehouseRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.google_vertex_ai_search import (
|
2024-04-30 17:13:48 +00:00
|
|
|
GoogleCloudEnterpriseSearchRetriever,
|
|
|
|
GoogleVertexAIMultiTurnSearchRetriever,
|
|
|
|
GoogleVertexAISearchRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.kay import (
|
2024-04-30 17:13:48 +00:00
|
|
|
KayAiRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.kendra import (
|
2024-04-30 17:13:48 +00:00
|
|
|
AmazonKendraRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.knn import (
|
2024-04-30 17:13:48 +00:00
|
|
|
KNNRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.llama_index import (
|
2024-04-30 17:13:48 +00:00
|
|
|
LlamaIndexGraphRetriever,
|
|
|
|
LlamaIndexRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.metal import (
|
2024-04-30 17:13:48 +00:00
|
|
|
MetalRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.milvus import (
|
2024-04-30 17:13:48 +00:00
|
|
|
MilvusRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.outline import (
|
2024-04-30 17:13:48 +00:00
|
|
|
OutlineRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.pinecone_hybrid_search import (
|
2024-04-30 17:13:48 +00:00
|
|
|
PineconeHybridSearchRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.pubmed import (
|
2024-04-30 17:13:48 +00:00
|
|
|
PubMedRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.qdrant_sparse_vector_retriever import (
|
2024-04-30 17:13:48 +00:00
|
|
|
QdrantSparseVectorRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
2024-05-01 18:44:44 +00:00
|
|
|
from langchain_community.retrievers.rememberizer import (
|
|
|
|
RememberizerRetriever,
|
|
|
|
)
|
2024-04-10 17:01:19 +00:00
|
|
|
from langchain_community.retrievers.remote_retriever import (
|
2024-04-30 17:13:48 +00:00
|
|
|
RemoteLangChainRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.svm import (
|
2024-04-30 17:13:48 +00:00
|
|
|
SVMRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.tavily_search_api import (
|
2024-04-30 17:13:48 +00:00
|
|
|
TavilySearchAPIRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.tfidf import (
|
2024-04-30 17:13:48 +00:00
|
|
|
TFIDFRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
2024-05-01 18:44:44 +00:00
|
|
|
from langchain_community.retrievers.thirdai_neuraldb import NeuralDBRetriever
|
2024-04-10 17:01:19 +00:00
|
|
|
from langchain_community.retrievers.vespa_retriever import (
|
2024-04-30 17:13:48 +00:00
|
|
|
VespaRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.weaviate_hybrid_search import (
|
2024-04-30 17:13:48 +00:00
|
|
|
WeaviateHybridSearchRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
2024-05-08 20:46:52 +00:00
|
|
|
from langchain_community.retrievers.web_research import WebResearchRetriever
|
2024-04-10 17:01:19 +00:00
|
|
|
from langchain_community.retrievers.wikipedia import (
|
2024-04-30 17:13:48 +00:00
|
|
|
WikipediaRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.you import (
|
2024-04-30 17:13:48 +00:00
|
|
|
YouRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.retrievers.zep import (
|
2024-04-30 17:13:48 +00:00
|
|
|
ZepRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
community[minor]: Add Zep Cloud components + docs + examples (#21671)
Thank you for contributing to LangChain!
- [x] **PR title**: community: Add Zep Cloud components + docs +
examples
- [x] **PR message**:
We have recently released our new zep-cloud sdks that are compatible
with Zep Cloud (not Zep Open Source). We have also maintained our Cloud
version of langchain components (ChatMessageHistory, VectorStore) as
part of our sdks. This PRs goal is to port these components to langchain
community repo, and close the gap with the existing Zep Open Source
components already present in community repo (added
ZepCloudMemory,ZepCloudVectorStore,ZepCloudRetriever).
Also added a ZepCloudChatMessageHistory components together with an
expression language example ported from our repo. We have left the
original open source components intact on purpose as to not introduce
any breaking changes.
- **Issue:** -
- **Dependencies:** Added optional dependency of our new cloud sdk
`zep-cloud`
- **Twitter handle:** @paulpaliychuk51
- [x] **Add tests and docs**
- [x] **Lint and test**: Run `make format`, `make lint` and `make test`
from the root of the package(s) you've modified. See contribution
guidelines for more: https://python.langchain.com/docs/contributing/
Additional guidelines:
- Make sure optional dependencies are imported within a function.
- Please do not add dependencies to pyproject.toml files (even optional
ones) unless they are required for unit tests.
- Most PRs should not touch more than one package.
- Changes should be backwards compatible.
- If you are adding something to community, do not re-import it in
langchain.
If no one reviews your PR within a few days, please @-mention one of
baskaryan, efriis, eyurtsev, hwchase17.
2024-05-27 19:50:13 +00:00
|
|
|
from langchain_community.retrievers.zep_cloud import (
|
|
|
|
ZepCloudRetriever,
|
|
|
|
)
|
2024-04-10 17:01:19 +00:00
|
|
|
from langchain_community.retrievers.zilliz import (
|
2024-04-30 17:13:48 +00:00
|
|
|
ZillizRetriever,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
|
2023-12-11 21:53:30 +00:00
|
|
|
|
2024-03-12 22:18:54 +00:00
|
|
|
_module_lookup = {
|
|
|
|
"AmazonKendraRetriever": "langchain_community.retrievers.kendra",
|
|
|
|
"AmazonKnowledgeBasesRetriever": "langchain_community.retrievers.bedrock",
|
|
|
|
"ArceeRetriever": "langchain_community.retrievers.arcee",
|
|
|
|
"ArxivRetriever": "langchain_community.retrievers.arxiv",
|
2024-05-21 01:23:06 +00:00
|
|
|
"AskNewsRetriever": "langchain_community.retrievers.asknews",
|
2024-04-30 17:13:48 +00:00
|
|
|
"AzureAISearchRetriever": "langchain_community.retrievers.azure_ai_search",
|
|
|
|
"AzureCognitiveSearchRetriever": "langchain_community.retrievers.azure_ai_search",
|
2024-03-12 22:18:54 +00:00
|
|
|
"BM25Retriever": "langchain_community.retrievers.bm25",
|
|
|
|
"BreebsRetriever": "langchain_community.retrievers.breebs",
|
|
|
|
"ChaindeskRetriever": "langchain_community.retrievers.chaindesk",
|
|
|
|
"ChatGPTPluginRetriever": "langchain_community.retrievers.chatgpt_plugin_retriever",
|
|
|
|
"CohereRagRetriever": "langchain_community.retrievers.cohere_rag_retriever",
|
|
|
|
"DocArrayRetriever": "langchain_community.retrievers.docarray",
|
2024-04-01 19:04:19 +00:00
|
|
|
"DriaRetriever": "langchain_community.retrievers.dria_index",
|
2024-03-12 22:18:54 +00:00
|
|
|
"ElasticSearchBM25Retriever": "langchain_community.retrievers.elastic_search_bm25",
|
|
|
|
"EmbedchainRetriever": "langchain_community.retrievers.embedchain",
|
|
|
|
"GoogleCloudEnterpriseSearchRetriever": "langchain_community.retrievers.google_vertex_ai_search", # noqa: E501
|
|
|
|
"GoogleDocumentAIWarehouseRetriever": "langchain_community.retrievers.google_cloud_documentai_warehouse", # noqa: E501
|
|
|
|
"GoogleVertexAIMultiTurnSearchRetriever": "langchain_community.retrievers.google_vertex_ai_search", # noqa: E501
|
|
|
|
"GoogleVertexAISearchRetriever": "langchain_community.retrievers.google_vertex_ai_search", # noqa: E501
|
|
|
|
"KNNRetriever": "langchain_community.retrievers.knn",
|
|
|
|
"KayAiRetriever": "langchain_community.retrievers.kay",
|
|
|
|
"LlamaIndexGraphRetriever": "langchain_community.retrievers.llama_index",
|
|
|
|
"LlamaIndexRetriever": "langchain_community.retrievers.llama_index",
|
|
|
|
"MetalRetriever": "langchain_community.retrievers.metal",
|
|
|
|
"MilvusRetriever": "langchain_community.retrievers.milvus",
|
|
|
|
"OutlineRetriever": "langchain_community.retrievers.outline",
|
|
|
|
"PineconeHybridSearchRetriever": "langchain_community.retrievers.pinecone_hybrid_search", # noqa: E501
|
|
|
|
"PubMedRetriever": "langchain_community.retrievers.pubmed",
|
|
|
|
"QdrantSparseVectorRetriever": "langchain_community.retrievers.qdrant_sparse_vector_retriever", # noqa: E501
|
2024-05-01 14:41:44 +00:00
|
|
|
"RememberizerRetriever": "langchain_community.retrievers.rememberizer",
|
2024-03-12 22:18:54 +00:00
|
|
|
"RemoteLangChainRetriever": "langchain_community.retrievers.remote_retriever",
|
|
|
|
"SVMRetriever": "langchain_community.retrievers.svm",
|
|
|
|
"TFIDFRetriever": "langchain_community.retrievers.tfidf",
|
|
|
|
"TavilySearchAPIRetriever": "langchain_community.retrievers.tavily_search_api",
|
|
|
|
"VespaRetriever": "langchain_community.retrievers.vespa_retriever",
|
|
|
|
"WeaviateHybridSearchRetriever": "langchain_community.retrievers.weaviate_hybrid_search", # noqa: E501
|
2024-05-08 20:46:52 +00:00
|
|
|
"WebResearchRetriever": "langchain_community.retrievers.web_research",
|
2024-03-12 22:18:54 +00:00
|
|
|
"WikipediaRetriever": "langchain_community.retrievers.wikipedia",
|
|
|
|
"YouRetriever": "langchain_community.retrievers.you",
|
|
|
|
"ZepRetriever": "langchain_community.retrievers.zep",
|
community[minor]: Add Zep Cloud components + docs + examples (#21671)
Thank you for contributing to LangChain!
- [x] **PR title**: community: Add Zep Cloud components + docs +
examples
- [x] **PR message**:
We have recently released our new zep-cloud sdks that are compatible
with Zep Cloud (not Zep Open Source). We have also maintained our Cloud
version of langchain components (ChatMessageHistory, VectorStore) as
part of our sdks. This PRs goal is to port these components to langchain
community repo, and close the gap with the existing Zep Open Source
components already present in community repo (added
ZepCloudMemory,ZepCloudVectorStore,ZepCloudRetriever).
Also added a ZepCloudChatMessageHistory components together with an
expression language example ported from our repo. We have left the
original open source components intact on purpose as to not introduce
any breaking changes.
- **Issue:** -
- **Dependencies:** Added optional dependency of our new cloud sdk
`zep-cloud`
- **Twitter handle:** @paulpaliychuk51
- [x] **Add tests and docs**
- [x] **Lint and test**: Run `make format`, `make lint` and `make test`
from the root of the package(s) you've modified. See contribution
guidelines for more: https://python.langchain.com/docs/contributing/
Additional guidelines:
- Make sure optional dependencies are imported within a function.
- Please do not add dependencies to pyproject.toml files (even optional
ones) unless they are required for unit tests.
- Most PRs should not touch more than one package.
- Changes should be backwards compatible.
- If you are adding something to community, do not re-import it in
langchain.
If no one reviews your PR within a few days, please @-mention one of
baskaryan, efriis, eyurtsev, hwchase17.
2024-05-27 19:50:13 +00:00
|
|
|
"ZepCloudRetriever": "langchain_community.retrievers.zep_cloud",
|
2024-03-12 22:18:54 +00:00
|
|
|
"ZillizRetriever": "langchain_community.retrievers.zilliz",
|
2024-04-16 23:36:55 +00:00
|
|
|
"NeuralDBRetriever": "langchain_community.retrievers.thirdai_neuraldb",
|
2024-03-12 22:18:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def __getattr__(name: str) -> Any:
|
|
|
|
if name in _module_lookup:
|
|
|
|
module = importlib.import_module(_module_lookup[name])
|
|
|
|
return getattr(module, name)
|
|
|
|
raise AttributeError(f"module {__name__} has no attribute {name}")
|
|
|
|
|
|
|
|
|
2024-05-01 18:44:44 +00:00
|
|
|
__all__ = [
|
|
|
|
"AmazonKendraRetriever",
|
|
|
|
"AmazonKnowledgeBasesRetriever",
|
|
|
|
"ArceeRetriever",
|
|
|
|
"ArxivRetriever",
|
2024-05-21 01:23:06 +00:00
|
|
|
"AskNewsRetriever",
|
2024-05-01 18:44:44 +00:00
|
|
|
"AzureAISearchRetriever",
|
2024-05-08 20:46:52 +00:00
|
|
|
"AzureCognitiveSearchRetriever",
|
2024-05-01 18:44:44 +00:00
|
|
|
"BM25Retriever",
|
|
|
|
"BreebsRetriever",
|
|
|
|
"ChaindeskRetriever",
|
|
|
|
"ChatGPTPluginRetriever",
|
|
|
|
"CohereRagRetriever",
|
|
|
|
"DocArrayRetriever",
|
|
|
|
"DriaRetriever",
|
|
|
|
"ElasticSearchBM25Retriever",
|
|
|
|
"EmbedchainRetriever",
|
|
|
|
"GoogleCloudEnterpriseSearchRetriever",
|
|
|
|
"GoogleDocumentAIWarehouseRetriever",
|
|
|
|
"GoogleVertexAIMultiTurnSearchRetriever",
|
|
|
|
"GoogleVertexAISearchRetriever",
|
|
|
|
"KayAiRetriever",
|
2024-05-08 20:46:52 +00:00
|
|
|
"KNNRetriever",
|
2024-05-01 18:44:44 +00:00
|
|
|
"LlamaIndexGraphRetriever",
|
|
|
|
"LlamaIndexRetriever",
|
|
|
|
"MetalRetriever",
|
|
|
|
"MilvusRetriever",
|
|
|
|
"NeuralDBRetriever",
|
|
|
|
"OutlineRetriever",
|
|
|
|
"PineconeHybridSearchRetriever",
|
|
|
|
"PubMedRetriever",
|
|
|
|
"QdrantSparseVectorRetriever",
|
|
|
|
"RememberizerRetriever",
|
|
|
|
"RemoteLangChainRetriever",
|
|
|
|
"SVMRetriever",
|
|
|
|
"TavilySearchAPIRetriever",
|
2024-05-08 20:46:52 +00:00
|
|
|
"TFIDFRetriever",
|
2024-05-01 18:44:44 +00:00
|
|
|
"VespaRetriever",
|
|
|
|
"WeaviateHybridSearchRetriever",
|
2024-05-08 20:46:52 +00:00
|
|
|
"WebResearchRetriever",
|
2024-05-01 18:44:44 +00:00
|
|
|
"WikipediaRetriever",
|
|
|
|
"YouRetriever",
|
|
|
|
"ZepRetriever",
|
community[minor]: Add Zep Cloud components + docs + examples (#21671)
Thank you for contributing to LangChain!
- [x] **PR title**: community: Add Zep Cloud components + docs +
examples
- [x] **PR message**:
We have recently released our new zep-cloud sdks that are compatible
with Zep Cloud (not Zep Open Source). We have also maintained our Cloud
version of langchain components (ChatMessageHistory, VectorStore) as
part of our sdks. This PRs goal is to port these components to langchain
community repo, and close the gap with the existing Zep Open Source
components already present in community repo (added
ZepCloudMemory,ZepCloudVectorStore,ZepCloudRetriever).
Also added a ZepCloudChatMessageHistory components together with an
expression language example ported from our repo. We have left the
original open source components intact on purpose as to not introduce
any breaking changes.
- **Issue:** -
- **Dependencies:** Added optional dependency of our new cloud sdk
`zep-cloud`
- **Twitter handle:** @paulpaliychuk51
- [x] **Add tests and docs**
- [x] **Lint and test**: Run `make format`, `make lint` and `make test`
from the root of the package(s) you've modified. See contribution
guidelines for more: https://python.langchain.com/docs/contributing/
Additional guidelines:
- Make sure optional dependencies are imported within a function.
- Please do not add dependencies to pyproject.toml files (even optional
ones) unless they are required for unit tests.
- Most PRs should not touch more than one package.
- Changes should be backwards compatible.
- If you are adding something to community, do not re-import it in
langchain.
If no one reviews your PR within a few days, please @-mention one of
baskaryan, efriis, eyurtsev, hwchase17.
2024-05-27 19:50:13 +00:00
|
|
|
"ZepCloudRetriever",
|
2024-05-01 18:44:44 +00:00
|
|
|
"ZillizRetriever",
|
|
|
|
]
|