nat.retriever.nemo_retriever.retriever#
Attributes#
Exceptions#
Common base class for all non-exit exceptions. |
Classes#
Client for retrieving document chunks from a Nemo Retriever service. |
|
Abstract base class for a document retrieval system. |
Functions#
|
|
|
|
|
Module Contents#
- logger#
Bases:
nat.retriever.models.RetrieverErrorCommon base class for all non-exit exceptions.
Initialize self. See help(type(self)) for accurate signature.
- class NemoRetriever(
- uri: str | pydantic.HttpUrl,
- timeout: int = 60,
- nvidia_api_key: str = None,
- \*\*kwargs,
Bases:
nat.retriever.interface.RetrieverClient for retrieving document chunks from a Nemo Retriever service.
- base_url = ''#
- timeout = 60#
- _search_func#
- api_key#
- _bound_params = []#
- bind(\*\*kwargs) None#
Bind default values to the search method. Cannot bind the
queryparameter.- Args:
kwargs: Key value pairs corresponding to the default values of search parameters.
- get_unbound_params() list[str]#
Returns a list of unbound parameters which will need to be passed to the search function.
- async get_collections(client) list[Collection]#
Get a list of all available collections as pydantic Collection objects.
- async get_collection_by_name(collection_name, client) Collection#
Retrieve a collection using its name. Will return the first collection found if the name is ambiguous.
- async search(query: str, \*\*kwargs)#
Retireve max(top_k) items from the data store based on vector similarity search (implementation dependent).
- class NemoLangchainRetriever(/, **data: Any)#
Bases:
langchain_core.retrievers.BaseRetriever,pydantic.BaseModelAbstract base class for a document retrieval system.
A retrieval system is defined as something that can take string queries and return the most ‘relevant’ documents from some source.
Usage:
A retriever follows the standard
Runnableinterface, and should be used via the standardRunnablemethods ofinvoke,ainvoke,batch,abatch.Implementation:
When implementing a custom retriever, the class should implement the
_get_relevant_documentsmethod to define the logic for retrieving documents.Optionally, an async native implementations can be provided by overriding the
_aget_relevant_documentsmethod. validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- client: NemoRetriever#
- abstractmethod _get_relevant_documents(query, *, run_manager, \*\*kwargs)#
Get documents relevant to a query.
- Args:
query: String to find relevant documents for. run_manager: The callback handler to use.
- Returns:
List of relevant documents.
- async _aget_relevant_documents(query, *, run_manager, \*\*kwargs)#
Asynchronously get documents relevant to a query.
- Args:
query: String to find relevant documents for run_manager: The callback handler to use
- Returns:
List of relevant documents