langchain.retrievers.azure_cognitive_search.AzureCognitiveSearchRetriever¶
- class langchain.retrievers.azure_cognitive_search.AzureCognitiveSearchRetriever(*, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, service_name: str = '', index_name: str = '', api_key: str = '', api_version: str = '2020-06-30', aiosession: Optional[ClientSession] = None, content_key: str = 'content', top_k: Optional[int] = None)[source]¶
Bases:
BaseRetrieverRetriever for the Azure Cognitive Search service.
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 aiosession: Optional[aiohttp.ClientSession] = None¶
ClientSession, in case we want to reuse connection for better performance.
- param api_key: str = ''¶
API Key. Both Admin and Query keys work, but for reading data it’s recommended to use a Query key.
- param api_version: str = '2020-06-30'¶
API version
- param content_key: str = 'content'¶
Key in a retrieved result to set as the Document page_content.
- param index_name: str = ''¶
Name of Index inside Azure Cognitive Search service
- 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 service_name: str = ''¶
Name of Azure Cognitive Search service
- 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: Optional[int] = None¶
Number of results to retrieve. Set to None to retrieve all results.
- 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¶
- validator validate_environment » all fields[source]¶
Validate that service name, index name and api key exists in environment.
- 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.