azure.ai.language.questionanswering package¶
-
class
azure.ai.language.questionanswering.
QuestionAnsweringClient
(endpoint: str, credential: AzureKeyCredential, **kwargs: Any)[source]¶ The language service API is a suite of natural language processing (NLP) skills built with best-in-class Microsoft machine learning algorithms. The API can be used to analyze unstructured text for tasks such as sentiment analysis, key phrase extraction, language detection and question answering. Further documentation can be found in https://docs.microsoft.com/azure/cognitive-services/text-analytics/overview
- Parameters
endpoint (str) – Supported Cognitive Services endpoint (e.g., https://<resource-name>.api.cognitiveservices.azure.com).
credential (AzureKeyCredential) – Credential needed for the client to connect to Azure.
- Keyword Arguments
default_language (str) – Sets the default language to use for all operations.
-
get_answers
(*args: ‘_models.AnswersOptions’, **kwargs: Any) → _models.AnswersResult¶ Answers the specified question using your knowledge base.
- Parameters
options (AnswersOptions) – Positional only. POST body of the request. Provide either options, OR individual keyword arguments. If both are provided, only the options object will be used.
- Keyword Arguments
project_name (str) – The name of the knowledge base project to use.
deployment_name (str) – The name of the specific deployment of the project to use.
qna_id (int) – Exact QnA ID to fetch from the knowledge base, this field takes priority over question.
question (str) – User question to query against the knowledge base.
top (int) – Max number of answers to be returned for the question.
user_id (str) – Unique identifier for the user.
confidence_threshold (float) – Minimum threshold score for answers, value ranges from 0 to 1.
answer_context (KnowledgeBaseAnswerContext) – Context object with previous QnA’s information.
ranker_kind (str) – Type of ranker to be used. Possible values include: “Default”, “QuestionOnly”.
filters (QueryFilters) – Filter QnAs based on given metadata list and knowledge base sources.
short_answer_options (ShortAnswerOptions) – To configure Answer span prediction feature.
include_unstructured_sources (bool) – (Optional) Flag to enable Query over Unstructured Sources.
- Returns
AnswersResult
- Return type
- Raises
~azure.core.exceptions.HttpResponseError
-
get_answers_from_text
(*args: ‘_models.AnswersFromTextOptions’, **kwargs: Any) → _models.AnswersFromTextResult¶ Answers the specified question using the provided text in the body.
- Parameters
options (AnswersFromTextOptions) – Positional only. POST body of the request. Provide either options, OR individual keyword arguments. If both are provided, only the options object will be used.
- Keyword Arguments
question (str) – User question to query against the given text records.
text_documents (list[str or TextDocument]) – Text records to be searched for given question.
language (str) – Language of the text records. This is BCP-47 representation of a language. For example, use “en” for English; “es” for Spanish etc. If not set, use “en” for English as default.
- Returns
AnswersFromTextResult
- Return type
- Raises
~azure.core.exceptions.HttpResponseError
-
send_request
(request: HttpRequest, **kwargs: Any) → HttpResponse[source]¶ Runs the network request through the client’s chained policies.
>>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = client.send_request(request) <HttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
- Parameters
request (HttpRequest) – The network request you want to make. Required.
- Keyword Arguments
stream (bool) – Whether the response payload will be streamed. Defaults to False.
- Returns
The response of your network call. Does not do error handling on your response.
- Return type