ConversationAnalysisClient 類別

語言服務交談 API 是一套自然語言處理 (NLP) 技能,可用來分析結構化交談 (文字或口語) 。 如需進一步的檔, https://docs.microsoft.com/azure/cognitive-services/language-service/overview 請參閱 。

繼承
azure.ai.language.conversations.aio._client.ConversationAnalysisClient
ConversationAnalysisClient

建構函式

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

參數

endpoint
str
必要

支援的認知服務端點 (例如HTTPs://<resource-name> .cognitiveservices.azure.com) 。 必要。

credential
AzureKeyCredentialAsyncTokenCredential
必要

用戶端連線到 Azure 所需的認證。 如果使用語言 API 金鑰或來自 identity 的權杖認證,這可以是 AzureKeyCredential 的實例。

api_version
str

Api 版本。 可用的值為 「2023-04-01」 和 「2022-05-01」。 預設值為 「2023-04-01」。 請注意,覆寫此預設值可能會導致不支援的行為。

polling_interval
int

如果沒有 Retry-After 標頭,則為 LRO 作業的兩個輪詢之間的預設等候時間。

方法

analyze_conversation

分析輸入交談語句。

如需相關資訊,請參閱 https://video2.skills-academy.com/rest/api/language/2023-04-01/conversation-analysis-runtime/analyze-conversation

begin_conversation_analysis

提交交談的分析作業。

提交交談集合以供分析。 指定要執行的一或多個唯一工作。

如需相關資訊,請參閱 https://video2.skills-academy.com/rest/api/language/2023-04-01/analyze-conversation/submit-job

close
send_request

透過用戶端的鏈結原則執行網路要求。


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

如需此程式碼流程的詳細資訊,請參閱 https://aka.ms/azsdk/dpcodegen/python/send_request

analyze_conversation

分析輸入交談語句。

如需相關資訊,請參閱 https://video2.skills-academy.com/rest/api/language/2023-04-01/conversation-analysis-runtime/analyze-conversation

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

參數

task
<xref:JSON> 或 IO
必要

要執行的單一交談式工作。 這是 JSON 類型或 IO 類型。 必要。

content_type
str

Body 參數內容類型。 已知值為:'application/json'。 預設值為 [無]。

傳回

JSON 物件

傳回類型

<xref:JSON>

例外狀況

範例


   # 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

提交交談的分析作業。

提交交談集合以供分析。 指定要執行的一或多個唯一工作。

如需相關資訊,請參閱 https://video2.skills-academy.com/rest/api/language/2023-04-01/analyze-conversation/submit-job

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

參數

task
<xref:JSON> 或 IO
必要

要分析和一或多個要執行之工作的交談集合。 這是 JSON 類型或 IO 類型。 必要。

content_type
str

Body 參數內容類型。 已知值為:'application/json'。 預設值為 [無]。

continuation_token
str

從已儲存狀態重新開機輪詢器的接續權杖。

polling
boolAsyncPollingMethod

根據預設,您的輪詢方法將會是 AsyncLROBasePolling。 針對此作業傳入 False,以不輪詢,或傳入您自己的初始化輪詢物件,以取得個人輪詢策略。

polling_interval
int

如果沒有 Retry-After 標頭,則為 LRO 作業的兩個輪詢之間的預設等候時間。

傳回

傳回 JSON 物件的 AsyncLROPoller 實例

傳回類型

AsyncLROPoller[<xref:JSON>]

例外狀況

範例


   # 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

例外狀況

send_request

透過用戶端的鏈結原則執行網路要求。


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

如需此程式碼流程的詳細資訊,請參閱 https://aka.ms/azsdk/dpcodegen/python/send_request

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

參數

request
HttpRequest
必要

您想要進行的網路要求。 必要。

stream
bool

是否要串流回應承載。 預設為 False。

傳回

網路通話的回應。 不會在您的回應上處理錯誤。

傳回類型

例外狀況