azure.ai.language.questionanswering.authoring package¶
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://learn.microsoft.com/azure/cognitive-services/language-service/overview
- Parameters
endpoint (str) – Supported Cognitive Services endpoint (e.g., https://
<resource-name>
.cognitiveservices.azure.com).credential (AzureKeyCredential or TokenCredential) – 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
Update Active Learning feedback.
See https://learn.microsoft.com/rest/api/cognitiveservices/questionanswering/question-answering-projects/add-feedback for more information.
- Parameters
project_name (str) – The name of the project to use. Required.
feedback (JSON or IO) – Feedback for Active Learning. Is either a model type or a IO type. Required.
- Keyword Arguments
content_type (str) – Body Parameter content-type. Known values are: ‘application/json’. Default value is None.
- Returns
None
- Return type
- Raises
Delete the project.
See https://learn.microsoft.com/rest/api/cognitiveservices/questionanswering/question-answering-projects/delete-project for more information.
- Parameters
project_name (str) – The name of the project to use. Required.
- Keyword Arguments
continuation_token (str) – A continuation token to restart a poller from a saved state.
polling (bool or PollingMethod) – By default, your polling method will be LROBasePolling. 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 LROPoller that returns None
- Return type
- Raises
Deploy project to production.
See https://learn.microsoft.com/rest/api/cognitiveservices/questionanswering/question-answering-projects/deploy-project for more information.
- Parameters
- Keyword Arguments
continuation_token (str) – A continuation token to restart a poller from a saved state.
polling (bool or PollingMethod) – By default, your polling method will be LROBasePolling. 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 LROPoller that returns JSON object
- Return type
LROPoller[JSON]
- Raises
Example
# response body for status code(s): 200 response == { "deploymentName": "str", # Optional. Name of the deployment. "lastDeployedDateTime": "2020-02-20 00:00:00" # Optional. Represents the project last deployment date-time. }
Export project metadata and assets.
See https://learn.microsoft.com/rest/api/cognitiveservices/questionanswering/question-answering-projects/export for more information.
- Parameters
project_name (str) – The name of the project to use. Required.
- Keyword Arguments
file_format (str) – Knowledge base Import or Export format. Known values are: “json”, “tsv”, and “excel”. Default value is “json”.
asset_kind (str) – Kind of the asset of the project. Known values are: “qnas” and “synonyms”. Default value is None.
continuation_token (str) – A continuation token to restart a poller from a saved state.
polling (bool or PollingMethod) – By default, your polling method will be LROBasePolling. 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 LROPoller that returns JSON object
- Return type
LROPoller[JSON]
- Raises
Example
# response body for status code(s): 200 response == { "createdDateTime": "2020-02-20 00:00:00", # Required. "jobId": "str", # Required. "lastUpdatedDateTime": "2020-02-20 00:00:00", # Required. "resultUrl": "str", # URL to download the result of the Export Job. Required. "status": "str", # Job Status. Required. Known values are: "notStarted", "running", "succeeded", "failed", "cancelled", "cancelling", and "partiallyCompleted". "errors": [ { "code": "str", # One of a server-defined set of error codes. Required. Known values are: "InvalidRequest", "InvalidArgument", "Unauthorized", "Forbidden", "NotFound", "ProjectNotFound", "OperationNotFound", "AzureCognitiveSearchNotFound", "AzureCognitiveSearchIndexNotFound", "TooManyRequests", "AzureCognitiveSearchThrottling", "AzureCognitiveSearchIndexLimitReached", "InternalServerError", and "ServiceUnavailable". "message": "str", # A human-readable representation of the error. Required. "details": [ ... ], "innererror": { "code": "str", # One of a server-defined set of error codes. Required. Known values are: "InvalidRequest", "InvalidParameterValue", "KnowledgeBaseNotFound", "AzureCognitiveSearchNotFound", "AzureCognitiveSearchThrottling", and "ExtractionFailure". "message": "str", # Error message. Required. "details": { "str": "str" # Optional. Error details. }, "innererror": ..., "target": "str" # Optional. Error target. }, "target": "str" # Optional. The target of the error. } ], "expirationDateTime": "2020-02-20 00:00:00" # Optional. }
Import project assets.
See https://learn.microsoft.com/rest/api/cognitiveservices/questionanswering/question-answering-projects/import for more information.
- Parameters
project_name (str) – The name of the project to use. Required.
options (JSON or IO) – Project assets the needs to be imported. Is either a model type or a IO type. Default value is None.
- Keyword Arguments
file_format (str) – Knowledge base Import or Export format. Known values are: “json”, “tsv”, and “excel”. Default value is “json”.
asset_kind (str) – Kind of the asset of the project. Known values are: “qnas” and “synonyms”. Default value is None.
content_type (str) – Body Parameter content-type. Known values are: ‘application/json’. Default value is None.
continuation_token (str) – A continuation token to restart a poller from a saved state.
polling (bool or PollingMethod) – By default, your polling method will be LROBasePolling. 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 LROPoller that returns JSON object
- Return type
LROPoller[JSON]
- Raises
Example
# response body for status code(s): 200 response == { "createdDateTime": "2020-02-20 00:00:00", # Required. "jobId": "str", # Required. "lastUpdatedDateTime": "2020-02-20 00:00:00", # Required. "status": "str", # Job Status. Required. Known values are: "notStarted", "running", "succeeded", "failed", "cancelled", "cancelling", and "partiallyCompleted". "errors": [ { "code": "str", # One of a server-defined set of error codes. Required. Known values are: "InvalidRequest", "InvalidArgument", "Unauthorized", "Forbidden", "NotFound", "ProjectNotFound", "OperationNotFound", "AzureCognitiveSearchNotFound", "AzureCognitiveSearchIndexNotFound", "TooManyRequests", "AzureCognitiveSearchThrottling", "AzureCognitiveSearchIndexLimitReached", "InternalServerError", and "ServiceUnavailable". "message": "str", # A human-readable representation of the error. Required. "details": [ ... ], "innererror": { "code": "str", # One of a server-defined set of error codes. Required. Known values are: "InvalidRequest", "InvalidParameterValue", "KnowledgeBaseNotFound", "AzureCognitiveSearchNotFound", "AzureCognitiveSearchThrottling", and "ExtractionFailure". "message": "str", # Error message. Required. "details": { "str": "str" # Optional. Error details. }, "innererror": ..., "target": "str" # Optional. Error target. }, "target": "str" # Optional. The target of the error. } ], "expirationDateTime": "2020-02-20 00:00:00" # Optional. }
Updates the QnAs of a project.
See https://learn.microsoft.com/rest/api/cognitiveservices/questionanswering/question-answering-projects/update-qnas for more information.
- Parameters
- Keyword Arguments
content_type (str) – Body Parameter content-type. Known values are: ‘application/json’. Default value is None.
continuation_token (str) – A continuation token to restart a poller from a saved state.
polling (bool or PollingMethod) – By default, your polling method will be LROBasePolling. 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 LROPoller that returns an iterator like instance of JSON object
- Return type
- Raises
Example
# response body for status code(s): 200, 202 response == { "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 . }
Updates the sources of a project.
See https://learn.microsoft.com/rest/api/cognitiveservices/questionanswering/question-answering-projects/update-sources for more information.
- Parameters
- Keyword Arguments
content_type (str) – Body Parameter content-type. Known values are: ‘application/json’. Default value is None.
continuation_token (str) – A continuation token to restart a poller from a saved state.
polling (bool or PollingMethod) – By default, your polling method will be LROBasePolling. 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 LROPoller that returns an iterator like instance of JSON object
- Return type
- Raises
Example
# response body for status code(s): 200, 202 response == { "sourceKind": "str", # Supported source types. Required. Known values are: "file" and "url". "sourceUri": "str", # URI location for the file or url. Required. "contentStructureKind": "str", # Optional. Content structure type for sources. "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. }
Create or update a project.
See https://learn.microsoft.com/rest/api/cognitiveservices/questionanswering/question-answering-projects/create-project for more information.
- Parameters
project_name (str) – The name of the project to use. Required.
options (JSON or IO) – Parameters needed to create the project. Is either a model type or a IO type. Required.
- Keyword Arguments
content_type (str) – Body Parameter content-type. Known values are: ‘application/json’. Default value is None.
- Returns
JSON object
- Return type
JSON
- Raises
Example
# response body for status code(s): 200, 201 response == { "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. } }
Get the requested project metadata.
See https://learn.microsoft.com/rest/api/cognitiveservices/questionanswering/question-answering-projects/get-project-details for more information.
- Parameters
project_name (str) – The name of the project to use. Required.
- Returns
JSON object
- Return type
JSON
- Raises
Example
# response body for status code(s): 200 response == { "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 all deployments of a project.
See https://learn.microsoft.com/rest/api/cognitiveservices/questionanswering/question-answering-projects/list-deployments for more information.
- Parameters
project_name (str) – The name of the project to use. Required.
- Keyword Arguments
- Returns
An iterator like instance of JSON object
- Return type
ItemPaged[JSON]
- Raises
Example
# response body for status code(s): 200 response == { "deploymentName": "str", # Optional. Name of the deployment. "lastDeployedDateTime": "2020-02-20 00:00:00" # Optional. Represents the project last deployment date-time. }
Gets all projects for a user.
See https://learn.microsoft.com/rest/api/cognitiveservices/questionanswering/question-answering-projects/list-projects for more information.
- Keyword Arguments
- Returns
An iterator like instance of JSON object
- Return type
ItemPaged[JSON]
- Raises
Example
# response body for status code(s): 200 response == { "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. } }
Gets all the QnAs of a project.
See https://learn.microsoft.com/rest/api/cognitiveservices/questionanswering/question-answering-projects/get-qnas for more information.
- Parameters
project_name (str) – The name of the project to use. Required.
- Keyword Arguments
- Returns
An iterator like instance of JSON object
- Return type
ItemPaged[JSON]
- Raises
Example
# response body for status code(s): 200 response == { "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 . }
Gets all the sources of a project.
See https://learn.microsoft.com/rest/api/cognitiveservices/questionanswering/question-answering-projects/get-sources for more information.
- Parameters
project_name (str) – The name of the project to use. Required.
- Keyword Arguments
- Returns
An iterator like instance of JSON object
- Return type
ItemPaged[JSON]
- Raises
Example
# response body for status code(s): 200 response == { "sourceKind": "str", # Supported source types. Required. Known values are: "file" and "url". "sourceUri": "str", # URI location for the file or url. Required. "contentStructureKind": "str", # Optional. Content structure type for sources. "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. }
Gets all the synonyms of a project.
See https://learn.microsoft.com/rest/api/cognitiveservices/questionanswering/question-answering-projects/get-synonyms for more information.
- Parameters
project_name (str) – The name of the project to use. Required.
- Keyword Arguments
- Returns
An iterator like instance of JSON object
- Return type
ItemPaged[JSON]
- Raises
Example
# response body for status code(s): 200 response == { "alterations": [ "str" # Collection of word alterations. Required. ] }
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/dpcodegen/python/send_request
- 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
Updates all the synonyms of a project.
See https://learn.microsoft.com/rest/api/cognitiveservices/questionanswering/question-answering-projects/update-synonyms for more information.
- Parameters
project_name (str) – The name of the project to use. Required.
synonyms (JSON or IO) – All the synonyms of a project. Is either a model type or a IO type. Required.
- Keyword Arguments
content_type (str) – Body Parameter content-type. Known values are: ‘application/json’. Default value is None.
- Returns
None
- Return type
- Raises