langchain_community.retrievers.vespa_retriever.VespaRetriever

Note

VespaRetriever implements the standard Runnable Interface. 🏃

class langchain_community.retrievers.vespa_retriever.VespaRetriever[source]

Bases: BaseRetriever

Vespa retriever.

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 app: Any = None

Vespa application to query.

param body: Dict [Required]

Body of the query.

param content_field: str [Required]

Name of the content field.

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 metadata_fields: Sequence[str] [Required]

Names of the metadata fields.

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.

async aget_relevant_documents(query: str, *, callbacks: Callbacks = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, run_name: Optional[str] = None, **kwargs: Any) List[Document]

[Deprecated] Asynchronously get documents relevant to a query.

Users should favor using .ainvoke or .abatch rather than aget_relevant_documents directly.

Parameters
  • query (str) – string to find relevant documents for

  • callbacks (Callbacks) – Callback manager or list of callbacks

  • tags (Optional[List[str]]) – 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.

  • metadata (Optional[Dict[str, Any]]) – 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.

  • run_name (Optional[str]) – Optional name for the run.

  • kwargs (Any) –

Returns

List of relevant documents

Return type

List[Document]

Notes

Deprecated since version langchain-core==0.1.46: Use ainvoke instead.

classmethod from_params(url: str, content_field: str, *, k: Optional[int] = None, metadata_fields: Union[Sequence[str], Literal['*']] = (), sources: Optional[Union[Sequence[str], Literal['*']]] = None, _filter: Optional[str] = None, yql: Optional[str] = None, **kwargs: Any) VespaRetriever[source]

Instantiate retriever from params.

Parameters
  • url (str) – Vespa app URL.

  • content_field (str) – Field in results to return as Document page_content.

  • k (Optional[int]) – Number of Documents to return. Defaults to None.

  • metadata_fields (Sequence[str] or "*") – Fields in results to include in document metadata. Defaults to empty tuple ().

  • sources (Sequence[str] or "*" or None) – Sources to retrieve from. Defaults to None.

  • _filter (Optional[str]) – Document filter condition expressed in YQL. Defaults to None.

  • yql (Optional[str]) – Full YQL query to be used. Should not be specified if _filter or sources are specified. Defaults to None.

  • kwargs (Any) – Keyword arguments added to query body.

Returns

Instantiated VespaRetriever.

Return type

VespaRetriever

get_relevant_documents(query: str, *, callbacks: Callbacks = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, run_name: Optional[str] = None, **kwargs: Any) List[Document]

[Deprecated] Retrieve documents relevant to a query.

Users should favor using .invoke or .batch rather than get_relevant_documents directly.

Parameters
  • query (str) – string to find relevant documents for

  • callbacks (Callbacks) – Callback manager or list of callbacks

  • tags (Optional[List[str]]) – 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.

  • metadata (Optional[Dict[str, Any]]) – 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.

  • run_name (Optional[str]) – Optional name for the run.

  • kwargs (Any) –

Returns

List of relevant documents

Return type

List[Document]

Notes

Deprecated since version langchain-core==0.1.46: Use invoke instead.

get_relevant_documents_with_filter(query: str, *, _filter: Optional[str] = None) List[Document][source]
Parameters
  • query (str) –

  • _filter (Optional[str]) –

Return type

List[Document]

Examples using VespaRetriever