azure.ai.language.questionanswering.projects.aio package¶
-
class
azure.ai.language.questionanswering.projects.aio.
QuestionAnsweringProjectsClient
(endpoint: str, credential: Union[azure.core.credentials.AzureKeyCredential, azure.core.credentials_async.AsyncTokenCredential], **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
<a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview">https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview</a>
.- Parameters
endpoint (str) – Supported Cognitive Services endpoint (e.g., https://
<resource-name>
.api.cognitiveservices.azure.com).credential (AzureKeyCredential or AsyncTokenCredential) – Credential needed for the client to connect to Azure. This can be the an instance of AzureKeyCredential if using a Language API key or a token credential from
azure.identity
.
- Keyword Arguments
-
async
add_feedback
(project_name: str, feedback: Any, **kwargs: Any) → None¶ Update Active Learning feedback.
Update Active Learning feedback.
- Parameters
project_name (str) – The name of the project to use.
feedback (JSONType) – Feedback for Active Learning.
- Returns
None
- Return type
- Raises
~azure.core.exceptions.HttpResponseError
Example
# JSON input template you can fill out and use as your body input. feedback = { "records": [ { "qnaId": 0, # Optional. Unique ID of the QnA. "userId": "str", # Optional. Unique identifier of the user. "userQuestion": "str" # Optional. User suggested question for the QnA. } ] }
-
async
begin_delete_project
(project_name: str, **kwargs: Any) → azure.core.polling._async_poller.AsyncLROPoller[None]¶ Delete the project.
Delete the project.
- Parameters
project_name (str) – The name of the project to use.
- Keyword Arguments
continuation_token (str) – A continuation token to restart a poller from a saved state.
polling (bool or AsyncPollingMethod) – By default, your polling method will be AsyncLROBasePolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.
polling_interval (int) – Default waiting time between two polls for LRO operations if no Retry-After header is present.
- Returns
An instance of AsyncLROPoller that returns None
- Return type
- Raises
~azure.core.exceptions.HttpResponseError
-
async
begin_deploy_project
(project_name: str, deployment_name: str, **kwargs: Any) → azure.core.polling._async_poller.AsyncLROPoller[None]¶ Deploy project to production.
Deploy project to production.
- Parameters
- Keyword Arguments
continuation_token (str) – A continuation token to restart a poller from a saved state.
polling (bool or AsyncPollingMethod) – By default, your polling method will be AsyncLROBasePolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.
polling_interval (int) – Default waiting time between two polls for LRO operations if no Retry-After header is present.
- Returns
An instance of AsyncLROPoller that returns None
- Return type
- Raises
~azure.core.exceptions.HttpResponseError
-
async
begin_export
(project_name: str, *, format: Optional[str] = 'json', asset_kind: Optional[str] = None, **kwargs: Any) → azure.core.polling._async_poller.AsyncLROPoller[Any]¶ Export project metadata and assets.
Export project metadata and assets.
- Parameters
project_name (str) – The name of the project to use.
- Keyword Arguments
format (str) – Knowledge base Import or Export format. Possible values are: “json”, “tsv”, and “excel”.
asset_kind (str) – Kind of the asset of the project. Possible values are: “qnas” or “synonyms”.
continuation_token (str) – A continuation token to restart a poller from a saved state.
polling (bool or AsyncPollingMethod) – By default, your polling method will be AsyncLROBasePolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.
polling_interval (int) – Default waiting time between two polls for LRO operations if no Retry-After header is present.
- Returns
An instance of AsyncLROPoller that returns JSON object
- Return type
AsyncLROPoller[JSONType]
- Raises
~azure.core.exceptions.HttpResponseError
Example
# response body for status code(s): 200 response.json() == { "createdDateTime": "2020-02-20 00:00:00", # Required. "errors": [ { "code": "str", # Required. One of a server-defined set of error codes. Possible values include: "InvalidRequest", "InvalidArgument", "Unauthorized", "Forbidden", "NotFound", "ProjectNotFound", "OperationNotFound", "AzureCognitiveSearchNotFound", "AzureCognitiveSearchIndexNotFound", "TooManyRequests", "AzureCognitiveSearchThrottling", "AzureCognitiveSearchIndexLimitReached", "InternalServerError", "ServiceUnavailable". "details": [ ... ], "innererror": { "code": "str", # Required. One of a server-defined set of error codes. Possible values include: "InvalidRequest", "InvalidParameterValue", "KnowledgeBaseNotFound", "AzureCognitiveSearchNotFound", "AzureCognitiveSearchThrottling", "ExtractionFailure". "details": { "str": "str" # Optional. Error details. }, "innererror": ..., "message": "str", # Required. Error message. "target": "str" # Optional. Error target. }, "message": "str", # Required. A human-readable representation of the error. "target": "str" # Optional. The target of the error. } ], "expirationDateTime": "2020-02-20 00:00:00", # Optional. "jobId": "str", # Required. "lastUpdatedDateTime": "2020-02-20 00:00:00", # Required. "resultUrl": "str", # Required. URL to download the result of the Export Job. "status": "str" # Required. Job Status. Possible values include: "notStarted", "running", "succeeded", "failed", "cancelled", "cancelling", "partiallyCompleted". }
-
async
begin_import_assets
(project_name: str, options: Any = None, *, format: Optional[str] = 'json', asset_kind: Optional[str] = None, **kwargs: Any) → azure.core.polling._async_poller.AsyncLROPoller[None]¶ Import project assets.
Import project assets.
- Parameters
project_name (str) – The name of the project to use.
options (JSONType) – Project assets the needs to be imported.
- Keyword Arguments
format (str) – Knowledge base Import or Export format. Possible values are: “json”, “tsv”, and “excel”.
asset_kind (str) – Kind of the asset of the project. Possible values are: “qnas” or “synonyms”.
continuation_token (str) – A continuation token to restart a poller from a saved state.
polling (bool or AsyncPollingMethod) – By default, your polling method will be AsyncLROBasePolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.
polling_interval (int) – Default waiting time between two polls for LRO operations if no Retry-After header is present.
- Returns
An instance of AsyncLROPoller that returns None
- Return type
- Raises
~azure.core.exceptions.HttpResponseError
Example
# JSON input template you can fill out and use as your body input. options = { "assets": { "qnas": [ { "activeLearningSuggestions": [ { "clusterHead": "str", # Optional. Question chosen as the head of suggested questions cluster by Active Learning clustering algorithm. "suggestedQuestions": [ { "autoSuggestedCount": 0, # Optional. The number of times the question was suggested automatically by the Active Learning algorithm. "question": "str", # Optional. Question suggested by the Active Learning feature. "userSuggestedCount": 0 # Optional. The number of times the question was suggested explicitly by the user. } ] } ], "answer": "str", # Optional. Answer text. "dialog": { "isContextOnly": bool, # Optional. To mark if a prompt is relevant only with a previous question or not. If true, do not include this QnA as answer for queries without context; otherwise, ignores context and includes this QnA in answers. "prompts": [ { "displayOrder": 0, # Optional. Index of the prompt. It is used for ordering of the prompts. "displayText": "str", # Optional. Text displayed to represent a follow up question prompt. "qna": { "activeLearningSuggestions": [ { "clusterHead": "str", # Optional. Question chosen as the head of suggested questions cluster by Active Learning clustering algorithm. "suggestedQuestions": [ { "autoSuggestedCount": 0, # Optional. The number of times the question was suggested automatically by the Active Learning algorithm. "question": "str", # Optional. Question suggested by the Active Learning feature. "userSuggestedCount": 0 # Optional. The number of times the question was suggested explicitly by the user. } ] } ], "answer": "str", # Optional. Answer text. "dialog": ..., "id": 0, # Optional. Unique ID for the QnA. "metadata": { "str": "str" # Optional. Metadata associated with the answer, useful to categorize or filter question answers. }, "questions": [ "str" # Optional. List of questions associated with the answer. ], "source": "str" # Optional. Source from which QnA was indexed e.g. https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs . }, "qnaId": 0 # Optional. ID of the QnA corresponding to the prompt. } ] }, "id": 0, # Optional. Unique ID for the QnA. "lastUpdatedDateTime": "2020-02-20 00:00:00", # Optional. Date-time when the QnA was last updated. "metadata": { "str": "str" # Optional. Metadata associated with the answer, useful to categorize or filter question answers. }, "questions": [ "str" # Optional. List of questions associated with the answer. ], "source": "str", # Optional. Source from which QnA was indexed e.g. https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs . "sourceDisplayName": "str" # Optional. Friendly name of the Source. } ], "synonyms": [ { "alterations": [ "str" # Required. Collection of word alterations. ] } ] }, "fileUri": "str", # Optional. Import data File URI. "metadata": { "description": "str", # Optional. Description of the project. "language": "str", # Required. 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. "multilingualResource": bool, # Optional. Set to true to enable creating knowledgebases in different languages for the same resource. "settings": { "defaultAnswer": "str" # Optional. Default Answer response when no good match is found in the knowledge base. } } }
-
async
begin_update_qnas
(project_name: str, qnas: List[Any], **kwargs: Any) → azure.core.polling._async_poller.AsyncLROPoller[None]¶ Updates the QnAs of a project.
Updates the QnAs of a project.
- Parameters
- Keyword Arguments
continuation_token (str) – A continuation token to restart a poller from a saved state.
polling (bool or AsyncPollingMethod) – By default, your polling method will be AsyncLROBasePolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.
polling_interval (int) – Default waiting time between two polls for LRO operations if no Retry-After header is present.
- Returns
An instance of AsyncLROPoller that returns None
- Return type
- Raises
~azure.core.exceptions.HttpResponseError
Example
# JSON input template you can fill out and use as your body input. qnas = [ { "op": "str", # Required. Update operation type for assets. Possible values include: "add", "delete", "replace". "value": { "activeLearningSuggestions": [ { "clusterHead": "str", # Optional. Question chosen as the head of suggested questions cluster by Active Learning clustering algorithm. "suggestedQuestions": [ { "autoSuggestedCount": 0, # Optional. The number of times the question was suggested automatically by the Active Learning algorithm. "question": "str", # Optional. Question suggested by the Active Learning feature. "userSuggestedCount": 0 # Optional. The number of times the question was suggested explicitly by the user. } ] } ], "answer": "str", # Optional. Answer text. "dialog": { "isContextOnly": bool, # Optional. To mark if a prompt is relevant only with a previous question or not. If true, do not include this QnA as answer for queries without context; otherwise, ignores context and includes this QnA in answers. "prompts": [ { "displayOrder": 0, # Optional. Index of the prompt. It is used for ordering of the prompts. "displayText": "str", # Optional. Text displayed to represent a follow up question prompt. "qna": ..., "qnaId": 0 # Optional. ID of the QnA corresponding to the prompt. } ] }, "id": 0, # Optional. Unique ID for the QnA. "metadata": { "str": "str" # Optional. Metadata associated with the answer, useful to categorize or filter question answers. }, "questions": [ "str" # Optional. List of questions associated with the answer. ], "source": "str" # Optional. Source from which QnA was indexed e.g. https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs . } } ]
-
async
begin_update_sources
(project_name: str, sources: List[Any], **kwargs: Any) → azure.core.polling._async_poller.AsyncLROPoller[None]¶ Updates the sources of a project.
Updates the sources of a project.
- Parameters
- Keyword Arguments
continuation_token (str) – A continuation token to restart a poller from a saved state.
polling (bool or AsyncPollingMethod) – By default, your polling method will be AsyncLROBasePolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.
polling_interval (int) – Default waiting time between two polls for LRO operations if no Retry-After header is present.
- Returns
An instance of AsyncLROPoller that returns None
- Return type
- Raises
~azure.core.exceptions.HttpResponseError
Example
# JSON input template you can fill out and use as your body input. sources = [ { "op": "str", # Required. Update operation type for assets. Possible values include: "add", "delete", "replace". "value": { "contentStructureKind": "unstructured", # Optional. Default value is "unstructured". Content structure type for sources. Possible values include: "unstructured". "displayName": "str", # Optional. Friendly name of the Source. "refresh": bool, # Optional. Boolean flag used to refresh data from the Source. "source": "str", # Optional. Unique source identifier. Name of the file if it's a 'file' source; otherwise, the complete URL if it's a 'url' source. "sourceKind": "str", # Required. Supported source types. Possible values include: "file", "url". "sourceUri": "str" # Required. URI location for the file or url. } } ]
-
async
create_project
(project_name: str, options: Any, **kwargs: Any) → Any¶ Create or update a project.
Create or update a project.
- Parameters
project_name (str) – The name of the project to use.
options (JSONType) – Parameters needed to create the project.
- Returns
JSON object
- Return type
JSONType
- Raises
~azure.core.exceptions.HttpResponseError
Example
# JSON input template you can fill out and use as your body input. options = { "description": "str", # Optional. Description of the project. "language": "str", # Required. 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. "multilingualResource": bool, # Optional. Set to true to enable creating knowledgebases in different languages for the same resource. "settings": { "defaultAnswer": "str" # Optional. Default Answer response when no good match is found in the knowledge base. } } # response body for status code(s): 200, 201 response.json() == { "createdDateTime": "2020-02-20 00:00:00", # Optional. Project creation date-time. "description": "str", # Optional. Description of the project. "language": "str", # Optional. 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. "lastDeployedDateTime": "2020-02-20 00:00:00", # Optional. Represents the project last deployment date-time. "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. Represents the project last modified date-time. "multilingualResource": bool, # Optional. Resource enabled for multiple languages across projects or not. "projectName": "str", # Optional. Name of the project. "settings": { "defaultAnswer": "str" # Optional. Default Answer response when no good match is found in the knowledge base. } }
-
async
get_project_details
(project_name: str, **kwargs: Any) → Any¶ Get the requested project metadata.
Get the requested project metadata.
- Parameters
project_name (str) – The name of the project to use.
- Returns
JSON object
- Return type
JSONType
- Raises
~azure.core.exceptions.HttpResponseError
Example
# response body for status code(s): 200 response.json() == { "createdDateTime": "2020-02-20 00:00:00", # Optional. Project creation date-time. "description": "str", # Optional. Description of the project. "language": "str", # Optional. 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. "lastDeployedDateTime": "2020-02-20 00:00:00", # Optional. Represents the project last deployment date-time. "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. Represents the project last modified date-time. "multilingualResource": bool, # Optional. Resource enabled for multiple languages across projects or not. "projectName": "str", # Optional. Name of the project. "settings": { "defaultAnswer": "str" # Optional. Default Answer response when no good match is found in the knowledge base. } }
-
list_deployments
(project_name: str, *, top: Optional[int] = None, skip: Optional[int] = None, maxpagesize: Optional[int] = None, **kwargs: Any) → AsyncIterable[Any]¶ List all deployments of a project.
List all deployments of a project.
- Parameters
project_name (str) – The name of the project to use.
- Keyword Arguments
- Returns
An iterator like instance of JSON object
- Return type
AsyncItemPaged[JSONType]
- Raises
~azure.core.exceptions.HttpResponseError
Example
# response body for status code(s): 200 response.json() == { "nextLink": "str", # Optional. "value": [ { "deploymentName": "str", # Optional. Name of the deployment. "lastDeployedDateTime": "2020-02-20 00:00:00" # Optional. Represents the project last deployment date-time. } ] }
-
list_projects
(*, top: Optional[int] = None, skip: Optional[int] = None, maxpagesize: Optional[int] = None, **kwargs: Any) → AsyncIterable[Any]¶ Gets all projects for a user.
Gets all projects for a user.
- Keyword Arguments
- Returns
An iterator like instance of JSON object
- Return type
AsyncItemPaged[JSONType]
- Raises
~azure.core.exceptions.HttpResponseError
Example
# response body for status code(s): 200 response.json() == { "nextLink": "str", # Optional. "value": [ { "createdDateTime": "2020-02-20 00:00:00", # Optional. Project creation date-time. "description": "str", # Optional. Description of the project. "language": "str", # Optional. 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. "lastDeployedDateTime": "2020-02-20 00:00:00", # Optional. Represents the project last deployment date-time. "lastModifiedDateTime": "2020-02-20 00:00:00", # Optional. Represents the project last modified date-time. "multilingualResource": bool, # Optional. Resource enabled for multiple languages across projects or not. "projectName": "str", # Optional. Name of the project. "settings": { "defaultAnswer": "str" # Optional. Default Answer response when no good match is found in the knowledge base. } } ] }
-
list_qnas
(project_name: str, *, source: Optional[str] = None, top: Optional[int] = None, skip: Optional[int] = None, maxpagesize: Optional[int] = None, **kwargs: Any) → AsyncIterable[Any]¶ Gets all the QnAs of a project.
Gets all the QnAs of a project.
- Parameters
project_name (str) – The name of the project to use.
- Keyword Arguments
- Returns
An iterator like instance of JSON object
- Return type
AsyncItemPaged[JSONType]
- Raises
~azure.core.exceptions.HttpResponseError
Example
# response body for status code(s): 200 response.json() == { "nextLink": "str", # Optional. "value": [ { "activeLearningSuggestions": [ { "clusterHead": "str", # Optional. Question chosen as the head of suggested questions cluster by Active Learning clustering algorithm. "suggestedQuestions": [ { "autoSuggestedCount": 0, # Optional. The number of times the question was suggested automatically by the Active Learning algorithm. "question": "str", # Optional. Question suggested by the Active Learning feature. "userSuggestedCount": 0 # Optional. The number of times the question was suggested explicitly by the user. } ] } ], "answer": "str", # Optional. Answer text. "dialog": { "isContextOnly": bool, # Optional. To mark if a prompt is relevant only with a previous question or not. If true, do not include this QnA as answer for queries without context; otherwise, ignores context and includes this QnA in answers. "prompts": [ { "displayOrder": 0, # Optional. Index of the prompt. It is used for ordering of the prompts. "displayText": "str", # Optional. Text displayed to represent a follow up question prompt. "qna": { "activeLearningSuggestions": [ { "clusterHead": "str", # Optional. Question chosen as the head of suggested questions cluster by Active Learning clustering algorithm. "suggestedQuestions": [ { "autoSuggestedCount": 0, # Optional. The number of times the question was suggested automatically by the Active Learning algorithm. "question": "str", # Optional. Question suggested by the Active Learning feature. "userSuggestedCount": 0 # Optional. The number of times the question was suggested explicitly by the user. } ] } ], "answer": "str", # Optional. Answer text. "dialog": ..., "id": 0, # Optional. Unique ID for the QnA. "metadata": { "str": "str" # Optional. Metadata associated with the answer, useful to categorize or filter question answers. }, "questions": [ "str" # Optional. List of questions associated with the answer. ], "source": "str" # Optional. Source from which QnA was indexed e.g. https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs . }, "qnaId": 0 # Optional. ID of the QnA corresponding to the prompt. } ] }, "id": 0, # Optional. Unique ID for the QnA. "lastUpdatedDateTime": "2020-02-20 00:00:00", # Optional. Date-time when the QnA was last updated. "metadata": { "str": "str" # Optional. Metadata associated with the answer, useful to categorize or filter question answers. }, "questions": [ "str" # Optional. List of questions associated with the answer. ], "source": "str" # Optional. Source from which QnA was indexed e.g. https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs . } ] }
-
list_sources
(project_name: str, *, top: Optional[int] = None, skip: Optional[int] = None, maxpagesize: Optional[int] = None, **kwargs: Any) → AsyncIterable[Any]¶ Gets all the sources of a project.
Gets all the sources of a project.
- Parameters
project_name (str) – The name of the project to use.
- Keyword Arguments
- Returns
An iterator like instance of JSON object
- Return type
AsyncItemPaged[JSONType]
- Raises
~azure.core.exceptions.HttpResponseError
Example
# response body for status code(s): 200 response.json() == { "nextLink": "str", # Optional. "value": [ { "contentStructureKind": "unstructured", # Optional. Default value is "unstructured". Content structure type for sources. Possible values include: "unstructured". "displayName": "str", # Optional. Friendly name of the Source. "lastUpdatedDateTime": "2020-02-20 00:00:00", # Optional. Date-time when the QnA was last updated. "source": "str", # Optional. Unique source identifier. Name of the file if it's a 'file' source; otherwise, the complete URL if it's a 'url' source. "sourceKind": "str", # Required. Supported source types. Possible values include: "file", "url". "sourceUri": "str" # Required. URI location for the file or url. } ] }
-
list_synonyms
(project_name: str, *, top: Optional[int] = None, skip: Optional[int] = None, maxpagesize: Optional[int] = None, **kwargs: Any) → AsyncIterable[Any]¶ Gets all the synonyms of a project.
Gets all the synonyms of a project.
- Parameters
project_name (str) – The name of the project to use.
- Keyword Arguments
- Returns
An iterator like instance of JSON object
- Return type
AsyncItemPaged[JSONType]
- Raises
~azure.core.exceptions.HttpResponseError
Example
# response body for status code(s): 200 response.json() == { "nextLink": "str", # Optional. "value": [ { "alterations": [ "str" # Required. Collection of word alterations. ] } ] }
-
send_request
(request: azure.core.rest._rest_py3.HttpRequest, **kwargs: Any) → Awaitable[azure.core.rest._rest_py3.AsyncHttpResponse][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 = await client.send_request(request) <AsyncHttpResponse: 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
-
async
update_synonyms
(project_name: str, synonyms: Any, **kwargs: Any) → None¶ Updates all the synonyms of a project.
Updates all the synonyms of a project.
- Parameters
project_name (str) – The name of the project to use.
synonyms (JSONType) – All the synonyms of a project.
- Returns
None
- Return type
- Raises
~azure.core.exceptions.HttpResponseError
Example
# JSON input template you can fill out and use as your body input. synonyms = { "nextLink": "str", # Optional. "value": [ { "alterations": [ "str" # Required. Collection of word alterations. ] } ] }