azure.ai.language.conversations.aio package

class azure.ai.language.conversations.aio.ConversationAnalysisClient(endpoint: str, credential: Union[azure.core.credentials.AzureKeyCredential, azure.core.credentials_async.AsyncTokenCredential], **kwargs: Any)[source]

The language service conversations API is a suite of natural language processing (NLP) skills that can be used to analyze structured conversations (textual or spoken). The synchronous API in this suite accepts a request and mediates among multiple language projects, such as LUIS Generally Available, Question Answering, Conversational Language Understanding, and then calls the best candidate service to handle the request. At last, it returns a response with the candidate service’s response as a payload.

See https://docs.microsoft.com/rest/api/language/conversation-analysis-runtime/ for more information about requests and responses you can pass to this client.

Parameters
  • endpoint (str) – Supported Cognitive Services endpoint (e.g., https://<resource-name>.cognitiveservices.azure.com). Required.

  • 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
  • api_version (str) – Api Version. Available values are “2022-10-01-preview”, “2022-05-15-preview”, “2022-05-01”. Default value is “2022-10-01-preview”. Note that overriding this default value may result in unsupported behavior.

  • polling_interval (int) – Default waiting time between two polls for LRO operations if no Retry-After header is present.

async analyze_conversation(task: Union[collections.abc.MutableMapping[str, Any], IO], **kwargs: Any)collections.abc.MutableMapping[str, Any]

Analyzes the input conversation utterance.

See https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversation-analysis/analyze-conversation for more information.

Parameters

task (JSON or IO) – A single conversational task to execute. 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

HttpResponseError

Example

# The response is polymorphic. The following are possible polymorphic responses based
  off discriminator "kind":

# JSON input template for discriminator value "ConversationResult":
analyze_conversation_task_result = {
    "kind": "ConversationResult",
    "result": {
        "prediction": base_prediction,
        "query": "str",  # The conversation utterance given by the caller.
          Required.
        "detectedLanguage": "str"  # Optional. The system detected language
          for the query in BCP 47 language representation..
    }
}

# JSON input template for discriminator value "Conversation":
base_prediction = {
    "entities": [
        {
            "category": "str",  # The entity category. Required.
            "confidenceScore": 0.0,  # The entity confidence score.
              Required.
            "length": 0,  # The length of the text. Required.
            "offset": 0,  # The starting index of this entity in the
              query. Required.
            "text": "str",  # The predicted entity text. Required.
            "extraInformation": [
                base_extra_information
            ],
            "resolutions": [
                base_resolution
            ]
        }
    ],
    "intents": [
        {
            "category": "str",  # A predicted class. Required.
            "confidenceScore": 0.0  # The confidence score of the class
              from 0.0 to 1.0. Required.
        }
    ],
    "projectKind": "Conversation",
    "topIntent": "str"  # Optional. The intent with the highest score.
}

# JSON input template for discriminator value "Orchestration":
base_prediction = {
    "intents": {
        "str": target_intent_result
    },
    "projectKind": "Orchestration",
    "topIntent": "str"  # Optional. The intent with the highest score.
}

# response body for status code(s): 200
response == analyze_conversation_task_result
async begin_conversation_analysis(task: Union[collections.abc.MutableMapping[str, Any], IO], **kwargs: Any)azure.core.polling._async_poller.AsyncLROPoller[collections.abc.MutableMapping[str, Any]]

Submit analysis job for conversations.

Submit a collection of conversations for analysis. Specify one or more unique tasks to be executed.

See https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversation-analysis-runtime/submit-job for more information.

Parameters

task (JSON or IO) – The collection of conversations to analyze and one or more tasks to execute. 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.

  • 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[JSON]

Raises

HttpResponseError

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",  # The status of the task at the mentioned last update time.
      Required. Known values are: "notStarted", "running", "succeeded", "failed",
      "cancelled", "cancelling", and "partiallyCompleted".
    "tasks": {
        "completed": 0,  # Count of tasks completed successfully. Required.
        "failed": 0,  # Count of tasks that failed. Required.
        "inProgress": 0,  # Count of tasks in progress currently. Required.
        "total": 0,  # Total count of tasks submitted as part of the job.
          Required.
        "items": [
            analyze_conversation_job_result
        ]
    },
    "displayName": "str",  # Optional.
    "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",
              "ServiceUnavailable", "Timeout", "QuotaExceeded", "Conflict", and
              "Warning".
            "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",
                  "ExtractionFailure", "InvalidRequestBodyFormat", "EmptyRequest",
                  "MissingInputDocuments", "InvalidDocument", "ModelVersionIncorrect",
                  "InvalidDocumentBatch", "UnsupportedLanguageCode", and
                  "InvalidCountryHint".
                "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.
    "nextLink": "str",  # Optional.
    "statistics": {
        "conversationsCount": 0,  # Number of conversations submitted in the
          request. Required.
        "documentsCount": 0,  # Number of documents submitted in the request.
          Required.
        "erroneousConversationsCount": 0,  # Number of invalid documents.
          This includes empty, over-size limit or non-supported languages documents.
          Required.
        "erroneousDocumentsCount": 0,  # Number of invalid documents. This
          includes empty, over-size limit or non-supported languages documents.
          Required.
        "transactionsCount": 0,  # Number of transactions for the request.
          Required.
        "validConversationsCount": 0,  # Number of conversations documents.
          This excludes empty, over-size limit or non-supported languages documents.
          Required.
        "validDocumentsCount": 0  # Number of valid documents. This excludes
          empty, over-size limit or non-supported languages documents. Required.
    }
}
async close()None[source]
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/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

AsyncHttpResponse