ConversationAnalysisClient Clase
La API de conversaciones del servicio de lenguaje es un conjunto de aptitudes de procesamiento de lenguaje natural (NLP) que se pueden usar para analizar conversaciones estructuradas (textuales o habladas). Encontrará más documentación en https://docs.microsoft.com/azure/cognitive-services/language-service/overview.
- Herencia
-
azure.ai.language.conversations.aio._client.ConversationAnalysisClientConversationAnalysisClient
Constructor
ConversationAnalysisClient(endpoint: str, credential: AzureKeyCredential | AsyncTokenCredential, **kwargs: Any)
Parámetros
- endpoint
- str
Punto de conexión de Cognitive Services compatible (por ejemplo, https://<resource-name>
.cognitiveservices.azure.com). Necesario.
- credential
- AzureKeyCredential o AsyncTokenCredential
Credencial necesaria para que el cliente se conecte a Azure. Puede ser una instancia de AzureKeyCredential si usa una clave de Language API o una credencial de token de identity.
- api_version
- str
Versión de api. Los valores disponibles son "2023-04-01" y "2022-05-01". El valor predeterminado es "2023-04-01". Tenga en cuenta que la invalidación de este valor predeterminado puede dar lugar a un comportamiento no admitido.
- polling_interval
- int
Tiempo de espera predeterminado entre dos sondeos para las operaciones LRO si no hay ningún encabezado Retry-After presente.
Métodos
analyze_conversation |
Analiza la expresión de conversación de entrada. Consulte https://learn.microsoft.com/rest/api/language/2023-04-01/conversation-analysis-runtime/analyze-conversation para obtener más información. |
begin_conversation_analysis |
Enviar trabajo de análisis para conversaciones. Envíe una colección de conversaciones para su análisis. Especifica una o más tareas únicas que se van a ejecutar. Consulte https://learn.microsoft.com/rest/api/language/2023-04-01/analyze-conversation/submit-job para obtener más información. |
close | |
send_request |
Ejecuta la solicitud de red a través de las directivas encadenadas del cliente.
Para obtener más información sobre este flujo de código, consulte https://aka.ms/azsdk/dpcodegen/python/send_request |
analyze_conversation
Analiza la expresión de conversación de entrada.
Consulte https://learn.microsoft.com/rest/api/language/2023-04-01/conversation-analysis-runtime/analyze-conversation para obtener más información.
async analyze_conversation(task: MutableMapping[str, Any] | IO, **kwargs: Any) -> MutableMapping[str, Any]
Parámetros
- task
- <xref:JSON> o IO
Una sola tarea conversacional que se va a ejecutar. Es un tipo JSON o un tipo de E/S. Necesario.
- content_type
- str
Tipo de contenido del parámetro body. Los valores conocidos son: "application/json". El valor predeterminado es Ninguno.
Devoluciones
Objeto JSON
Tipo de valor devuelto
Excepciones
Ejemplos
# 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 trabajo de análisis para conversaciones.
Envíe una colección de conversaciones para su análisis. Especifica una o más tareas únicas que se van a ejecutar.
Consulte https://learn.microsoft.com/rest/api/language/2023-04-01/analyze-conversation/submit-job para obtener más información.
async begin_conversation_analysis(task: MutableMapping[str, Any] | IO, **kwargs: Any) -> AsyncLROPoller[MutableMapping[str, Any]]
Parámetros
- task
- <xref:JSON> o IO
Colección de conversaciones para analizar y una o varias tareas que se van a ejecutar. Es un tipo JSON o un tipo de E/S. Necesario.
- content_type
- str
Tipo de contenido del parámetro body. Los valores conocidos son: "application/json". El valor predeterminado es Ninguno.
- continuation_token
- str
Token de continuación para reiniciar un sondeo desde un estado guardado.
- polling
- bool o AsyncPollingMethod
De forma predeterminada, el método de sondeo será AsyncLROBasePolling. Pase False para que esta operación no sondee o pase su propio objeto de sondeo inicializado para una estrategia de sondeo personal.
- polling_interval
- int
Tiempo de espera predeterminado entre dos sondeos para las operaciones LRO si no hay ningún encabezado Retry-After presente.
Devoluciones
Instancia de AsyncLROPoller que devuelve el objeto JSON
Tipo de valor devuelto
Excepciones
Ejemplos
# 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
send_request
Ejecuta la solicitud de red a través de las directivas encadenadas del 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 obtener más información sobre este flujo de código, consulte https://aka.ms/azsdk/dpcodegen/python/send_request
send_request(request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]
Parámetros
- stream
- bool
Si se transmitirá la carga de respuesta. El valor predeterminado es False.
Devoluciones
Respuesta de la llamada de red. No realiza el control de errores en la respuesta.
Tipo de valor devuelto
Excepciones
Azure SDK for Python