Share via


ConversationAnalysisClient Classe

A API de conversas do serviço de linguagem é um conjunto de habilidades de NLP (processamento de linguagem natural) que podem ser usadas para analisar conversas estruturadas (textuais ou faladas). Outra documentação pode ser encontrada em https://docs.microsoft.com/azure/cognitive-services/language-service/overview.

Herança
azure.ai.language.conversations.aio._client.ConversationAnalysisClient
ConversationAnalysisClient

Construtor

ConversationAnalysisClient(endpoint: str, credential: AzureKeyCredential | AsyncTokenCredential, **kwargs: Any)

Parâmetros

endpoint
str
Obrigatório

Ponto de extremidade dos Serviços Cognitivos com suporte (por exemplo, https://<resource-name>.cognitiveservices.azure.com). Obrigatórios.

credential
AzureKeyCredential ou AsyncTokenCredential
Obrigatório

Credencial necessária para que o cliente se conecte ao Azure. Essa pode ser a instância do AzureKeyCredential se estiver usando uma chave de API de Linguagem ou uma credencial de token do identity.

api_version
str

Versão da API. Os valores disponíveis são "2023-04-01" e "2022-05-01". O valor padrão é "2023-04-01". Observe que substituir esse valor padrão pode resultar em um comportamento sem suporte.

polling_interval
int

Tempo de espera padrão entre duas pesquisas para operações LRO se nenhum cabeçalho Retry-After estiver presente.

Métodos

analyze_conversation

Analisa o enunciado da conversa de entrada.

Consulte https://learn.microsoft.com/rest/api/language/2023-04-01/conversation-analysis-runtime/analyze-conversation para obter mais informações.

begin_conversation_analysis

Enviar trabalho de análise para conversas.

Envie uma coleção de conversas para análise. Especificar uma ou mais tarefas exclusivas a serem executadas.

Consulte https://learn.microsoft.com/rest/api/language/2023-04-01/analyze-conversation/submit-job para obter mais informações.

close
send_request

Executa a solicitação de rede por meio das políticas encadeadas do cliente.


>>> 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>

Para obter mais informações sobre esse fluxo de código, consulte https://aka.ms/azsdk/dpcodegen/python/send_request

analyze_conversation

Analisa o enunciado da conversa de entrada.

Consulte https://learn.microsoft.com/rest/api/language/2023-04-01/conversation-analysis-runtime/analyze-conversation para obter mais informações.

async analyze_conversation(task: MutableMapping[str, Any] | IO, **kwargs: Any) -> MutableMapping[str, Any]

Parâmetros

task
<xref:JSON> ou IO
Obrigatório

Uma única tarefa de conversa a ser executada. É um tipo JSON ou um tipo de E/S. Obrigatórios.

content_type
str

Tipo de conteúdo do Parâmetro do Corpo. Os valores conhecidos são: 'application/json'. O valor padrão é Nenhum.

Retornos

Objeto JSON

Tipo de retorno

<xref:JSON>

Exceções

Exemplos


   # The input is polymorphic. The following are possible polymorphic inputs based off
     discriminator "kind":

   # JSON input template for discriminator value "Conversation":
   analyze_conversation_task = {
       "analysisInput": {
           "conversationItem": {
               "id": "str",  # The ID of a conversation item. Required.
               "participantId": "str",  # The participant ID of a
                 conversation item. Required.
               "language": "str",  # Optional. The override language of a
                 conversation item in BCP 47 language representation.
               "modality": "str",  # Optional. Enumeration of supported
                 conversational modalities. Known values are: "transcript" and "text".
               "role": "str"  # Optional. Role of the participant. Known
                 values are: "agent", "customer", and "generic".
           }
       },
       "kind": "Conversation",
       "parameters": {
           "deploymentName": "str",  # The name of the deployment to use.
             Required.
           "projectName": "str",  # The name of the project to use. Required.
           "directTarget": "str",  # Optional. The name of a target project to
             forward the request to.
           "isLoggingEnabled": bool,  # Optional. If true, the service will keep
             the query for further review.
           "stringIndexType": "TextElements_v8",  # Optional. Default value is
             "TextElements_v8". Specifies the method used to interpret string offsets. Set
             to "UnicodeCodePoint" for Python strings. Known values are:
             "TextElements_v8", "UnicodeCodePoint", and "Utf16CodeUnit".
           "targetProjectParameters": {
               "str": analysis_parameters
           },
           "verbose": bool  # Optional. If true, the service will return more
             detailed information in the response.
       }
   }

   # JSON input template you can fill out and use as your body input.
   task = analyze_conversation_task
   # 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

begin_conversation_analysis

Enviar trabalho de análise para conversas.

Envie uma coleção de conversas para análise. Especificar uma ou mais tarefas exclusivas a serem executadas.

Consulte https://learn.microsoft.com/rest/api/language/2023-04-01/analyze-conversation/submit-job para obter mais informações.

async begin_conversation_analysis(task: MutableMapping[str, Any] | IO, **kwargs: Any) -> AsyncLROPoller[MutableMapping[str, Any]]

Parâmetros

task
<xref:JSON> ou IO
Obrigatório

Coleção de conversas a serem analisadas e uma ou mais tarefas a serem executadas. É um tipo JSON ou um tipo de E/S. Obrigatórios.

content_type
str

Tipo de conteúdo do Parâmetro do Corpo. Os valores conhecidos são: 'application/json'. O valor padrão é Nenhum.

continuation_token
str

Um token de continuação para reiniciar um poller de um estado salvo.

polling
bool ou AsyncPollingMethod

Por padrão, seu método de sondagem será AsyncLROBasePolling. Passe em False para que esta operação não sondar ou passe seu próprio objeto de sondagem inicializado para uma estratégia de sondagem pessoal.

polling_interval
int

Tempo de espera padrão entre duas pesquisas para operações LRO se nenhum cabeçalho Retry-After estiver presente.

Retornos

Uma instância de AsyncLROPoller que retorna o objeto JSON

Tipo de retorno

AsyncLROPoller[<xref:JSON>]

Exceções

Exemplos


   # JSON input template you can fill out and use as your body input.
   task = {
       "analysisInput": {
           "conversations": [
               conversation
           ]
       },
       "tasks": [
           analyze_conversation_lro_task
       ],
       "displayName": "str"  # Optional. Display name for the analysis job.
   }

   # 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 that finished successfully.
             Required.
           "failed": 0,  # Count of tasks that failed. Required.
           "inProgress": 0,  # Count of tasks that are currently in progress.
             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 documents that are empty, over the size limit, or in
             unsupported languages. 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 conversation documents.
             This excludes documents that are empty, over the size limit, or in
             unsupported languages. Required.
           "validDocumentsCount": 0  # Number of valid documents. This excludes
             empty, over-size limit or non-supported languages documents. Required.
       }
   }

close

async close() -> None

Exceções

send_request

Executa a solicitação de rede por meio das políticas encadeadas do cliente.


>>> 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>

Para obter mais informações sobre esse fluxo de código, consulte https://aka.ms/azsdk/dpcodegen/python/send_request

send_request(request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]

Parâmetros

request
HttpRequest
Obrigatório

A solicitação de rede que você deseja fazer. Obrigatórios.

stream
bool

Se o conteúdo da resposta será transmitido. Usa False como padrão.

Retornos

A resposta da sua chamada de rede. Não faz tratamento de erros em sua resposta.

Tipo de retorno

Exceções