langchain.retrievers.docarray.DocArrayRetriever¶
- class langchain.retrievers.docarray.DocArrayRetriever(*, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, index: Any = None, embeddings: Embeddings, search_field: str, content_field: str, search_type: SearchType = SearchType.similarity, top_k: int = 1, filters: Optional[Any] = None)[source]¶
Bases:
BaseRetrieverRetriever for DocArray Document Indices.
Currently, supports 5 backends: InMemoryExactNNIndex, HnswDocumentIndex, QdrantDocumentIndex, ElasticDocIndex, and WeaviateDocumentIndex.
- Parameters
index – One of the above-mentioned index instances
embeddings – Embedding model to represent text as vectors
search_field – Field to consider for searching in the documents. Should be an embedding/vector/tensor.
content_field – Field that represents the main content in your document schema. Will be used as a page_content. Everything else will go into metadata.
search_type – Type of search to perform (similarity / mmr)
filters – Filters applied for document retrieval.
top_k – Number of documents to return
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- param content_field: str [Required]¶
- param embeddings: langchain.embeddings.base.Embeddings [Required]¶
- param filters: Optional[Any] = None¶
- param index: Any = None¶
- param metadata: Optional[Dict[str, Any]] = None¶
Optional metadata associated with the retriever. Defaults to None This metadata will be associated with each call to this retriever, and passed as arguments to the handlers defined in callbacks. You can use these to eg identify a specific instance of a retriever with its use case.
- param search_field: str [Required]¶
- param search_type: langchain.retrievers.docarray.SearchType = SearchType.similarity¶
- param tags: Optional[List[str]] = None¶
Optional list of tags associated with the retriever. Defaults to None These tags will be associated with each call to this retriever, and passed as arguments to the handlers defined in callbacks. You can use these to eg identify a specific instance of a retriever with its use case.
- param top_k: int = 1¶
- async aget_relevant_documents(query: str, *, callbacks: Callbacks = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) List[Document]¶
Asynchronously get documents relevant to a query. :param query: string to find relevant documents for :param callbacks: Callback manager or list of callbacks :param tags: Optional list of tags associated with the retriever. Defaults to None
These tags will be associated with each call to this retriever, and passed as arguments to the handlers defined in callbacks.
- Parameters
metadata – Optional metadata associated with the retriever. Defaults to None This metadata will be associated with each call to this retriever, and passed as arguments to the handlers defined in callbacks.
- Returns
List of relevant documents
- async ainvoke(input: str, config: Optional[RunnableConfig] = None) List[Document]¶
- get_relevant_documents(query: str, *, callbacks: Callbacks = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) List[Document]¶
Retrieve documents relevant to a query. :param query: string to find relevant documents for :param callbacks: Callback manager or list of callbacks :param tags: Optional list of tags associated with the retriever. Defaults to None
These tags will be associated with each call to this retriever, and passed as arguments to the handlers defined in callbacks.
- Parameters
metadata – Optional metadata associated with the retriever. Defaults to None This metadata will be associated with each call to this retriever, and passed as arguments to the handlers defined in callbacks.
- Returns
List of relevant documents
- invoke(input: str, config: Optional[RunnableConfig] = None) List[Document]¶
- to_json() Union[SerializedConstructor, SerializedNotImplemented]¶
- to_json_not_implemented() SerializedNotImplemented¶
- property lc_attributes: Dict¶
Return a list of attribute names that should be included in the serialized kwargs. These attributes must be accepted by the constructor.
- property lc_namespace: List[str]¶
Return the namespace of the langchain object. eg. [“langchain”, “llms”, “openai”]
- property lc_secrets: Dict[str, str]¶
Return a map of constructor argument names to secret ids. eg. {“openai_api_key”: “OPENAI_API_KEY”}
- property lc_serializable: bool¶
Return whether or not the class is serializable.