nat.retriever.milvus.retriever#

Attributes#

Exceptions#

CollectionNotFoundError

Common base class for all non-exit exceptions.

Classes#

MilvusRetriever

Client for retrieving document chunks from a Milvus vectorstore

Functions#

Module Contents#

logger#
exception CollectionNotFoundError#

Bases: nat.retriever.models.RetrieverError

Common base class for all non-exit exceptions.

Initialize self. See help(type(self)) for accurate signature.

class MilvusRetriever(
client: MilvusClient | AsyncMilvusClient,
embedder: langchain_core.embeddings.Embeddings,
content_field: str = 'text',
use_iterator: bool = False,
)#

Bases: nat.retriever.interface.Retriever

Client for retrieving document chunks from a Milvus vectorstore

Initialize the Milvus Retriever using a preconfigured MilvusClient or AsyncMilvusClient

Args:

_client: pymilvus.MilvusClient | pymilvus.AsyncMilvusClient#
_embedder#
_is_async#
_search_func#
_default_params = None#
_bound_params = []#
content_field = 'text'#
bind(\*\*kwargs) None#

Bind default values to the search method. Cannot bind the ‘query’ parameter.

Args:

kwargs (dict): 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 _validate_collection(collection_name: str) bool#

Validate that a collection exists.

async search(query: str, \*\*kwargs)#

Retireve max(top_k) items from the data store based on vector similarity search (implementation dependent).

async _search_with_iterator(
query: str,
*,
collection_name: str,
top_k: int,
filters: str | None = None,
output_fields: list[str] | None = None,
search_params: dict | None = None,
timeout: float | None = None,
vector_field_name: str | None = 'vector',
distance_cutoff: float | None = None,
\*\*kwargs,
)#

Retrieve document chunks from a Milvus vectorstore using a search iterator, allowing for the retrieval of more results.

Retrieve document chunks from a Milvus vectorstore

_wrap_milvus_results(
res: list[pymilvus.client.abstract.Hit],
content_field: str,
)#
_wrap_milvus_single_results(
res: pymilvus.client.abstract.Hit | dict,
content_field: str,
) nat.retriever.models.Document#