diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/CHANGELOG.md b/sdk/cognitivelanguage/azure-ai-language-conversations/CHANGELOG.md index 687f1680f2ed..7ecbe86d1d7f 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/CHANGELOG.md +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/CHANGELOG.md @@ -1,14 +1,27 @@ # Release History -## 1.1.0b4 (Unreleased) +## 1.1.0 (Unreleased) ### Features Added +- Added support for service version 2023-04-01. ### Breaking Changes -### Bugs Fixed +> Note: The following changes are only breaking from the previous beta. They are not breaking since version 1.0.0 when those types and members did not exist. -### Other Changes +- Removed support for service version 2022-05-15-preview. +- Removed support for service version 2022-10-01-preview. +- Removed support for "ConversationalPIITask" analysis with `ConversationAnalysisClient`. +- Removed support for "ConversationalSentimentTask" with `ConversationAnalysisClient`. +- Removed the following methods from `ConversationAuthoringClient`: + - `begin_assign_deployment_resources` + - `get_assign_deployment_resources_status` + - `begin_unassign_deployment_resources` + - `get_unassign_deployment_resources_status` + - `begin_delete_deployment_from_resources` + - `get_deployment_delete_from_resources_status` + - `list_assigned_resource_deployments` + - `list_deployment_resources` ## 1.1.0b3 (2022-11-10) diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/README.md b/sdk/cognitivelanguage/azure-ai-language-conversations/README.md index 82f8eeecc9e6..b65baf65257d 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/README.md +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/README.md @@ -5,8 +5,6 @@ Conversational Language Understanding - aka **CLU** for short - is a cloud-based - Conversation App: It's used in extracting intents and entities in conversations - Workflow app: Acts like an orchestrator to select the best candidate to analyze conversations to get best response from apps like Qna, Luis, and Conversation App - Conversational Summarization: Used to analyze conversations in the form of issues/resolution, chapter title, and narrative summarizations -- Conversational PII: Used to extract and redact personally-identifiable information (PII) -- Conversational Sentiment Analysis: Used to analyze the sentiment of conversations [Source code][conversationallanguage_client_src] | [Package (PyPI)][conversationallanguage_pypi_package] @@ -31,10 +29,10 @@ Conversational Language Understanding - aka **CLU** for short - is a cloud-based Install the Azure Conversations client library for Python with [pip][pip_link]: ```bash -pip install azure-ai-language-conversations --pre +pip install azure-ai-language-conversations ``` -> Note: This version of the client library defaults to the 2022-10-01-preview version of the service +> Note: This version of the client library defaults to the 2023-04-01 version of the service ### Authenticate the client In order to interact with the CLU service, you'll need to create an instance of the [ConversationAnalysisClient][conversationanalysisclient_class] class, or [ConversationAuthoringClient][conversationauthoringclient_class] class. You will need an **endpoint**, and an **API key** to instantiate a client object. For more information regarding authenticating with Cognitive Services, see [Authenticate requests to Azure Cognitive Services][cognitive_auth]. @@ -337,178 +335,6 @@ with client: print(f"{summary['aspect']}: {summary['text']}") ``` -### Conversational PII - -You can use this sample if you need to extract and redact pii info from/in conversations - -```python -# import libraries -import os -from azure.core.credentials import AzureKeyCredential -from azure.ai.language.conversations import ConversationAnalysisClient -# get secrets -endpoint = os.environ["AZURE_CONVERSATIONS_ENDPOINT"] -key = os.environ["AZURE_CONVERSATIONS_KEY"] -# analyze query -client = ConversationAnalysisClient(endpoint, AzureKeyCredential(key)) -with client: - poller = client.begin_conversation_analysis( - task={ - "displayName": "Analyze PII in conversation", - "analysisInput": { - "conversations": [ - { - "conversationItems": [ - { - "id": "1", - "participantId": "0", - "modality": "transcript", - "text": "It is john doe.", - "lexical": "It is john doe", - "itn": "It is john doe", - "maskedItn": "It is john doe" - }, - { - "id": "2", - "participantId": "1", - "modality": "transcript", - "text": "Yes, 633-27-8199 is my phone", - "lexical": "yes six three three two seven eight one nine nine is my phone", - "itn": "yes 633278199 is my phone", - "maskedItn": "yes 633278199 is my phone", - }, - { - "id": "3", - "participantId": "1", - "modality": "transcript", - "text": "j.doe@yahoo.com is my email", - "lexical": "j dot doe at yahoo dot com is my email", - "maskedItn": "j.doe@yahoo.com is my email", - "itn": "j.doe@yahoo.com is my email", - } - ], - "modality": "transcript", - "id": "1", - "language": "en" - } - ] - }, - "tasks": [ - { - "kind": "ConversationalPIITask", - "parameters": { - "redactionSource": "lexical", - "piiCategories": [ - "all" - ] - } - } - ] - } - ) - # view result - result = poller.result() - task_result = result["tasks"]["items"][0] - print("... view task status ...") - print("status: {}".format(task_result["status"])) - conv_pii_result = task_result["results"] - if conv_pii_result["errors"]: - print("... errors occurred ...") - for error in conv_pii_result["errors"]: - print(error) - else: - conversation_result = conv_pii_result["conversations"][0] - if conversation_result["warnings"]: - print("... view warnings ...") - for warning in conversation_result["warnings"]: - print(warning) - else: - print("... view task result ...") - for conversation in conversation_result["conversationItems"]: - print("conversation id: {}".format(conversation["id"])) - print("... entities ...") - for entity in conversation["entities"]: - print("text: {}".format(entity["text"])) - print("category: {}".format(entity["category"])) - print("confidence: {}".format(entity["confidenceScore"])) - print("offset: {}".format(entity["offset"])) - print("length: {}".format(entity["length"])) -``` - - -### Conversational Sentiment Analysis - -Analyze sentiment in conversations. - -```python -# import libraries -import os -from azure.core.credentials import AzureKeyCredential -from azure.ai.language.conversations import ConversationAnalysisClient -# get secrets -endpoint = os.environ["AZURE_CONVERSATIONS_ENDPOINT"] -key = os.environ["AZURE_CONVERSATIONS_KEY"] -# analyze query -client = ConversationAnalysisClient(endpoint, AzureKeyCredential(key)) - -with client: - poller = client.begin_conversation_analysis( - task={ - "displayName": "Sentiment Analysis from a call center conversation", - "analysisInput": { - "conversations": [ - { - "id": "1", - "language": "en", - "modality": "transcript", - "conversationItems": [ - { - "participantId": "1", - "id": "1", - "text": "I like the service. I do not like the food", - "lexical": "i like the service i do not like the food", - } - ] - } - ] - }, - "tasks": [ - { - "taskName": "Conversation Sentiment Analysis", - "kind": "ConversationalSentimentTask", - "parameters": { - "modelVersion": "latest", - "predictionSource": "text" - } - } - ] - } - ) - - result = poller.result() - task_result = result["tasks"]["items"][0] - print("... view task status ...") - print(f"status: {task_result['status']}") - conv_sentiment_result = task_result["results"] - if conv_sentiment_result["errors"]: - print("... errors occurred ...") - for error in conv_sentiment_result["errors"]: - print(error) - else: - conversation_result = conv_sentiment_result["conversations"][0] - if conversation_result["warnings"]: - print("... view warnings ...") - for warning in conversation_result["warnings"]: - print(warning) - else: - print("... view task result ...") - for conversation in conversation_result["conversationItems"]: - print(f"Participant ID: {conversation['participantId']}") - print(f"Sentiment: {conversation['sentiment']}") - print(f"confidenceScores: {conversation['confidenceScores']}") -``` - - ### Import a Conversation Project This sample shows a common scenario for the authoring part of the SDK diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/assets.json b/sdk/cognitivelanguage/azure-ai-language-conversations/assets.json index b72e51b00361..fc6241ed7704 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/assets.json +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/cognitivelanguage/azure-ai-language-conversations", - "Tag": "python/cognitivelanguage/azure-ai-language-conversations_e2cf06813b" + "Tag": "python/cognitivelanguage/azure-ai-language-conversations_b33e6ad861" } diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_client.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_client.py index d49d020196b9..fcaad97793cc 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_client.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_client.py @@ -33,8 +33,8 @@ class ConversationAnalysisClient( :type endpoint: str :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2022-10-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-04-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -43,7 +43,7 @@ class ConversationAnalysisClient( def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: _endpoint = "{Endpoint}/language" self._config = ConversationAnalysisClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) - self._client = PipelineClient(base_url=_endpoint, config=self._config, **kwargs) + self._client: PipelineClient = PipelineClient(base_url=_endpoint, config=self._config, **kwargs) self._serialize = Serializer() self._deserialize = Deserializer() @@ -82,5 +82,5 @@ def __enter__(self) -> "ConversationAnalysisClient": self._client.__enter__() return self - def __exit__(self, *exc_details) -> None: + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_configuration.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_configuration.py index 8ad40ae85c01..39e392ae0d68 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_configuration.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,11 +13,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -35,14 +29,14 @@ class ConversationAnalysisClientConfiguration(Configuration): # pylint: disable :type endpoint: str :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2022-10-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-04-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: super(ConversationAnalysisClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-10-01-preview"] = kwargs.pop("api_version", "2022-10-01-preview") + api_version: str = kwargs.pop("api_version", "2023-04-01") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_operations/_operations.py index 39477835d655..04cca8b31029 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_operations/_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload @@ -32,10 +33,6 @@ from collections.abc import MutableMapping else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,9 +46,7 @@ def build_conversation_analysis_analyze_conversation_request(**kwargs: Any) -> H _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -73,9 +68,7 @@ def build_conversation_analysis_conversation_analysis_request(**kwargs: Any) -> _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -98,7 +91,7 @@ def analyze_conversation(self, task: JSON, *, content_type: str = "application/j """Analyzes the input conversation utterance. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversation-analysis/analyze-conversation + https://learn.microsoft.com/rest/api/language/2023-04-01/conversation-analysis/analyze-conversation for more information. :param task: A single conversational task to execute. Required. @@ -127,7 +120,7 @@ def analyze_conversation(self, task: JSON, *, content_type: str = "application/j conversation item in BCP 47 language representation. "modality": "str", # Optional. Enumeration of supported conversational modalities. Known values are: "transcript" and "text". - "role": "str" # Optional. The role of the participant. Known + "role": "str" # Optional. Role of the participant. Known values are: "agent", "customer", and "generic". } }, @@ -217,7 +210,7 @@ def analyze_conversation(self, task: IO, *, content_type: str = "application/jso """Analyzes the input conversation utterance. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversation-analysis/analyze-conversation + https://learn.microsoft.com/rest/api/language/2023-04-01/conversation-analysis/analyze-conversation for more information. :param task: A single conversational task to execute. Required. @@ -231,7 +224,6 @@ def analyze_conversation(self, task: IO, *, content_type: str = "application/jso Example: .. code-block:: python - # The response is polymorphic. The following are possible polymorphic responses based off discriminator "kind": @@ -295,10 +287,10 @@ def analyze_conversation(self, task: Union[JSON, IO], **kwargs: Any) -> JSON: """Analyzes the input conversation utterance. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversation-analysis/analyze-conversation + https://learn.microsoft.com/rest/api/language/2023-04-01/conversation-analysis/analyze-conversation for more information. - :param task: A single conversational task to execute. Is either a model type or a IO type. + :param task: A single conversational task to execute. Is either a JSON type or a IO type. Required. :type task: JSON or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -311,6 +303,47 @@ def analyze_conversation(self, task: Union[JSON, IO], **kwargs: Any) -> JSON: Example: .. code-block:: python + # 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": @@ -385,7 +418,7 @@ def analyze_conversation(self, task: Union[JSON, IO], **kwargs: Any) -> JSON: content_type = content_type or "application/json" _json = None _content = None - if isinstance(task, (IO, bytes)): + if isinstance(task, (IOBase, bytes)): _content = task else: _json = task @@ -403,8 +436,9 @@ def analyze_conversation(self, task: Union[JSON, IO], **kwargs: Any) -> JSON: } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -441,7 +475,7 @@ def _conversation_analysis_initial(self, task: Union[JSON, IO], **kwargs: Any) - content_type = content_type or "application/json" _json = None _content = None - if isinstance(task, (IO, bytes)): + if isinstance(task, (IOBase, bytes)): _content = task else: _json = task @@ -459,8 +493,9 @@ def _conversation_analysis_initial(self, task: Union[JSON, IO], **kwargs: Any) - } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -497,11 +532,10 @@ def begin_conversation_analysis( executed. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversation-analysis-runtime/submit-job + https://learn.microsoft.com/rest/api/language/2023-04-01/conversation-analysis-runtime/submit-job for more information. - :param task: The collection of conversations to analyze and one or more tasks to execute. - Required. + :param task: Collection of conversations to analyze and one or more tasks to execute. Required. :type task: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -530,7 +564,7 @@ def begin_conversation_analysis( "tasks": [ analyze_conversation_lro_task ], - "displayName": "str" # Optional. Optional display name for the analysis job. + "displayName": "str" # Optional. Display name for the analysis job. } # response body for status code(s): 200 @@ -542,9 +576,11 @@ def begin_conversation_analysis( Required. Known values are: "notStarted", "running", "succeeded", "failed", "cancelled", "cancelling", and "partiallyCompleted". "tasks": { - "completed": 0, # Count of tasks completed successfully. Required. + "completed": 0, # Count of tasks that finished successfully. + Required. "failed": 0, # Count of tasks that failed. Required. - "inProgress": 0, # Count of tasks in progress currently. 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": [ @@ -595,16 +631,16 @@ def begin_conversation_analysis( "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. + 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 conversations documents. - This excludes empty, over-size limit or non-supported languages documents. - 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. } @@ -621,11 +657,10 @@ def begin_conversation_analysis( executed. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversation-analysis-runtime/submit-job + https://learn.microsoft.com/rest/api/language/2023-04-01/conversation-analysis-runtime/submit-job for more information. - :param task: The collection of conversations to analyze and one or more tasks to execute. - Required. + :param task: Collection of conversations to analyze and one or more tasks to execute. Required. :type task: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -653,9 +688,11 @@ def begin_conversation_analysis( Required. Known values are: "notStarted", "running", "succeeded", "failed", "cancelled", "cancelling", and "partiallyCompleted". "tasks": { - "completed": 0, # Count of tasks completed successfully. Required. + "completed": 0, # Count of tasks that finished successfully. + Required. "failed": 0, # Count of tasks that failed. Required. - "inProgress": 0, # Count of tasks in progress currently. 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": [ @@ -706,16 +743,16 @@ def begin_conversation_analysis( "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. + 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 conversations documents. - This excludes empty, over-size limit or non-supported languages documents. - 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. } @@ -730,11 +767,11 @@ def begin_conversation_analysis(self, task: Union[JSON, IO], **kwargs: Any) -> L executed. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversation-analysis-runtime/submit-job + https://learn.microsoft.com/rest/api/language/2023-04-01/conversation-analysis-runtime/submit-job for more information. - :param task: The collection of conversations to analyze and one or more tasks to execute. Is - either a model type or a IO type. Required. + :param task: Collection of conversations to analyze and one or more tasks to execute. Is either + a JSON type or a IO type. Required. :type task: JSON or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -753,6 +790,19 @@ def begin_conversation_analysis(self, task: Union[JSON, IO], **kwargs: Any) -> L Example: .. code-block:: python + # 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. @@ -762,9 +812,11 @@ def begin_conversation_analysis(self, task: Union[JSON, IO], **kwargs: Any) -> L Required. Known values are: "notStarted", "running", "succeeded", "failed", "cancelled", "cancelling", and "partiallyCompleted". "tasks": { - "completed": 0, # Count of tasks completed successfully. Required. + "completed": 0, # Count of tasks that finished successfully. + Required. "failed": 0, # Count of tasks that failed. Required. - "inProgress": 0, # Count of tasks in progress currently. 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": [ @@ -815,16 +867,16 @@ def begin_conversation_analysis(self, task: Union[JSON, IO], **kwargs: Any) -> L "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. + 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 conversations documents. - This excludes empty, over-size limit or non-supported languages documents. - 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. } diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_patch.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_patch.py index f3b96a5948e5..31fa0a8c9db5 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_patch.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_patch.py @@ -52,14 +52,8 @@ def _authentication_policy(credential): class ConversationAnalysisClient(GeneratedConversationAnalysisClient): """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. + that can be used to analyze structured conversations (textual or spoken). Further documentation + can be found in https://docs.microsoft.com/azure/cognitive-services/language-service/overview. :param endpoint: Supported Cognitive Services endpoint (e.g., https://:code:``.cognitiveservices.azure.com). Required. @@ -68,12 +62,11 @@ class ConversationAnalysisClient(GeneratedConversationAnalysisClient): This can be the an instance of AzureKeyCredential if using a Language API key or a token credential from :mod:`azure.identity`. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential - :keyword api_version: 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. + :keyword api_version: Api Version. Available values are "2023-04-01" and "2022-05-01". Default value is + "2023-04-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + Retry-After header is present. """ def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, TokenCredential], **kwargs: Any) -> None: diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_serialization.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_serialization.py index 4842ef347dd2..842ae727fbbc 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_serialization.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_serialization.py @@ -64,6 +64,7 @@ import isodate # type: ignore from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback +from azure.core.serialization import NULL as AzureCoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -628,7 +629,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if xml_desc.get("attr", False): if xml_ns: ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) serialized.set(xml_name, new_attr) # type: ignore continue if xml_desc.get("text", False): @@ -802,6 +803,8 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: + if data is AzureCoreNull: + return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -1268,7 +1271,7 @@ def _extract_name_from_internal_type(internal_type): xml_name = internal_type_xml_map.get("name", internal_type.__name__) xml_ns = internal_type_xml_map.get("ns", None) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) return xml_name @@ -1292,7 +1295,7 @@ def xml_key_extractor(attr, attr_desc, data): # Integrate namespace if necessary xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) # If it's an attribute, that's simple if xml_desc.get("attr", False): diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_version.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_version.py index a741dc7b69b5..59deb8c7263b 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_version.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.1.0b4" +VERSION = "1.1.0" diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_client.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_client.py index 4c2fdc26d011..8ca7200c6bf2 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_client.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_client.py @@ -33,8 +33,8 @@ class ConversationAnalysisClient( :type endpoint: str :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2022-10-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-04-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -43,7 +43,7 @@ class ConversationAnalysisClient( def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: _endpoint = "{Endpoint}/language" self._config = ConversationAnalysisClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) - self._client = AsyncPipelineClient(base_url=_endpoint, config=self._config, **kwargs) + self._client: AsyncPipelineClient = AsyncPipelineClient(base_url=_endpoint, config=self._config, **kwargs) self._serialize = Serializer() self._deserialize = Deserializer() @@ -82,5 +82,5 @@ async def __aenter__(self) -> "ConversationAnalysisClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_configuration.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_configuration.py index 1ffc12c4054b..b6fed7e5d09d 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_configuration.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,11 +13,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -35,14 +29,14 @@ class ConversationAnalysisClientConfiguration(Configuration): # pylint: disable :type endpoint: str :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2022-10-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-04-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(ConversationAnalysisClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-10-01-preview"] = kwargs.pop("api_version", "2022-10-01-preview") + api_version: str = kwargs.pop("api_version", "2023-04-01") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_operations/_operations.py index 74b088e4c53c..6639c0fca598 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_operations/_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload @@ -46,7 +47,7 @@ async def analyze_conversation(self, task: JSON, *, content_type: str = "applica """Analyzes the input conversation utterance. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversation-analysis/analyze-conversation + https://learn.microsoft.com/rest/api/language/2023-04-01/conversation-analysis/analyze-conversation for more information. :param task: A single conversational task to execute. Required. @@ -75,7 +76,7 @@ async def analyze_conversation(self, task: JSON, *, content_type: str = "applica conversation item in BCP 47 language representation. "modality": "str", # Optional. Enumeration of supported conversational modalities. Known values are: "transcript" and "text". - "role": "str" # Optional. The role of the participant. Known + "role": "str" # Optional. Role of the participant. Known values are: "agent", "customer", and "generic". } }, @@ -165,7 +166,7 @@ async def analyze_conversation(self, task: IO, *, content_type: str = "applicati """Analyzes the input conversation utterance. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversation-analysis/analyze-conversation + https://learn.microsoft.com/rest/api/language/2023-04-01/conversation-analysis/analyze-conversation for more information. :param task: A single conversational task to execute. Required. @@ -179,7 +180,6 @@ async def analyze_conversation(self, task: IO, *, content_type: str = "applicati Example: .. code-block:: python - # The response is polymorphic. The following are possible polymorphic responses based off discriminator "kind": @@ -243,10 +243,10 @@ async def analyze_conversation(self, task: Union[JSON, IO], **kwargs: Any) -> JS """Analyzes the input conversation utterance. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversation-analysis/analyze-conversation + https://learn.microsoft.com/rest/api/language/2023-04-01/conversation-analysis/analyze-conversation for more information. - :param task: A single conversational task to execute. Is either a model type or a IO type. + :param task: A single conversational task to execute. Is either a JSON type or a IO type. Required. :type task: JSON or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -259,6 +259,47 @@ async def analyze_conversation(self, task: Union[JSON, IO], **kwargs: Any) -> JS Example: .. code-block:: python + # 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": @@ -333,7 +374,7 @@ async def analyze_conversation(self, task: Union[JSON, IO], **kwargs: Any) -> JS content_type = content_type or "application/json" _json = None _content = None - if isinstance(task, (IO, bytes)): + if isinstance(task, (IOBase, bytes)): _content = task else: _json = task @@ -351,8 +392,9 @@ async def analyze_conversation(self, task: Union[JSON, IO], **kwargs: Any) -> JS } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -389,7 +431,7 @@ async def _conversation_analysis_initial(self, task: Union[JSON, IO], **kwargs: content_type = content_type or "application/json" _json = None _content = None - if isinstance(task, (IO, bytes)): + if isinstance(task, (IOBase, bytes)): _content = task else: _json = task @@ -407,8 +449,9 @@ async def _conversation_analysis_initial(self, task: Union[JSON, IO], **kwargs: } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -445,11 +488,10 @@ async def begin_conversation_analysis( executed. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversation-analysis-runtime/submit-job + https://learn.microsoft.com/rest/api/language/2023-04-01/conversation-analysis-runtime/submit-job for more information. - :param task: The collection of conversations to analyze and one or more tasks to execute. - Required. + :param task: Collection of conversations to analyze and one or more tasks to execute. Required. :type task: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -478,7 +520,7 @@ async def begin_conversation_analysis( "tasks": [ analyze_conversation_lro_task ], - "displayName": "str" # Optional. Optional display name for the analysis job. + "displayName": "str" # Optional. Display name for the analysis job. } # response body for status code(s): 200 @@ -490,9 +532,11 @@ async def begin_conversation_analysis( Required. Known values are: "notStarted", "running", "succeeded", "failed", "cancelled", "cancelling", and "partiallyCompleted". "tasks": { - "completed": 0, # Count of tasks completed successfully. Required. + "completed": 0, # Count of tasks that finished successfully. + Required. "failed": 0, # Count of tasks that failed. Required. - "inProgress": 0, # Count of tasks in progress currently. 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": [ @@ -543,16 +587,16 @@ async def begin_conversation_analysis( "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. + 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 conversations documents. - This excludes empty, over-size limit or non-supported languages documents. - 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. } @@ -569,11 +613,10 @@ async def begin_conversation_analysis( executed. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversation-analysis-runtime/submit-job + https://learn.microsoft.com/rest/api/language/2023-04-01/conversation-analysis-runtime/submit-job for more information. - :param task: The collection of conversations to analyze and one or more tasks to execute. - Required. + :param task: Collection of conversations to analyze and one or more tasks to execute. Required. :type task: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -601,9 +644,11 @@ async def begin_conversation_analysis( Required. Known values are: "notStarted", "running", "succeeded", "failed", "cancelled", "cancelling", and "partiallyCompleted". "tasks": { - "completed": 0, # Count of tasks completed successfully. Required. + "completed": 0, # Count of tasks that finished successfully. + Required. "failed": 0, # Count of tasks that failed. Required. - "inProgress": 0, # Count of tasks in progress currently. 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": [ @@ -654,16 +699,16 @@ async def begin_conversation_analysis( "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. + 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 conversations documents. - This excludes empty, over-size limit or non-supported languages documents. - 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. } @@ -678,11 +723,11 @@ async def begin_conversation_analysis(self, task: Union[JSON, IO], **kwargs: Any executed. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversation-analysis-runtime/submit-job + https://learn.microsoft.com/rest/api/language/2023-04-01/conversation-analysis-runtime/submit-job for more information. - :param task: The collection of conversations to analyze and one or more tasks to execute. Is - either a model type or a IO type. Required. + :param task: Collection of conversations to analyze and one or more tasks to execute. Is either + a JSON type or a IO type. Required. :type task: JSON or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -701,6 +746,19 @@ async def begin_conversation_analysis(self, task: Union[JSON, IO], **kwargs: Any Example: .. code-block:: python + # 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. @@ -710,9 +768,11 @@ async def begin_conversation_analysis(self, task: Union[JSON, IO], **kwargs: Any Required. Known values are: "notStarted", "running", "succeeded", "failed", "cancelled", "cancelling", and "partiallyCompleted". "tasks": { - "completed": 0, # Count of tasks completed successfully. Required. + "completed": 0, # Count of tasks that finished successfully. + Required. "failed": 0, # Count of tasks that failed. Required. - "inProgress": 0, # Count of tasks in progress currently. 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": [ @@ -763,16 +823,16 @@ async def begin_conversation_analysis(self, task: Union[JSON, IO], **kwargs: Any "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. + 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 conversations documents. - This excludes empty, over-size limit or non-supported languages documents. - 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. } diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_patch.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_patch.py index 12e123195fb0..6c7aec7da3e8 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_patch.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/aio/_patch.py @@ -52,11 +52,8 @@ def _authentication_policy(credential): class ConversationAnalysisClient(GeneratedConversationAnalysisClient): """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. + that can be used to analyze structured conversations (textual or spoken). Further documentation + can be found in https://docs.microsoft.com/azure/cognitive-services/language-service/overview. See https://docs.microsoft.com/rest/api/language/conversation-analysis-runtime/ for more information about requests and responses you can pass to this client. @@ -68,12 +65,11 @@ class ConversationAnalysisClient(GeneratedConversationAnalysisClient): This can be the an instance of AzureKeyCredential if using a Language API key or a token credential from :mod:`azure.identity`. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: 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. + :keyword api_version: Api Version. Available values are "2023-04-01" and "2022-05-01". Default value is + "2023-04-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + Retry-After header is present. """ def __init__( diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_client.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_client.py index f0a613cbfd00..76109cfce8fd 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_client.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_client.py @@ -33,8 +33,8 @@ class ConversationAuthoringClient( :type endpoint: str :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2022-10-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-04-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -43,7 +43,7 @@ class ConversationAuthoringClient( def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: _endpoint = "{Endpoint}/language" self._config = ConversationAuthoringClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) - self._client = PipelineClient(base_url=_endpoint, config=self._config, **kwargs) + self._client: PipelineClient = PipelineClient(base_url=_endpoint, config=self._config, **kwargs) self._serialize = Serializer() self._deserialize = Deserializer() @@ -82,5 +82,5 @@ def __enter__(self) -> "ConversationAuthoringClient": self._client.__enter__() return self - def __exit__(self, *exc_details) -> None: + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_configuration.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_configuration.py index b1f2db6c71b0..c278a7145eed 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_configuration.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,11 +13,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -35,14 +29,14 @@ class ConversationAuthoringClientConfiguration(Configuration): # pylint: disabl :type endpoint: str :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2022-10-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-04-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: super(ConversationAuthoringClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-10-01-preview"] = kwargs.pop("api_version", "2022-10-01-preview") + api_version: str = kwargs.pop("api_version", "2023-04-01") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_operations/_operations.py index d205da8efeb9..80f3725519d2 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_operations/_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -34,10 +35,6 @@ from collections.abc import MutableMapping else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,9 +49,7 @@ def build_conversation_authoring_list_projects_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,9 +73,7 @@ def build_conversation_authoring_create_project_request(project_name: str, **kwa _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,9 +99,7 @@ def build_conversation_authoring_get_project_request(project_name: str, **kwargs _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -132,9 +123,7 @@ def build_conversation_authoring_delete_project_request(project_name: str, **kwa _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -166,9 +155,7 @@ def build_conversation_authoring_export_project_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -202,9 +189,7 @@ def build_conversation_authoring_import_project_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -233,9 +218,7 @@ def build_conversation_authoring_train_request(project_name: str, **kwargs: Any) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -263,9 +246,7 @@ def build_conversation_authoring_list_deployments_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -294,9 +275,7 @@ def build_conversation_authoring_swap_deployments_request(project_name: str, **k _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -324,9 +303,7 @@ def build_conversation_authoring_get_deployment_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -354,9 +331,7 @@ def build_conversation_authoring_deploy_project_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -385,9 +360,7 @@ def build_conversation_authoring_delete_deployment_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -408,77 +381,13 @@ def build_conversation_authoring_delete_deployment_request( return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_conversation_authoring_delete_deployment_from_resources_request( - project_name: str, deployment_name: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/authoring/analyze-conversations/projects/{projectName}/deployments/{deploymentName}/:delete-from-resources" - path_format_arguments = { - "projectName": _SERIALIZER.url("project_name", project_name, "str", max_length=100), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_conversation_authoring_get_deployment_delete_from_resources_status_request( - project_name: str, deployment_name: str, job_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/authoring/analyze-conversations/projects/{projectName}/deployments/{deploymentName}/delete-from-resources/jobs/{jobId}" # pylint: disable=line-too-long - path_format_arguments = { - "projectName": _SERIALIZER.url("project_name", project_name, "str", max_length=100), - "deploymentName": _SERIALIZER.url("deployment_name", deployment_name, "str"), - "jobId": _SERIALIZER.url("job_id", job_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - def build_conversation_authoring_get_deployment_job_status_request( project_name: str, deployment_name: str, job_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -506,9 +415,7 @@ def build_conversation_authoring_get_swap_deployments_job_status_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -535,9 +442,7 @@ def build_conversation_authoring_get_export_project_job_status_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -564,9 +469,7 @@ def build_conversation_authoring_get_import_project_job_status_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -593,9 +496,7 @@ def build_conversation_authoring_list_trained_models_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -625,9 +526,7 @@ def build_conversation_authoring_get_trained_model_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -654,9 +553,7 @@ def build_conversation_authoring_delete_trained_model_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -683,9 +580,7 @@ def build_conversation_authoring_load_snapshot_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -718,9 +613,7 @@ def build_conversation_authoring_list_model_evaluation_results_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -752,9 +645,7 @@ def build_conversation_authoring_get_model_evaluation_summary_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -783,9 +674,7 @@ def build_conversation_authoring_get_load_snapshot_status_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -809,163 +698,13 @@ def build_conversation_authoring_get_load_snapshot_status_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_conversation_authoring_list_deployment_resources_request( - project_name: str, *, top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/authoring/analyze-conversations/projects/{projectName}/resources" - path_format_arguments = { - "projectName": _SERIALIZER.url("project_name", project_name, "str", max_length=100), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - if top is not None: - _params["top"] = _SERIALIZER.query("top", top, "int") - if skip is not None: - _params["skip"] = _SERIALIZER.query("skip", skip, "int") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_conversation_authoring_assign_deployment_resources_request(project_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/authoring/analyze-conversations/projects/{projectName}/resources/:assign" - path_format_arguments = { - "projectName": _SERIALIZER.url("project_name", project_name, "str", max_length=100), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_conversation_authoring_unassign_deployment_resources_request(project_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/authoring/analyze-conversations/projects/{projectName}/resources/:unassign" - path_format_arguments = { - "projectName": _SERIALIZER.url("project_name", project_name, "str", max_length=100), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_conversation_authoring_get_assign_deployment_resources_status_request( - project_name: str, job_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/authoring/analyze-conversations/projects/{projectName}/resources/assign/jobs/{jobId}" - path_format_arguments = { - "projectName": _SERIALIZER.url("project_name", project_name, "str", max_length=100), - "jobId": _SERIALIZER.url("job_id", job_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_conversation_authoring_get_unassign_deployment_resources_status_request( - project_name: str, job_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/authoring/analyze-conversations/projects/{projectName}/resources/unassign/jobs/{jobId}" - path_format_arguments = { - "projectName": _SERIALIZER.url("project_name", project_name, "str", max_length=100), - "jobId": _SERIALIZER.url("job_id", job_id, "str"), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - def build_conversation_authoring_list_training_jobs_request( project_name: str, *, top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -995,9 +734,7 @@ def build_conversation_authoring_get_training_job_status_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1024,9 +761,7 @@ def build_conversation_authoring_cancel_training_job_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1051,9 +786,7 @@ def build_conversation_authoring_get_project_deletion_job_status_request(job_id: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1073,42 +806,13 @@ def build_conversation_authoring_get_project_deletion_job_status_request(job_id: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_conversation_authoring_list_assigned_resource_deployments_request( - *, top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/authoring/analyze-conversations/projects/global/deployments/resources" - - # Construct parameters - if top is not None: - _params["top"] = _SERIALIZER.query("top", top, "int") - if skip is not None: - _params["skip"] = _SERIALIZER.query("skip", skip, "int") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - def build_conversation_authoring_list_supported_languages_request( *, project_kind: str, top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1139,9 +843,7 @@ def build_conversation_authoring_list_supported_prebuilt_entities_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1170,9 +872,7 @@ def build_conversation_authoring_list_training_config_versions_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-10-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-10-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1200,7 +900,7 @@ def list_projects(self, *, top: Optional[int] = None, skip: Optional[int] = None """Lists the existing projects. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/list-projects + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/list-projects for more information. :keyword top: The maximum number of resources to return from the collection. Default value is @@ -1226,7 +926,7 @@ def list_projects(self, *, top: Optional[int] = None, skip: Optional[int] = None "lastModifiedDateTime": "2020-02-20 00:00:00", # Represents the project creation datetime. Required. "projectKind": "str", # Represents the project kind. Required. Known values - are: "Conversation", "Orchestration", and "CustomConversationSummarization". + are: "Conversation" and "Orchestration". "projectName": "str", # The new project name. Required. "description": "str", # Optional. The project description. "lastDeployedDateTime": "2020-02-20 00:00:00", # Optional. Represents the @@ -1240,9 +940,7 @@ def list_projects(self, *, top: Optional[int] = None, skip: Optional[int] = None highest confidence, at which the prediction will automatically be changed to "None". The value of the threshold should be between 0 and 1 inclusive. Required. - }, - "storageInputContainerName": "str" # Optional. The storage container name in - case of conversation summarization. + } } """ _headers = kwargs.pop("headers", {}) or {} @@ -1307,8 +1005,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1327,7 +1026,7 @@ def create_project( """Creates a new project or updates an existing one. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/create-project + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/create-project for more information. :param project_name: The name of the project to use. Required. @@ -1350,7 +1049,7 @@ def create_project( a language. For example, use "en" for English, "en-gb" for English (UK), "es" for Spanish etc. Required. "projectKind": "str", # Represents the project kind. Required. Known values - are: "Conversation", "Orchestration", and "CustomConversationSummarization". + are: "Conversation" and "Orchestration". "projectName": "str", # The new project name. Required. "description": "str", # Optional. The project description. "multilingual": bool, # Optional. Whether the project would be used for @@ -1360,9 +1059,7 @@ def create_project( highest confidence, at which the prediction will automatically be changed to "None". The value of the threshold should be between 0 and 1 inclusive. Required. - }, - "storageInputContainerName": "str" # Optional. The storage container name in - case of conversation summarization. + } } # response body for status code(s): 200, 201 @@ -1375,7 +1072,7 @@ def create_project( "lastModifiedDateTime": "2020-02-20 00:00:00", # Represents the project creation datetime. Required. "projectKind": "str", # Represents the project kind. Required. Known values - are: "Conversation", "Orchestration", and "CustomConversationSummarization". + are: "Conversation" and "Orchestration". "projectName": "str", # The new project name. Required. "description": "str", # Optional. The project description. "lastDeployedDateTime": "2020-02-20 00:00:00", # Optional. Represents the @@ -1389,9 +1086,7 @@ def create_project( highest confidence, at which the prediction will automatically be changed to "None". The value of the threshold should be between 0 and 1 inclusive. Required. - }, - "storageInputContainerName": "str" # Optional. The storage container name in - case of conversation summarization. + } } """ @@ -1402,7 +1097,7 @@ def create_project( """Creates a new project or updates an existing one. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/create-project + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/create-project for more information. :param project_name: The name of the project to use. Required. @@ -1429,7 +1124,7 @@ def create_project( "lastModifiedDateTime": "2020-02-20 00:00:00", # Represents the project creation datetime. Required. "projectKind": "str", # Represents the project kind. Required. Known values - are: "Conversation", "Orchestration", and "CustomConversationSummarization". + are: "Conversation" and "Orchestration". "projectName": "str", # The new project name. Required. "description": "str", # Optional. The project description. "lastDeployedDateTime": "2020-02-20 00:00:00", # Optional. Represents the @@ -1443,9 +1138,7 @@ def create_project( highest confidence, at which the prediction will automatically be changed to "None". The value of the threshold should be between 0 and 1 inclusive. Required. - }, - "storageInputContainerName": "str" # Optional. The storage container name in - case of conversation summarization. + } } """ @@ -1454,12 +1147,12 @@ def create_project(self, project_name: str, project: Union[JSON, IO], **kwargs: """Creates a new project or updates an existing one. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/create-project + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/create-project for more information. :param project_name: The name of the project to use. Required. :type project_name: str - :param project: The project parameters. Is either a model type or a IO type. Required. + :param project: The project parameters. Is either a JSON type or a IO type. Required. :type project: JSON or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/merge-patch+json'. Default value is None. @@ -1471,23 +1164,15 @@ def create_project(self, project_name: str, project: Union[JSON, IO], **kwargs: Example: .. code-block:: python - # response body for status code(s): 200, 201 - response == { - "createdDateTime": "2020-02-20 00:00:00", # Represents the project creation - datetime. Required. + # JSON input template you can fill out and use as your body input. + project = { "language": "str", # The project language. This is BCP-47 representation of a language. For example, use "en" for English, "en-gb" for English (UK), "es" for Spanish etc. Required. - "lastModifiedDateTime": "2020-02-20 00:00:00", # Represents the project - creation datetime. Required. "projectKind": "str", # Represents the project kind. Required. Known values - are: "Conversation", "Orchestration", and "CustomConversationSummarization". + are: "Conversation" and "Orchestration". "projectName": "str", # The new project name. Required. "description": "str", # Optional. The project description. - "lastDeployedDateTime": "2020-02-20 00:00:00", # Optional. Represents the - project last deployed datetime. - "lastTrainedDateTime": "2020-02-20 00:00:00", # Optional. Represents the - project last trained datetime. "multilingual": bool, # Optional. Whether the project would be used for multiple languages or not. "settings": { @@ -1495,9 +1180,34 @@ def create_project(self, project_name: str, project: Union[JSON, IO], **kwargs: highest confidence, at which the prediction will automatically be changed to "None". The value of the threshold should be between 0 and 1 inclusive. Required. - }, - "storageInputContainerName": "str" # Optional. The storage container name in - case of conversation summarization. + } + } + + # response body for status code(s): 200, 201 + response == { + "createdDateTime": "2020-02-20 00:00:00", # Represents the project creation + datetime. Required. + "language": "str", # The project language. This is BCP-47 representation of + a language. For example, use "en" for English, "en-gb" for English (UK), "es" for + Spanish etc. Required. + "lastModifiedDateTime": "2020-02-20 00:00:00", # Represents the project + creation datetime. Required. + "projectKind": "str", # Represents the project kind. Required. Known values + are: "Conversation" and "Orchestration". + "projectName": "str", # The new project name. Required. + "description": "str", # Optional. The project description. + "lastDeployedDateTime": "2020-02-20 00:00:00", # Optional. Represents the + project last deployed datetime. + "lastTrainedDateTime": "2020-02-20 00:00:00", # Optional. Represents the + project last trained datetime. + "multilingual": bool, # Optional. Whether the project would be used for + multiple languages or not. + "settings": { + "confidenceThreshold": 0.0 # The threshold of the intent with the + highest confidence, at which the prediction will automatically be changed to + "None". The value of the threshold should be between 0 and 1 inclusive. + Required. + } } """ error_map = { @@ -1517,7 +1227,7 @@ def create_project(self, project_name: str, project: Union[JSON, IO], **kwargs: content_type = content_type or "application/merge-patch+json" _json = None _content = None - if isinstance(project, (IO, bytes)): + if isinstance(project, (IOBase, bytes)): _content = project else: _json = project @@ -1536,8 +1246,9 @@ def create_project(self, project_name: str, project: Union[JSON, IO], **kwargs: } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1568,7 +1279,7 @@ def get_project(self, project_name: str, **kwargs: Any) -> JSON: """Gets the details of a project. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-project + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-project for more information. :param project_name: The name of the project to use. Required. @@ -1590,7 +1301,7 @@ def get_project(self, project_name: str, **kwargs: Any) -> JSON: "lastModifiedDateTime": "2020-02-20 00:00:00", # Represents the project creation datetime. Required. "projectKind": "str", # Represents the project kind. Required. Known values - are: "Conversation", "Orchestration", and "CustomConversationSummarization". + are: "Conversation" and "Orchestration". "projectName": "str", # The new project name. Required. "description": "str", # Optional. The project description. "lastDeployedDateTime": "2020-02-20 00:00:00", # Optional. Represents the @@ -1604,9 +1315,7 @@ def get_project(self, project_name: str, **kwargs: Any) -> JSON: highest confidence, at which the prediction will automatically be changed to "None". The value of the threshold should be between 0 and 1 inclusive. Required. - }, - "storageInputContainerName": "str" # Optional. The storage container name in - case of conversation summarization. + } } """ error_map = { @@ -1633,8 +1342,9 @@ def get_project(self, project_name: str, **kwargs: Any) -> JSON: } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1678,8 +1388,9 @@ def _delete_project_initial(self, project_name: str, **kwargs: Any) -> Optional[ } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1711,7 +1422,7 @@ def begin_delete_project(self, project_name: str, **kwargs: Any) -> LROPoller[JS """Deletes a project. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/delete-project + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/delete-project for more information. :param project_name: The name of the project to use. Required. @@ -1867,8 +1578,9 @@ def _export_project_initial( } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1909,7 +1621,7 @@ def begin_export_project( """Triggers a job to export a project's data. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/export + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/export for more information. :param project_name: The name of the project to use. Required. @@ -2073,7 +1785,7 @@ def _import_project_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(project, (IO, bytes)): + if isinstance(project, (IOBase, bytes)): _content = project else: _json = project @@ -2093,8 +1805,9 @@ def _import_project_initial( } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2135,7 +1848,7 @@ def begin_import_project( that project is replaced. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/import + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/import for more information. :param project_name: The name of the project to use. Required. @@ -2279,8 +1992,7 @@ def begin_import_project( representation of a language. For example, use "en" for English, "en-gb" for English (UK), "es" for Spanish etc. Required. "projectKind": "str", # Represents the project kind. Required. Known - values are: "Conversation", "Orchestration", and - "CustomConversationSummarization". + values are: "Conversation" and "Orchestration". "projectName": "str", # The new project name. Required. "description": "str", # Optional. The project description. "multilingual": bool, # Optional. Whether the project would be used @@ -2290,9 +2002,7 @@ def begin_import_project( with the highest confidence, at which the prediction will automatically be changed to "None". The value of the threshold should be between 0 and 1 inclusive. Required. - }, - "storageInputContainerName": "str" # Optional. The storage container - name in case of conversation summarization. + } }, "projectFileVersion": "str", # The version of the exported file. Required. "stringIndexType": "str", # Specifies the method used to interpret string @@ -2371,7 +2081,7 @@ def begin_import_project( that project is replaced. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/import + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/import for more information. :param project_name: The name of the project to use. Required. @@ -2467,12 +2177,12 @@ def begin_import_project( that project is replaced. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/import + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/import for more information. :param project_name: The name of the project to use. Required. :type project_name: str - :param project: The project data to import. Is either a model type or a IO type. Required. + :param project: The project data to import. Is either a JSON type or a IO type. Required. :type project: JSON or IO :keyword exported_project_format: The format of the exported project file to use. Known values are: "Conversation" and "Luis". Default value is None. @@ -2494,6 +2204,142 @@ def begin_import_project( Example: .. code-block:: python + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "projectKind": + + # JSON input template for discriminator value "Conversation": + exported_project_assets = { + "projectKind": "Conversation", + "entities": [ + { + "category": "str", # The category of the entity. Required. + "compositionSetting": "str", # Optional. The behavior to + follow when the entity's components overlap with each other. Known values + are: "returnLongestOverlap", "requireExactOverlap", "separateComponents", + and "combineComponents". + "list": { + "sublists": [ + { + "listKey": "str", # Optional. The + key of the sub-list. + "synonyms": [ + { + "language": "str", # + Optional. Represents the language of the synonyms. + This is BCP-47 representation of a language. For + example, use "en" for English, "en-gb" for English + (UK), "es" for Spanish etc. + "values": [ + "str" # + Optional. The list of synonyms. + ] + } + ] + } + ] + }, + "prebuilts": [ + { + "category": "str" # The prebuilt entity + category. Required. + } + ], + "regex": { + "expressions": [ + { + "language": "str", # Optional. + Represents the language of the regex expression. This is + BCP-47 representation of a language. For example, use "en" + for English, "en-gb" for English (UK), "es" for Spanish etc. + "regexKey": "str", # Optional. The + key of the regex expression. + "regexPattern": "str" # Optional. + The regex pattern. + } + ] + }, + "requiredComponents": [ + "str" # Optional. The required components. Allowed + values are 'learned', 'list', 'prebuilts' and 'regex'. + ] + } + ], + "intents": [ + { + "category": "str" # The intent category. Required. + } + ], + "utterances": [ + { + "intent": "str", # The intent of the utterance. Required. + "text": "str", # The utterance text. Required. + "dataset": "str", # Optional. The dataset for this + utterance. Allowed values are 'Train' and 'Test'. + "entities": [ + { + "category": "str", # The category of the + entity label. Required. + "length": 0, # Length for the entity text. + Required. + "offset": 0 # Start position for the entity + text. Required. + } + ], + "language": "str" # Optional. Represents the utterance's + language. This is BCP-47 representation of a language. For example, use + "en" for English, "en-gb" for English (UK), "es" for Spanish etc. + } + ] + } + + # JSON input template for discriminator value "Orchestration": + exported_project_assets = { + "projectKind": "Orchestration", + "intents": [ + { + "category": "str", # The intent category. Required. + "orchestration": exported_orchestration_options + } + ], + "utterances": [ + { + "intent": "str", # The intent of the utterance. Required. + "text": "str", # The utterance text. Required. + "dataset": "str", # Optional. The dataset for this + utterance. Allowed values are 'Train' and 'Test'. + "language": "str" # Optional. Represents the utterance's + language. This is BCP-47 representation of a language. For example, use + "en" for English, "en-gb" for English (UK), "es" for Spanish etc. + } + ] + } + + # JSON input template you can fill out and use as your body input. + project = { + "metadata": { + "language": "str", # The project language. This is BCP-47 + representation of a language. For example, use "en" for English, "en-gb" for + English (UK), "es" for Spanish etc. Required. + "projectKind": "str", # Represents the project kind. Required. Known + values are: "Conversation" and "Orchestration". + "projectName": "str", # The new project name. Required. + "description": "str", # Optional. The project description. + "multilingual": bool, # Optional. Whether the project would be used + for multiple languages or not. + "settings": { + "confidenceThreshold": 0.0 # The threshold of the intent + with the highest confidence, at which the prediction will automatically + be changed to "None". The value of the threshold should be between 0 and + 1 inclusive. Required. + } + }, + "projectFileVersion": "str", # The version of the exported file. Required. + "stringIndexType": "str", # Specifies the method used to interpret string + offsets. For additional information see https://aka.ms/text-analytics-offsets. + Required. "Utf16CodeUnit" + "assets": exported_project_assets + } + # response body for status code(s): 200 response == { "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the @@ -2619,7 +2465,7 @@ def _train_initial(self, project_name: str, configuration: Union[JSON, IO], **kw content_type = content_type or "application/json" _json = None _content = None - if isinstance(configuration, (IO, bytes)): + if isinstance(configuration, (IOBase, bytes)): _content = configuration else: _json = configuration @@ -2638,8 +2484,9 @@ def _train_initial(self, project_name: str, configuration: Union[JSON, IO], **kw } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2673,7 +2520,7 @@ def begin_train( """Triggers a training job for a project. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/train + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/train for more information. :param project_name: The name of the project to use. Required. @@ -2814,7 +2661,7 @@ def begin_train( """Triggers a training job for a project. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/train + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/train for more information. :param project_name: The name of the project to use. Required. @@ -2932,12 +2779,12 @@ def begin_train(self, project_name: str, configuration: Union[JSON, IO], **kwarg """Triggers a training job for a project. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/train + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/train for more information. :param project_name: The name of the project to use. Required. :type project_name: str - :param configuration: The training input parameters. Is either a model type or a IO type. + :param configuration: The training input parameters. Is either a JSON type or a IO type. Required. :type configuration: JSON or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -2957,6 +2804,27 @@ def begin_train(self, project_name: str, configuration: Union[JSON, IO], **kwarg Example: .. code-block:: python + # JSON input template you can fill out and use as your body input. + configuration = { + "modelLabel": "str", # Represents the output model label. Required. + "trainingMode": "str", # Represents the mode of the training operation. + Required. Known values are: "advanced" and "standard". + "evaluationOptions": { + "kind": "str", # Optional. Represents the evaluation kind. By + default, the evaluation kind is set to percentage. Known values are: + "percentage" and "manual". + "testingSplitPercentage": 0, # Optional. Represents the testing + dataset split percentage. Only needed in case the evaluation kind is + percentage. + "trainingSplitPercentage": 0 # Optional. Represents the training + dataset split percentage. Only needed in case the evaluation kind is + percentage. + }, + "trainingConfigVersion": "str" # Optional. Represents training config + version. By default, "latest" value is used which uses the latest released + training config version. + } + # response body for status code(s): 200 response == { "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the @@ -3103,7 +2971,7 @@ def list_deployments( """Lists the deployments belonging to a project. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/list-deployments + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/list-deployments for more information. :param project_name: The name of the project to use. Required. @@ -3131,15 +2999,8 @@ def list_deployments( "lastTrainedDateTime": "2020-02-20 00:00:00", # Represents deployment last trained time. Required. "modelId": "str", # Represents deployment modelId. Required. - "modelTrainingConfigVersion": "str", # Represents model training config + "modelTrainingConfigVersion": "str" # Represents model training config version. Required. - "assignedResources": [ - { - "region": "str", # Represents the resource region. Required. - "resourceId": "str" # Represents the Azure resource Id. - Required. - } - ] } """ _headers = kwargs.pop("headers", {}) or {} @@ -3205,8 +3066,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3238,7 +3100,7 @@ def _swap_deployments_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(deployments, (IO, bytes)): + if isinstance(deployments, (IOBase, bytes)): _content = deployments else: _json = deployments @@ -3257,8 +3119,9 @@ def _swap_deployments_initial( } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3292,7 +3155,7 @@ def begin_swap_deployments( """Swaps two existing deployments with each other. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/swap-deployments + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/swap-deployments for more information. :param project_name: The name of the project to use. Required. @@ -3387,7 +3250,7 @@ def begin_swap_deployments( """Swaps two existing deployments with each other. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/swap-deployments + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/swap-deployments for more information. :param project_name: The name of the project to use. Required. @@ -3472,13 +3335,13 @@ def begin_swap_deployments(self, project_name: str, deployments: Union[JSON, IO] """Swaps two existing deployments with each other. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/swap-deployments + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/swap-deployments for more information. :param project_name: The name of the project to use. Required. :type project_name: str - :param deployments: The job object to swap two deployments. Is either a model type or a IO - type. Required. + :param deployments: The job object to swap two deployments. Is either a JSON type or a IO type. + Required. :type deployments: JSON or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -3497,6 +3360,14 @@ def begin_swap_deployments(self, project_name: str, deployments: Union[JSON, IO] Example: .. code-block:: python + # JSON input template you can fill out and use as your body input. + deployments = { + "firstDeploymentName": "str", # Represents the first deployment name. + Required. + "secondDeploymentName": "str" # Represents the second deployment name. + Required. + } + # response body for status code(s): 200 response == { "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the @@ -3608,7 +3479,7 @@ def get_deployment(self, project_name: str, deployment_name: str, **kwargs: Any) """Gets the details of a deployment. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-deployment + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-deployment for more information. :param project_name: The name of the project to use. Required. @@ -3632,15 +3503,8 @@ def get_deployment(self, project_name: str, deployment_name: str, **kwargs: Any) "lastTrainedDateTime": "2020-02-20 00:00:00", # Represents deployment last trained time. Required. "modelId": "str", # Represents deployment modelId. Required. - "modelTrainingConfigVersion": "str", # Represents model training config + "modelTrainingConfigVersion": "str" # Represents model training config version. Required. - "assignedResources": [ - { - "region": "str", # Represents the resource region. Required. - "resourceId": "str" # Represents the Azure resource Id. - Required. - } - ] } """ error_map = { @@ -3668,8 +3532,9 @@ def get_deployment(self, project_name: str, deployment_name: str, **kwargs: Any) } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3708,7 +3573,7 @@ def _deploy_project_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(deployment, (IO, bytes)): + if isinstance(deployment, (IOBase, bytes)): _content = deployment else: _json = deployment @@ -3728,8 +3593,9 @@ def _deploy_project_initial( } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3769,7 +3635,7 @@ def begin_deploy_project( """Creates a new deployment or replaces an existing one. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/deploy-project + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/deploy-project for more information. :param project_name: The name of the project to use. Required. @@ -3797,13 +3663,7 @@ def begin_deploy_project( # JSON input template you can fill out and use as your body input. deployment = { - "trainedModelLabel": "str", # Represents the trained model label. Required. - "assignedResourceIds": [ - "str" # Optional. Represents the resource IDs to be assigned to the - deployment."n If provided, the deployment will be rolled out to - the resources provided here as well as the original resource in which the - project is created. - ] + "trainedModelLabel": "str" # Represents the trained model label. Required. } # response body for status code(s): 200 @@ -3816,15 +3676,8 @@ def begin_deploy_project( "lastTrainedDateTime": "2020-02-20 00:00:00", # Represents deployment last trained time. Required. "modelId": "str", # Represents deployment modelId. Required. - "modelTrainingConfigVersion": "str", # Represents model training config + "modelTrainingConfigVersion": "str" # Represents model training config version. Required. - "assignedResources": [ - { - "region": "str", # Represents the resource region. Required. - "resourceId": "str" # Represents the Azure resource Id. - Required. - } - ] } """ @@ -3841,7 +3694,7 @@ def begin_deploy_project( """Creates a new deployment or replaces an existing one. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/deploy-project + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/deploy-project for more information. :param project_name: The name of the project to use. Required. @@ -3877,15 +3730,8 @@ def begin_deploy_project( "lastTrainedDateTime": "2020-02-20 00:00:00", # Represents deployment last trained time. Required. "modelId": "str", # Represents deployment modelId. Required. - "modelTrainingConfigVersion": "str", # Represents model training config + "modelTrainingConfigVersion": "str" # Represents model training config version. Required. - "assignedResources": [ - { - "region": "str", # Represents the resource region. Required. - "resourceId": "str" # Represents the Azure resource Id. - Required. - } - ] } """ @@ -3896,14 +3742,14 @@ def begin_deploy_project( """Creates a new deployment or replaces an existing one. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/deploy-project + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/deploy-project for more information. :param project_name: The name of the project to use. Required. :type project_name: str :param deployment_name: The name of the specific deployment of the project to use. Required. :type deployment_name: str - :param deployment: The new deployment info. Is either a model type or a IO type. Required. + :param deployment: The new deployment info. Is either a JSON type or a IO type. Required. :type deployment: JSON or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -3922,6 +3768,11 @@ def begin_deploy_project( Example: .. code-block:: python + # JSON input template you can fill out and use as your body input. + deployment = { + "trainedModelLabel": "str" # Represents the trained model label. Required. + } + # response body for status code(s): 200 response == { "deploymentExpirationDate": "2020-02-20", # Represents deployment expiration @@ -3932,15 +3783,8 @@ def begin_deploy_project( "lastTrainedDateTime": "2020-02-20 00:00:00", # Represents deployment last trained time. Required. "modelId": "str", # Represents deployment modelId. Required. - "modelTrainingConfigVersion": "str", # Represents model training config + "modelTrainingConfigVersion": "str" # Represents model training config version. Required. - "assignedResources": [ - { - "region": "str", # Represents the resource region. Required. - "resourceId": "str" # Represents the Azure resource Id. - Required. - } - ] } """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -4021,8 +3865,9 @@ def _delete_deployment_initial(self, project_name: str, deployment_name: str, ** } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4054,7 +3899,7 @@ def begin_delete_deployment(self, project_name: str, deployment_name: str, **kwa """Deletes a project deployment. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/delete-deployment + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/delete-deployment for more information. :param project_name: The name of the project to use. Required. @@ -4179,249 +4024,26 @@ def get_long_running_output(pipeline_response): ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _delete_deployment_from_resources_initial( # pylint: disable=inconsistent-return-statements - self, project_name: str, deployment_name: str, body: Union[JSON, IO], **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + @distributed_trace + def get_deployment_job_status(self, project_name: str, deployment_name: str, job_id: str, **kwargs: Any) -> JSON: + """Gets the status of an existing deployment job. - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} + See + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-deployment-status + for more information. - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + :param project_name: The name of the project to use. Required. + :type project_name: str + :param deployment_name: The name of the specific deployment of the project to use. Required. + :type deployment_name: str + :param job_id: The job ID. Required. + :type job_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - _json = body - - request = build_conversation_authoring_delete_deployment_from_resources_request( - project_name=project_name, - deployment_name=deployment_name, - content_type=content_type, - api_version=self._config.api_version, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - response_headers = {} - response_headers["operation-location"] = self._deserialize("str", response.headers.get("operation-location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - @overload - def begin_delete_deployment_from_resources( - self, - project_name: str, - deployment_name: str, - body: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Deletes a project deployment from the specified assigned resources. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/delete-deployment-from-resources - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param deployment_name: The name of the specific deployment of the project to use. Required. - :type deployment_name: str - :param body: The options for deleting the deployment. Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: 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. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns None - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "assignedResourceIds": [ - "str" # Optional. Represents the resource IDs to delete the - deployment from."n If not provided, the deployment will be rolled - out from all the resources it is deployed to."n If provided, it - will delete the deployment only from the specified assigned resources, and - leave it for the rest. - ] - } - """ - - @overload - def begin_delete_deployment_from_resources( - self, - project_name: str, - deployment_name: str, - body: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Deletes a project deployment from the specified assigned resources. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/delete-deployment-from-resources - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param deployment_name: The name of the specific deployment of the project to use. Required. - :type deployment_name: str - :param body: The options for deleting the deployment. Required. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: 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. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns None - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_delete_deployment_from_resources( - self, project_name: str, deployment_name: str, body: Union[JSON, IO], **kwargs: Any - ) -> LROPoller[None]: - """Deletes a project deployment from the specified assigned resources. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/delete-deployment-from-resources - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param deployment_name: The name of the specific deployment of the project to use. Required. - :type deployment_name: str - :param body: The options for deleting the deployment. Is either a model type or a IO type. - Required. - :type body: JSON or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: 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. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns None - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_deployment_from_resources_initial( # type: ignore - project_name=project_name, - deployment_name=deployment_name, - body=body, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - path_format_arguments = { - "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get_deployment_delete_from_resources_status( - self, project_name: str, deployment_name: str, job_id: str, **kwargs: Any - ) -> JSON: - """Gets the status of an existing delete deployment from specific resources job. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-deployment-delete-from-resources-status - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param deployment_name: The name of the specific deployment of the project to use. Required. - :type deployment_name: str - :param job_id: The job ID. Required. - :type job_id: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python + Example: + .. code-block:: python # response body for status code(s): 200 response == { @@ -4491,7 +4113,7 @@ def get_deployment_delete_from_resources_status( cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_conversation_authoring_get_deployment_delete_from_resources_status_request( + request = build_conversation_authoring_get_deployment_job_status_request( project_name=project_name, deployment_name=deployment_name, job_id=job_id, @@ -4504,8 +4126,9 @@ def get_deployment_delete_from_resources_status( } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4525,17 +4148,15 @@ def get_deployment_delete_from_resources_status( return cast(JSON, deserialized) @distributed_trace - def get_deployment_job_status(self, project_name: str, deployment_name: str, job_id: str, **kwargs: Any) -> JSON: - """Gets the status of an existing deployment job. + def get_swap_deployments_job_status(self, project_name: str, job_id: str, **kwargs: Any) -> JSON: + """Gets the status of an existing swap deployment job. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-deployment-status + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-swap-deployments-status for more information. :param project_name: The name of the project to use. Required. :type project_name: str - :param deployment_name: The name of the specific deployment of the project to use. Required. - :type deployment_name: str :param job_id: The job ID. Required. :type job_id: str :return: JSON object @@ -4613,9 +4234,8 @@ def get_deployment_job_status(self, project_name: str, deployment_name: str, job cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_conversation_authoring_get_deployment_job_status_request( + request = build_conversation_authoring_get_swap_deployments_job_status_request( project_name=project_name, - deployment_name=deployment_name, job_id=job_id, api_version=self._config.api_version, headers=_headers, @@ -4626,8 +4246,9 @@ def get_deployment_job_status(self, project_name: str, deployment_name: str, job } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4647,11 +4268,11 @@ def get_deployment_job_status(self, project_name: str, deployment_name: str, job return cast(JSON, deserialized) @distributed_trace - def get_swap_deployments_job_status(self, project_name: str, job_id: str, **kwargs: Any) -> JSON: - """Gets the status of an existing swap deployment job. + def get_export_project_job_status(self, project_name: str, job_id: str, **kwargs: Any) -> JSON: + """Gets the status of an export job. Once job completes, returns the project metadata, and assets. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-swap-deployments-status + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-export-status for more information. :param project_name: The name of the project to use. Required. @@ -4712,6 +4333,8 @@ def get_swap_deployments_job_status(self, project_name: str, job_id: str, **kwar ], "expirationDateTime": "2020-02-20 00:00:00", # Optional. The expiration date time of the job. + "resultUrl": "str", # Optional. The URL to use in order to download the + exported project. "warnings": [ { "code": "str", # The warning code. Required. @@ -4733,7 +4356,7 @@ def get_swap_deployments_job_status(self, project_name: str, job_id: str, **kwar cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_conversation_authoring_get_swap_deployments_job_status_request( + request = build_conversation_authoring_get_export_project_job_status_request( project_name=project_name, job_id=job_id, api_version=self._config.api_version, @@ -4745,8 +4368,9 @@ def get_swap_deployments_job_status(self, project_name: str, job_id: str, **kwar } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4766,11 +4390,11 @@ def get_swap_deployments_job_status(self, project_name: str, job_id: str, **kwar return cast(JSON, deserialized) @distributed_trace - def get_export_project_job_status(self, project_name: str, job_id: str, **kwargs: Any) -> JSON: - """Gets the status of an export job. Once job completes, returns the project metadata, and assets. + def get_import_project_job_status(self, project_name: str, job_id: str, **kwargs: Any) -> JSON: + """Gets the status for an import. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-export-status + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-import-status for more information. :param project_name: The name of the project to use. Required. @@ -4831,8 +4455,6 @@ def get_export_project_job_status(self, project_name: str, job_id: str, **kwargs ], "expirationDateTime": "2020-02-20 00:00:00", # Optional. The expiration date time of the job. - "resultUrl": "str", # Optional. The URL to use in order to download the - exported project. "warnings": [ { "code": "str", # The warning code. Required. @@ -4854,7 +4476,7 @@ def get_export_project_job_status(self, project_name: str, job_id: str, **kwargs cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_conversation_authoring_get_export_project_job_status_request( + request = build_conversation_authoring_get_import_project_job_status_request( project_name=project_name, job_id=job_id, api_version=self._config.api_version, @@ -4866,8 +4488,9 @@ def get_export_project_job_status(self, project_name: str, job_id: str, **kwargs } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4887,144 +4510,25 @@ def get_export_project_job_status(self, project_name: str, job_id: str, **kwargs return cast(JSON, deserialized) @distributed_trace - def get_import_project_job_status(self, project_name: str, job_id: str, **kwargs: Any) -> JSON: - """Gets the status for an import. + def list_trained_models( + self, project_name: str, *, top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any + ) -> Iterable[JSON]: + """Lists the trained models belonging to a project. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-import-status + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/list-trained-models for more information. :param project_name: The name of the project to use. Required. :type project_name: str - :param job_id: The job ID. Required. - :type job_id: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the - job. Required. - "jobId": "str", # The job ID. Required. - "lastUpdatedDateTime": "2020-02-20 00:00:00", # The last date time the job - was updated. Required. - "status": "str", # The 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", - "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. The expiration date - time of the job. - "warnings": [ - { - "code": "str", # The warning code. Required. - "message": "str" # The warning message. Required. - } - ] - } - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - - request = build_conversation_authoring_get_import_project_job_status_request( - project_name=project_name, - job_id=job_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) - - return cast(JSON, deserialized) - - @distributed_trace - def list_trained_models( - self, project_name: str, *, top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable[JSON]: - """Lists the trained models belonging to a project. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/list-trained-models - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :keyword top: The maximum number of resources to return from the collection. Default value is - None. - :paramtype top: int - :keyword skip: An offset into the collection of the first resource to be returned. Default - value is None. - :paramtype skip: int - :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSON] + :keyword top: The maximum number of resources to return from the collection. Default value is + None. + :paramtype top: int + :keyword skip: An offset into the collection of the first resource to be returned. Default + value is None. + :paramtype skip: int + :return: An iterator like instance of JSON object + :rtype: ~azure.core.paging.ItemPaged[JSON] :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -5032,6 +4536,8 @@ def list_trained_models( # response body for status code(s): 200 response == { + "hasSnapshot": bool, # The flag to indicate if the trained model has a + snapshot ready. Required. "label": "str", # The trained model label. Required. "lastTrainedDateTime": "2020-02-20 00:00:00", # The last trained date time of the model. Required. @@ -5039,10 +4545,8 @@ def list_trained_models( training request in seconds. Required. "modelExpirationDate": "2020-02-20", # The model expiration date. Required. "modelId": "str", # The model ID. Required. - "modelTrainingConfigVersion": "str", # The model training config version. + "modelTrainingConfigVersion": "str" # The model training config version. Required. - "hasSnapshot": bool # Optional. The flag to indicate if the trained model - has a snapshot ready. } """ _headers = kwargs.pop("headers", {}) or {} @@ -5108,8 +4612,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5126,7 +4631,7 @@ def get_trained_model(self, project_name: str, trained_model_label: str, **kwarg """Gets the details of a trained model. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-trained-model + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-trained-model for more information. :param project_name: The name of the project to use. Required. @@ -5142,6 +4647,8 @@ def get_trained_model(self, project_name: str, trained_model_label: str, **kwarg # response body for status code(s): 200 response == { + "hasSnapshot": bool, # The flag to indicate if the trained model has a + snapshot ready. Required. "label": "str", # The trained model label. Required. "lastTrainedDateTime": "2020-02-20 00:00:00", # The last trained date time of the model. Required. @@ -5149,10 +4656,8 @@ def get_trained_model(self, project_name: str, trained_model_label: str, **kwarg training request in seconds. Required. "modelExpirationDate": "2020-02-20", # The model expiration date. Required. "modelId": "str", # The model ID. Required. - "modelTrainingConfigVersion": "str", # The model training config version. + "modelTrainingConfigVersion": "str" # The model training config version. Required. - "hasSnapshot": bool # Optional. The flag to indicate if the trained model - has a snapshot ready. } """ error_map = { @@ -5180,8 +4685,9 @@ def get_trained_model(self, project_name: str, trained_model_label: str, **kwarg } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5207,7 +4713,7 @@ def delete_trained_model( # pylint: disable=inconsistent-return-statements """Deletes an existing trained model. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/delete-trained-model + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/delete-trained-model for more information. :param project_name: The name of the project to use. Required. @@ -5243,8 +4749,9 @@ def delete_trained_model( # pylint: disable=inconsistent-return-statements } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5282,8 +4789,9 @@ def _load_snapshot_initial(self, project_name: str, trained_model_label: str, ** } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5315,7 +4823,7 @@ def begin_load_snapshot(self, project_name: str, trained_model_label: str, **kwa """Restores the snapshot of this trained model to be the current working directory of the project. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/load-snapshot + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/load-snapshot for more information. :param project_name: The name of the project to use. Required. @@ -5455,7 +4963,7 @@ def list_model_evaluation_results( inference results for the data included in the evaluation process. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-model-evaluation-results + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-model-evaluation-results for more information. :param project_name: The name of the project to use. Required. @@ -5579,8 +5087,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5588,1194 +5097,23 @@ def get_next(next_link=None): map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_model_evaluation_summary(self, project_name: str, trained_model_label: str, **kwargs: Any) -> JSON: - """Gets the evaluation summary of a trained model. The summary includes high level performance - measurements of the model e.g., F1, Precision, Recall, etc. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-model-evaluation-summary - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param trained_model_label: The trained model label. Required. - :type trained_model_label: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "entitiesEvaluation": { - "confusionMatrix": { - "str": { - "str": { - "normalizedValue": 0.0, # Represents - normalized value in percentages. Required. - "rawValue": 0.0 # Represents raw value. - Required. - } - } - }, - "entities": { - "str": { - "f1": 0.0, # Represents the model precision. - Required. - "falseNegativeCount": 0, # Represents the count of - false negative. Required. - "falsePositiveCount": 0, # Represents the count of - false positive. Required. - "precision": 0.0, # Represents the model recall. - Required. - "recall": 0.0, # Represents the model F1 score. - Required. - "trueNegativeCount": 0, # Represents the count of - true negative. Required. - "truePositiveCount": 0 # Represents the count of - true positive. Required. - } - }, - "macroF1": 0.0, # Represents the macro F1. Required. - "macroPrecision": 0.0, # Represents the macro precision. Required. - "macroRecall": 0.0, # Represents the macro recall. Required. - "microF1": 0.0, # Represents the micro F1. Required. - "microPrecision": 0.0, # Represents the micro precision. Required. - "microRecall": 0.0 # Represents the micro recall. Required. - }, - "intentsEvaluation": { - "confusionMatrix": { - "str": { - "str": { - "normalizedValue": 0.0, # Represents - normalized value in percentages. Required. - "rawValue": 0.0 # Represents raw value. - Required. - } - } - }, - "intents": { - "str": { - "f1": 0.0, # Represents the model precision. - Required. - "falseNegativeCount": 0, # Represents the count of - false negative. Required. - "falsePositiveCount": 0, # Represents the count of - false positive. Required. - "precision": 0.0, # Represents the model recall. - Required. - "recall": 0.0, # Represents the model F1 score. - Required. - "trueNegativeCount": 0, # Represents the count of - true negative. Required. - "truePositiveCount": 0 # Represents the count of - true positive. Required. - } - }, - "macroF1": 0.0, # Represents the macro F1. Required. - "macroPrecision": 0.0, # Represents the macro precision. Required. - "macroRecall": 0.0, # Represents the macro recall. Required. - "microF1": 0.0, # Represents the micro F1. Required. - "microPrecision": 0.0, # Represents the micro precision. Required. - "microRecall": 0.0 # Represents the micro recall. Required. - }, - "evaluationOptions": { - "kind": "str", # Optional. Represents the evaluation kind. By - default, the evaluation kind is set to percentage. Known values are: - "percentage" and "manual". - "testingSplitPercentage": 0, # Optional. Represents the testing - dataset split percentage. Only needed in case the evaluation kind is - percentage. - "trainingSplitPercentage": 0 # Optional. Represents the training - dataset split percentage. Only needed in case the evaluation kind is - percentage. - } - } - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - - request = build_conversation_authoring_get_model_evaluation_summary_request( - project_name=project_name, - trained_model_label=trained_model_label, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) - - return cast(JSON, deserialized) - - @distributed_trace - def get_load_snapshot_status(self, project_name: str, trained_model_label: str, job_id: str, **kwargs: Any) -> JSON: - """Gets the status for loading a snapshot. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-load-snapshot-status - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param trained_model_label: The trained model label. Required. - :type trained_model_label: str - :param job_id: The job ID. Required. - :type job_id: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the - job. Required. - "jobId": "str", # The job ID. Required. - "lastUpdatedDateTime": "2020-02-20 00:00:00", # The last date time the job - was updated. Required. - "status": "str", # The 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", - "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. The expiration date - time of the job. - "warnings": [ - { - "code": "str", # The warning code. Required. - "message": "str" # The warning message. Required. - } - ] - } - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - - request = build_conversation_authoring_get_load_snapshot_status_request( - project_name=project_name, - trained_model_label=trained_model_label, - job_id=job_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) - - return cast(JSON, deserialized) - - @distributed_trace - def list_deployment_resources( - self, project_name: str, *, top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable[JSON]: - """Lists the deployments resources assigned to the project. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/list-deployment-resources - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :keyword top: The maximum number of resources to return from the collection. Default value is - None. - :paramtype top: int - :keyword skip: An offset into the collection of the first resource to be returned. Default - value is None. - :paramtype skip: int - :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSON] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "azureResourceId": "str", # The resource ID. Required. - "region": "str" # The resource region. Required. - } - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_conversation_authoring_list_deployment_resources_request( - project_name=project_name, - top=top, - skip=skip, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "Endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "Endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - return request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized["value"] - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - def _assign_deployment_resources_initial( - self, project_name: str, body: Union[JSON, IO], **kwargs: Any - ) -> Optional[JSON]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - _json = body - - request = build_conversation_authoring_assign_deployment_resources_request( - project_name=project_name, - content_type=content_type, - api_version=self._config.api_version, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = None - response_headers = {} - if response.status_code == 200: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if response.status_code == 202: - response_headers["operation-location"] = self._deserialize( - "str", response.headers.get("operation-location") - ) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - @overload - def begin_assign_deployment_resources( - self, project_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[JSON]: - """Assign new Azure resources to a project to allow deploying new deployments to them. This API is - available only via AAD authentication and not supported via subscription key authentication. - For more details about AAD authentication, check here: - https://learn.microsoft.com/en-us/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-azure-active-directory - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/assign-deployment-resources - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param body: The new project resources info. Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: 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. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns JSON object - :rtype: ~azure.core.polling.LROPoller[JSON] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "resourcesMetadata": [ - { - "azureResourceId": "str", # Represents the Azure resource - ID. Required. - "customDomain": "str", # Represents the Azure resource - custom domain. Required. - "region": "str" # Represents the Azure resource region. - Required. - } - ] - } - - # response body for status code(s): 200 - response == { - "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the - job. Required. - "jobId": "str", # The job ID. Required. - "lastUpdatedDateTime": "2020-02-20 00:00:00", # The last date time the job - was updated. Required. - "status": "str", # The 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", - "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. The expiration date - time of the job. - "warnings": [ - { - "code": "str", # The warning code. Required. - "message": "str" # The warning message. Required. - } - ] - } - """ - - @overload - def begin_assign_deployment_resources( - self, project_name: str, body: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[JSON]: - """Assign new Azure resources to a project to allow deploying new deployments to them. This API is - available only via AAD authentication and not supported via subscription key authentication. - For more details about AAD authentication, check here: - https://learn.microsoft.com/en-us/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-azure-active-directory - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/assign-deployment-resources - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param body: The new project resources info. Required. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: 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. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns JSON object - :rtype: ~azure.core.polling.LROPoller[JSON] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the - job. Required. - "jobId": "str", # The job ID. Required. - "lastUpdatedDateTime": "2020-02-20 00:00:00", # The last date time the job - was updated. Required. - "status": "str", # The 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", - "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. The expiration date - time of the job. - "warnings": [ - { - "code": "str", # The warning code. Required. - "message": "str" # The warning message. Required. - } - ] - } - """ - - @distributed_trace - def begin_assign_deployment_resources( - self, project_name: str, body: Union[JSON, IO], **kwargs: Any - ) -> LROPoller[JSON]: - """Assign new Azure resources to a project to allow deploying new deployments to them. This API is - available only via AAD authentication and not supported via subscription key authentication. - For more details about AAD authentication, check here: - https://learn.microsoft.com/en-us/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-azure-active-directory - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/assign-deployment-resources - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param body: The new project resources info. Is either a model type or a IO type. Required. - :type body: JSON or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: 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. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns JSON object - :rtype: ~azure.core.polling.LROPoller[JSON] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the - job. Required. - "jobId": "str", # The job ID. Required. - "lastUpdatedDateTime": "2020-02-20 00:00:00", # The last date time the job - was updated. Required. - "status": "str", # The 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", - "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. The expiration date - time of the job. - "warnings": [ - { - "code": "str", # The warning code. Required. - "message": "str" # The warning message. Required. - } - ] - } - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[JSON] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._assign_deployment_resources_initial( - project_name=project_name, - body=body, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - if response.content: - deserialized = response.json() - else: - deserialized = None - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - path_format_arguments = { - "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _unassign_deployment_resources_initial( - self, project_name: str, body: Union[JSON, IO], **kwargs: Any - ) -> Optional[JSON]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - _json = body - - request = build_conversation_authoring_unassign_deployment_resources_request( - project_name=project_name, - content_type=content_type, - api_version=self._config.api_version, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = None - response_headers = {} - if response.status_code == 200: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if response.status_code == 202: - response_headers["operation-location"] = self._deserialize( - "str", response.headers.get("operation-location") - ) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - @overload - def begin_unassign_deployment_resources( - self, project_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[JSON]: - """Unassign resources from a project. This disallows deploying new deployments to these resources, - and deletes existing deployments assigned to them. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/unassign-deployment-resources - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param body: The info for the deployment resources to be deleted. Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: 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. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns JSON object - :rtype: ~azure.core.polling.LROPoller[JSON] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "assignedResourceIds": [ - "str" # Represents the assigned resource IDs to be unassigned. - Required. - ] - } - - # response body for status code(s): 200 - response == { - "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the - job. Required. - "jobId": "str", # The job ID. Required. - "lastUpdatedDateTime": "2020-02-20 00:00:00", # The last date time the job - was updated. Required. - "status": "str", # The 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", - "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. The expiration date - time of the job. - "warnings": [ - { - "code": "str", # The warning code. Required. - "message": "str" # The warning message. Required. - } - ] - } - """ - - @overload - def begin_unassign_deployment_resources( - self, project_name: str, body: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[JSON]: - """Unassign resources from a project. This disallows deploying new deployments to these resources, - and deletes existing deployments assigned to them. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/unassign-deployment-resources - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param body: The info for the deployment resources to be deleted. Required. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: 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. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns JSON object - :rtype: ~azure.core.polling.LROPoller[JSON] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the - job. Required. - "jobId": "str", # The job ID. Required. - "lastUpdatedDateTime": "2020-02-20 00:00:00", # The last date time the job - was updated. Required. - "status": "str", # The 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", - "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. The expiration date - time of the job. - "warnings": [ - { - "code": "str", # The warning code. Required. - "message": "str" # The warning message. Required. - } - ] - } - """ - - @distributed_trace - def begin_unassign_deployment_resources( - self, project_name: str, body: Union[JSON, IO], **kwargs: Any - ) -> LROPoller[JSON]: - """Unassign resources from a project. This disallows deploying new deployments to these resources, - and deletes existing deployments assigned to them. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/unassign-deployment-resources - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param body: The info for the deployment resources to be deleted. Is either a model type or a - IO type. Required. - :type body: JSON or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: 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. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns JSON object - :rtype: ~azure.core.polling.LROPoller[JSON] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the - job. Required. - "jobId": "str", # The job ID. Required. - "lastUpdatedDateTime": "2020-02-20 00:00:00", # The last date time the job - was updated. Required. - "status": "str", # The 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", - "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. The expiration date - time of the job. - "warnings": [ - { - "code": "str", # The warning code. Required. - "message": "str" # The warning message. Required. - } - ] - } - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[JSON] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._unassign_deployment_resources_initial( - project_name=project_name, - body=body, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - if response.content: - deserialized = response.json() - else: - deserialized = None - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - path_format_arguments = { - "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - + return pipeline_response + + return ItemPaged(get_next, extract_data) + @distributed_trace - def get_assign_deployment_resources_status(self, project_name: str, job_id: str, **kwargs: Any) -> JSON: - """Gets the status of an existing assign deployment resources job. + def get_model_evaluation_summary(self, project_name: str, trained_model_label: str, **kwargs: Any) -> JSON: + """Gets the evaluation summary of a trained model. The summary includes high level performance + measurements of the model e.g., F1, Precision, Recall, etc. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-assign-deployment-resources-status + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-model-evaluation-summary for more information. :param project_name: The name of the project to use. Required. :type project_name: str - :param job_id: The job ID. Required. - :type job_id: str + :param trained_model_label: The trained model label. Required. + :type trained_model_label: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -6785,57 +5123,89 @@ def get_assign_deployment_resources_status(self, project_name: str, job_id: str, # response body for status code(s): 200 response == { - "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the - job. Required. - "jobId": "str", # The job ID. Required. - "lastUpdatedDateTime": "2020-02-20 00:00:00", # The last date time the job - was updated. Required. - "status": "str", # The 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", - "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. The expiration date - time of the job. - "warnings": [ - { - "code": "str", # The warning code. Required. - "message": "str" # The warning message. Required. - } - ] + "entitiesEvaluation": { + "confusionMatrix": { + "str": { + "str": { + "normalizedValue": 0.0, # Represents + normalized value in percentages. Required. + "rawValue": 0.0 # Represents raw value. + Required. + } + } + }, + "entities": { + "str": { + "f1": 0.0, # Represents the model precision. + Required. + "falseNegativeCount": 0, # Represents the count of + false negative. Required. + "falsePositiveCount": 0, # Represents the count of + false positive. Required. + "precision": 0.0, # Represents the model recall. + Required. + "recall": 0.0, # Represents the model F1 score. + Required. + "trueNegativeCount": 0, # Represents the count of + true negative. Required. + "truePositiveCount": 0 # Represents the count of + true positive. Required. + } + }, + "macroF1": 0.0, # Represents the macro F1. Required. + "macroPrecision": 0.0, # Represents the macro precision. Required. + "macroRecall": 0.0, # Represents the macro recall. Required. + "microF1": 0.0, # Represents the micro F1. Required. + "microPrecision": 0.0, # Represents the micro precision. Required. + "microRecall": 0.0 # Represents the micro recall. Required. + }, + "intentsEvaluation": { + "confusionMatrix": { + "str": { + "str": { + "normalizedValue": 0.0, # Represents + normalized value in percentages. Required. + "rawValue": 0.0 # Represents raw value. + Required. + } + } + }, + "intents": { + "str": { + "f1": 0.0, # Represents the model precision. + Required. + "falseNegativeCount": 0, # Represents the count of + false negative. Required. + "falsePositiveCount": 0, # Represents the count of + false positive. Required. + "precision": 0.0, # Represents the model recall. + Required. + "recall": 0.0, # Represents the model F1 score. + Required. + "trueNegativeCount": 0, # Represents the count of + true negative. Required. + "truePositiveCount": 0 # Represents the count of + true positive. Required. + } + }, + "macroF1": 0.0, # Represents the macro F1. Required. + "macroPrecision": 0.0, # Represents the macro precision. Required. + "macroRecall": 0.0, # Represents the macro recall. Required. + "microF1": 0.0, # Represents the micro F1. Required. + "microPrecision": 0.0, # Represents the micro precision. Required. + "microRecall": 0.0 # Represents the micro recall. Required. + }, + "evaluationOptions": { + "kind": "str", # Optional. Represents the evaluation kind. By + default, the evaluation kind is set to percentage. Known values are: + "percentage" and "manual". + "testingSplitPercentage": 0, # Optional. Represents the testing + dataset split percentage. Only needed in case the evaluation kind is + percentage. + "trainingSplitPercentage": 0 # Optional. Represents the training + dataset split percentage. Only needed in case the evaluation kind is + percentage. + } } """ error_map = { @@ -6851,9 +5221,9 @@ def get_assign_deployment_resources_status(self, project_name: str, job_id: str, cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_conversation_authoring_get_assign_deployment_resources_status_request( + request = build_conversation_authoring_get_model_evaluation_summary_request( project_name=project_name, - job_id=job_id, + trained_model_label=trained_model_label, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6863,8 +5233,9 @@ def get_assign_deployment_resources_status(self, project_name: str, job_id: str, } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6884,15 +5255,17 @@ def get_assign_deployment_resources_status(self, project_name: str, job_id: str, return cast(JSON, deserialized) @distributed_trace - def get_unassign_deployment_resources_status(self, project_name: str, job_id: str, **kwargs: Any) -> JSON: - """Gets the status of an existing unassign deployment resources job. + def get_load_snapshot_status(self, project_name: str, trained_model_label: str, job_id: str, **kwargs: Any) -> JSON: + """Gets the status for loading a snapshot. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-unassign-deployment-resources-status + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-load-snapshot-status for more information. :param project_name: The name of the project to use. Required. :type project_name: str + :param trained_model_label: The trained model label. Required. + :type trained_model_label: str :param job_id: The job ID. Required. :type job_id: str :return: JSON object @@ -6970,8 +5343,9 @@ def get_unassign_deployment_resources_status(self, project_name: str, job_id: st cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_conversation_authoring_get_unassign_deployment_resources_status_request( + request = build_conversation_authoring_get_load_snapshot_status_request( project_name=project_name, + trained_model_label=trained_model_label, job_id=job_id, api_version=self._config.api_version, headers=_headers, @@ -6982,8 +5356,9 @@ def get_unassign_deployment_resources_status(self, project_name: str, job_id: st } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7009,7 +5384,7 @@ def list_training_jobs( """Lists the non-expired training jobs created for a project. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/list-training-jobs + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/list-training-jobs for more information. :param project_name: The name of the project to use. Required. @@ -7178,8 +5553,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7196,7 +5572,7 @@ def get_training_job_status(self, project_name: str, job_id: str, **kwargs: Any) """Gets the status for a training job. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-training-status + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-training-status for more information. :param project_name: The name of the project to use. Required. @@ -7323,8 +5699,9 @@ def get_training_job_status(self, project_name: str, job_id: str, **kwargs: Any) } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7369,8 +5746,9 @@ def _cancel_training_job_initial(self, project_name: str, job_id: str, **kwargs: } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7402,7 +5780,7 @@ def begin_cancel_training_job(self, project_name: str, job_id: str, **kwargs: An """Triggers a cancellation for a running training job. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/cancel-training-job + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/cancel-training-job for more information. :param project_name: The name of the project to use. Required. @@ -7565,7 +5943,7 @@ def get_project_deletion_job_status(self, job_id: str, **kwargs: Any) -> JSON: """Gets the status for a project deletion job. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-project-deletion-status + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-project-deletion-status for more information. :param job_id: The job ID. Required. @@ -7656,8 +6034,9 @@ def get_project_deletion_job_status(self, job_id: str, **kwargs: Any) -> JSON: } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7676,121 +6055,6 @@ def get_project_deletion_job_status(self, job_id: str, **kwargs: Any) -> JSON: return cast(JSON, deserialized) - @distributed_trace - def list_assigned_resource_deployments( - self, *, top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> Iterable[JSON]: - """Lists the deployments to which an Azure resource is assigned. This doesn't return deployments - belonging to projects owned by this resource. It only returns deployments belonging to projects - owned by other resources. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/list-assigned-resource-deployments - for more information. - - :keyword top: The maximum number of resources to return from the collection. Default value is - None. - :paramtype top: int - :keyword skip: An offset into the collection of the first resource to be returned. Default - value is None. - :paramtype skip: int - :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSON] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "deploymentsMetadata": [ - { - "deploymentExpirationDate": "2020-02-20", # Represents - deployment expiration date in the runtime. Required. - "deploymentName": "str", # Represents the deployment name. - Required. - "lastDeployedDateTime": "2020-02-20 00:00:00" # Represents - deployment last deployed time. Required. - } - ], - "projectName": "str" # Represents the project name. Required. - } - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_conversation_authoring_list_assigned_resource_deployments_request( - top=top, - skip=skip, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "Endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "Endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - return request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized["value"] - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - @distributed_trace def list_supported_languages( self, *, project_kind: str, top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any @@ -7798,11 +6062,11 @@ def list_supported_languages( """Lists the supported languages for the given project type. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-supported-languages + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-supported-languages for more information. - :keyword project_kind: The project kind. Known values are: "Conversation", "Orchestration", and - "CustomConversationSummarization". Required. + :keyword project_kind: The project kind. Known values are: "Conversation" and "Orchestration". + Required. :paramtype project_kind: str :keyword top: The maximum number of resources to return from the collection. Default value is None. @@ -7888,8 +6152,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7914,7 +6179,7 @@ def list_supported_prebuilt_entities( """Lists the supported prebuilt entities that can be used while creating composed entities. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-supported-prebuilt-entities + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-supported-prebuilt-entities for more information. :keyword language: The language to get supported prebuilt entities for. Required if @@ -8008,8 +6273,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -8028,11 +6294,11 @@ def list_training_config_versions( """Lists the support training config version for a given project type. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/list-training-config-versions + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/list-training-config-versions for more information. - :keyword project_kind: The project kind. Known values are: "Conversation", "Orchestration", and - "CustomConversationSummarization". Required. + :keyword project_kind: The project kind. Known values are: "Conversation" and "Orchestration". + Required. :paramtype project_kind: str :keyword top: The maximum number of resources to return from the collection. Default value is None. @@ -8118,8 +6384,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_patch.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_patch.py index 72d8cede5562..189be48e7c9f 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_patch.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_patch.py @@ -29,11 +29,9 @@ def _authentication_policy(credential): class ConversationAuthoringClient(GeneratedConversationAuthoringClient): - """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://docs.microsoft.com/en-us/azure/cognitive-services/language-service/overview. + """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). Further documentation + can be found in https://docs.microsoft.com/azure/cognitive-services/language-service/overview. See https://docs.microsoft.com/rest/api/language/conversational-analysis-authoring for more information about requests and responses you can pass to this client. @@ -45,12 +43,11 @@ class ConversationAuthoringClient(GeneratedConversationAuthoringClient): This can be the an instance of AzureKeyCredential if using a Language API key or a token credential from :mod:`azure.identity`. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials.TokenCredential - :keyword api_version: 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. + :keyword api_version: Api Version. Available values are "2023-04-01" and "2022-05-01". Default value is + "2023-04-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + Retry-After header is present. """ def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, TokenCredential], **kwargs: Any) -> None: diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_serialization.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_serialization.py index 4842ef347dd2..842ae727fbbc 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_serialization.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_serialization.py @@ -64,6 +64,7 @@ import isodate # type: ignore from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback +from azure.core.serialization import NULL as AzureCoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -628,7 +629,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if xml_desc.get("attr", False): if xml_ns: ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) serialized.set(xml_name, new_attr) # type: ignore continue if xml_desc.get("text", False): @@ -802,6 +803,8 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: + if data is AzureCoreNull: + return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -1268,7 +1271,7 @@ def _extract_name_from_internal_type(internal_type): xml_name = internal_type_xml_map.get("name", internal_type.__name__) xml_ns = internal_type_xml_map.get("ns", None) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) return xml_name @@ -1292,7 +1295,7 @@ def xml_key_extractor(attr, attr_desc, data): # Integrate namespace if necessary xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) # If it's an attribute, that's simple if xml_desc.get("attr", False): diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_version.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_version.py index a741dc7b69b5..59deb8c7263b 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_version.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.1.0b4" +VERSION = "1.1.0" diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/aio/_client.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/aio/_client.py index f6add27afcdf..f829627bec73 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/aio/_client.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/aio/_client.py @@ -33,8 +33,8 @@ class ConversationAuthoringClient( :type endpoint: str :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2022-10-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-04-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -43,7 +43,7 @@ class ConversationAuthoringClient( def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: _endpoint = "{Endpoint}/language" self._config = ConversationAuthoringClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) - self._client = AsyncPipelineClient(base_url=_endpoint, config=self._config, **kwargs) + self._client: AsyncPipelineClient = AsyncPipelineClient(base_url=_endpoint, config=self._config, **kwargs) self._serialize = Serializer() self._deserialize = Deserializer() @@ -82,5 +82,5 @@ async def __aenter__(self) -> "ConversationAuthoringClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/aio/_configuration.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/aio/_configuration.py index 147d60d4f496..2806c5622105 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/aio/_configuration.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,11 +13,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -35,14 +29,14 @@ class ConversationAuthoringClientConfiguration(Configuration): # pylint: disabl :type endpoint: str :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2022-10-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-04-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(ConversationAuthoringClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-10-01-preview"] = kwargs.pop("api_version", "2022-10-01-preview") + api_version: str = kwargs.pop("api_version", "2023-04-01") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/aio/_operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/aio/_operations/_operations.py index c9702018f5db..459312c91312 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/aio/_operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/aio/_operations/_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -29,17 +30,13 @@ from azure.core.utils import case_insensitive_dict from ..._operations._operations import ( - build_conversation_authoring_assign_deployment_resources_request, build_conversation_authoring_cancel_training_job_request, build_conversation_authoring_create_project_request, - build_conversation_authoring_delete_deployment_from_resources_request, build_conversation_authoring_delete_deployment_request, build_conversation_authoring_delete_project_request, build_conversation_authoring_delete_trained_model_request, build_conversation_authoring_deploy_project_request, build_conversation_authoring_export_project_request, - build_conversation_authoring_get_assign_deployment_resources_status_request, - build_conversation_authoring_get_deployment_delete_from_resources_status_request, build_conversation_authoring_get_deployment_job_status_request, build_conversation_authoring_get_deployment_request, build_conversation_authoring_get_export_project_job_status_request, @@ -51,10 +48,7 @@ build_conversation_authoring_get_swap_deployments_job_status_request, build_conversation_authoring_get_trained_model_request, build_conversation_authoring_get_training_job_status_request, - build_conversation_authoring_get_unassign_deployment_resources_status_request, build_conversation_authoring_import_project_request, - build_conversation_authoring_list_assigned_resource_deployments_request, - build_conversation_authoring_list_deployment_resources_request, build_conversation_authoring_list_deployments_request, build_conversation_authoring_list_model_evaluation_results_request, build_conversation_authoring_list_projects_request, @@ -66,7 +60,6 @@ build_conversation_authoring_load_snapshot_request, build_conversation_authoring_swap_deployments_request, build_conversation_authoring_train_request, - build_conversation_authoring_unassign_deployment_resources_request, ) from .._vendor import ConversationAuthoringClientMixinABC @@ -89,7 +82,7 @@ def list_projects( """Lists the existing projects. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/list-projects + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/list-projects for more information. :keyword top: The maximum number of resources to return from the collection. Default value is @@ -115,7 +108,7 @@ def list_projects( "lastModifiedDateTime": "2020-02-20 00:00:00", # Represents the project creation datetime. Required. "projectKind": "str", # Represents the project kind. Required. Known values - are: "Conversation", "Orchestration", and "CustomConversationSummarization". + are: "Conversation" and "Orchestration". "projectName": "str", # The new project name. Required. "description": "str", # Optional. The project description. "lastDeployedDateTime": "2020-02-20 00:00:00", # Optional. Represents the @@ -129,9 +122,7 @@ def list_projects( highest confidence, at which the prediction will automatically be changed to "None". The value of the threshold should be between 0 and 1 inclusive. Required. - }, - "storageInputContainerName": "str" # Optional. The storage container name in - case of conversation summarization. + } } """ _headers = kwargs.pop("headers", {}) or {} @@ -196,8 +187,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -216,7 +208,7 @@ async def create_project( """Creates a new project or updates an existing one. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/create-project + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/create-project for more information. :param project_name: The name of the project to use. Required. @@ -239,7 +231,7 @@ async def create_project( a language. For example, use "en" for English, "en-gb" for English (UK), "es" for Spanish etc. Required. "projectKind": "str", # Represents the project kind. Required. Known values - are: "Conversation", "Orchestration", and "CustomConversationSummarization". + are: "Conversation" and "Orchestration". "projectName": "str", # The new project name. Required. "description": "str", # Optional. The project description. "multilingual": bool, # Optional. Whether the project would be used for @@ -249,9 +241,7 @@ async def create_project( highest confidence, at which the prediction will automatically be changed to "None". The value of the threshold should be between 0 and 1 inclusive. Required. - }, - "storageInputContainerName": "str" # Optional. The storage container name in - case of conversation summarization. + } } # response body for status code(s): 200, 201 @@ -264,7 +254,7 @@ async def create_project( "lastModifiedDateTime": "2020-02-20 00:00:00", # Represents the project creation datetime. Required. "projectKind": "str", # Represents the project kind. Required. Known values - are: "Conversation", "Orchestration", and "CustomConversationSummarization". + are: "Conversation" and "Orchestration". "projectName": "str", # The new project name. Required. "description": "str", # Optional. The project description. "lastDeployedDateTime": "2020-02-20 00:00:00", # Optional. Represents the @@ -278,9 +268,7 @@ async def create_project( highest confidence, at which the prediction will automatically be changed to "None". The value of the threshold should be between 0 and 1 inclusive. Required. - }, - "storageInputContainerName": "str" # Optional. The storage container name in - case of conversation summarization. + } } """ @@ -291,7 +279,7 @@ async def create_project( """Creates a new project or updates an existing one. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/create-project + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/create-project for more information. :param project_name: The name of the project to use. Required. @@ -318,7 +306,7 @@ async def create_project( "lastModifiedDateTime": "2020-02-20 00:00:00", # Represents the project creation datetime. Required. "projectKind": "str", # Represents the project kind. Required. Known values - are: "Conversation", "Orchestration", and "CustomConversationSummarization". + are: "Conversation" and "Orchestration". "projectName": "str", # The new project name. Required. "description": "str", # Optional. The project description. "lastDeployedDateTime": "2020-02-20 00:00:00", # Optional. Represents the @@ -332,9 +320,7 @@ async def create_project( highest confidence, at which the prediction will automatically be changed to "None". The value of the threshold should be between 0 and 1 inclusive. Required. - }, - "storageInputContainerName": "str" # Optional. The storage container name in - case of conversation summarization. + } } """ @@ -343,12 +329,12 @@ async def create_project(self, project_name: str, project: Union[JSON, IO], **kw """Creates a new project or updates an existing one. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/create-project + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/create-project for more information. :param project_name: The name of the project to use. Required. :type project_name: str - :param project: The project parameters. Is either a model type or a IO type. Required. + :param project: The project parameters. Is either a JSON type or a IO type. Required. :type project: JSON or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/merge-patch+json'. Default value is None. @@ -360,6 +346,25 @@ async def create_project(self, project_name: str, project: Union[JSON, IO], **kw Example: .. code-block:: python + # JSON input template you can fill out and use as your body input. + project = { + "language": "str", # The project language. This is BCP-47 representation of + a language. For example, use "en" for English, "en-gb" for English (UK), "es" for + Spanish etc. Required. + "projectKind": "str", # Represents the project kind. Required. Known values + are: "Conversation" and "Orchestration". + "projectName": "str", # The new project name. Required. + "description": "str", # Optional. The project description. + "multilingual": bool, # Optional. Whether the project would be used for + multiple languages or not. + "settings": { + "confidenceThreshold": 0.0 # The threshold of the intent with the + highest confidence, at which the prediction will automatically be changed to + "None". The value of the threshold should be between 0 and 1 inclusive. + Required. + } + } + # response body for status code(s): 200, 201 response == { "createdDateTime": "2020-02-20 00:00:00", # Represents the project creation @@ -370,7 +375,7 @@ async def create_project(self, project_name: str, project: Union[JSON, IO], **kw "lastModifiedDateTime": "2020-02-20 00:00:00", # Represents the project creation datetime. Required. "projectKind": "str", # Represents the project kind. Required. Known values - are: "Conversation", "Orchestration", and "CustomConversationSummarization". + are: "Conversation" and "Orchestration". "projectName": "str", # The new project name. Required. "description": "str", # Optional. The project description. "lastDeployedDateTime": "2020-02-20 00:00:00", # Optional. Represents the @@ -384,9 +389,7 @@ async def create_project(self, project_name: str, project: Union[JSON, IO], **kw highest confidence, at which the prediction will automatically be changed to "None". The value of the threshold should be between 0 and 1 inclusive. Required. - }, - "storageInputContainerName": "str" # Optional. The storage container name in - case of conversation summarization. + } } """ error_map = { @@ -406,7 +409,7 @@ async def create_project(self, project_name: str, project: Union[JSON, IO], **kw content_type = content_type or "application/merge-patch+json" _json = None _content = None - if isinstance(project, (IO, bytes)): + if isinstance(project, (IOBase, bytes)): _content = project else: _json = project @@ -425,8 +428,9 @@ async def create_project(self, project_name: str, project: Union[JSON, IO], **kw } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -457,7 +461,7 @@ async def get_project(self, project_name: str, **kwargs: Any) -> JSON: """Gets the details of a project. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-project + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-project for more information. :param project_name: The name of the project to use. Required. @@ -479,7 +483,7 @@ async def get_project(self, project_name: str, **kwargs: Any) -> JSON: "lastModifiedDateTime": "2020-02-20 00:00:00", # Represents the project creation datetime. Required. "projectKind": "str", # Represents the project kind. Required. Known values - are: "Conversation", "Orchestration", and "CustomConversationSummarization". + are: "Conversation" and "Orchestration". "projectName": "str", # The new project name. Required. "description": "str", # Optional. The project description. "lastDeployedDateTime": "2020-02-20 00:00:00", # Optional. Represents the @@ -493,9 +497,7 @@ async def get_project(self, project_name: str, **kwargs: Any) -> JSON: highest confidence, at which the prediction will automatically be changed to "None". The value of the threshold should be between 0 and 1 inclusive. Required. - }, - "storageInputContainerName": "str" # Optional. The storage container name in - case of conversation summarization. + } } """ error_map = { @@ -522,8 +524,9 @@ async def get_project(self, project_name: str, **kwargs: Any) -> JSON: } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -567,8 +570,9 @@ async def _delete_project_initial(self, project_name: str, **kwargs: Any) -> Opt } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -600,7 +604,7 @@ async def begin_delete_project(self, project_name: str, **kwargs: Any) -> AsyncL """Deletes a project. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/delete-project + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/delete-project for more information. :param project_name: The name of the project to use. Required. @@ -757,8 +761,9 @@ async def _export_project_initial( } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -799,7 +804,7 @@ async def begin_export_project( """Triggers a job to export a project's data. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/export + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/export for more information. :param project_name: The name of the project to use. Required. @@ -964,7 +969,7 @@ async def _import_project_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(project, (IO, bytes)): + if isinstance(project, (IOBase, bytes)): _content = project else: _json = project @@ -984,8 +989,9 @@ async def _import_project_initial( } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1026,7 +1032,7 @@ async def begin_import_project( that project is replaced. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/import + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/import for more information. :param project_name: The name of the project to use. Required. @@ -1170,8 +1176,7 @@ async def begin_import_project( representation of a language. For example, use "en" for English, "en-gb" for English (UK), "es" for Spanish etc. Required. "projectKind": "str", # Represents the project kind. Required. Known - values are: "Conversation", "Orchestration", and - "CustomConversationSummarization". + values are: "Conversation" and "Orchestration". "projectName": "str", # The new project name. Required. "description": "str", # Optional. The project description. "multilingual": bool, # Optional. Whether the project would be used @@ -1181,9 +1186,7 @@ async def begin_import_project( with the highest confidence, at which the prediction will automatically be changed to "None". The value of the threshold should be between 0 and 1 inclusive. Required. - }, - "storageInputContainerName": "str" # Optional. The storage container - name in case of conversation summarization. + } }, "projectFileVersion": "str", # The version of the exported file. Required. "stringIndexType": "str", # Specifies the method used to interpret string @@ -1262,7 +1265,7 @@ async def begin_import_project( that project is replaced. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/import + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/import for more information. :param project_name: The name of the project to use. Required. @@ -1358,12 +1361,12 @@ async def begin_import_project( that project is replaced. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/import + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/import for more information. :param project_name: The name of the project to use. Required. :type project_name: str - :param project: The project data to import. Is either a model type or a IO type. Required. + :param project: The project data to import. Is either a JSON type or a IO type. Required. :type project: JSON or IO :keyword exported_project_format: The format of the exported project file to use. Known values are: "Conversation" and "Luis". Default value is None. @@ -1385,6 +1388,142 @@ async def begin_import_project( Example: .. code-block:: python + # The input is polymorphic. The following are possible polymorphic inputs based off + discriminator "projectKind": + + # JSON input template for discriminator value "Conversation": + exported_project_assets = { + "projectKind": "Conversation", + "entities": [ + { + "category": "str", # The category of the entity. Required. + "compositionSetting": "str", # Optional. The behavior to + follow when the entity's components overlap with each other. Known values + are: "returnLongestOverlap", "requireExactOverlap", "separateComponents", + and "combineComponents". + "list": { + "sublists": [ + { + "listKey": "str", # Optional. The + key of the sub-list. + "synonyms": [ + { + "language": "str", # + Optional. Represents the language of the synonyms. + This is BCP-47 representation of a language. For + example, use "en" for English, "en-gb" for English + (UK), "es" for Spanish etc. + "values": [ + "str" # + Optional. The list of synonyms. + ] + } + ] + } + ] + }, + "prebuilts": [ + { + "category": "str" # The prebuilt entity + category. Required. + } + ], + "regex": { + "expressions": [ + { + "language": "str", # Optional. + Represents the language of the regex expression. This is + BCP-47 representation of a language. For example, use "en" + for English, "en-gb" for English (UK), "es" for Spanish etc. + "regexKey": "str", # Optional. The + key of the regex expression. + "regexPattern": "str" # Optional. + The regex pattern. + } + ] + }, + "requiredComponents": [ + "str" # Optional. The required components. Allowed + values are 'learned', 'list', 'prebuilts' and 'regex'. + ] + } + ], + "intents": [ + { + "category": "str" # The intent category. Required. + } + ], + "utterances": [ + { + "intent": "str", # The intent of the utterance. Required. + "text": "str", # The utterance text. Required. + "dataset": "str", # Optional. The dataset for this + utterance. Allowed values are 'Train' and 'Test'. + "entities": [ + { + "category": "str", # The category of the + entity label. Required. + "length": 0, # Length for the entity text. + Required. + "offset": 0 # Start position for the entity + text. Required. + } + ], + "language": "str" # Optional. Represents the utterance's + language. This is BCP-47 representation of a language. For example, use + "en" for English, "en-gb" for English (UK), "es" for Spanish etc. + } + ] + } + + # JSON input template for discriminator value "Orchestration": + exported_project_assets = { + "projectKind": "Orchestration", + "intents": [ + { + "category": "str", # The intent category. Required. + "orchestration": exported_orchestration_options + } + ], + "utterances": [ + { + "intent": "str", # The intent of the utterance. Required. + "text": "str", # The utterance text. Required. + "dataset": "str", # Optional. The dataset for this + utterance. Allowed values are 'Train' and 'Test'. + "language": "str" # Optional. Represents the utterance's + language. This is BCP-47 representation of a language. For example, use + "en" for English, "en-gb" for English (UK), "es" for Spanish etc. + } + ] + } + + # JSON input template you can fill out and use as your body input. + project = { + "metadata": { + "language": "str", # The project language. This is BCP-47 + representation of a language. For example, use "en" for English, "en-gb" for + English (UK), "es" for Spanish etc. Required. + "projectKind": "str", # Represents the project kind. Required. Known + values are: "Conversation" and "Orchestration". + "projectName": "str", # The new project name. Required. + "description": "str", # Optional. The project description. + "multilingual": bool, # Optional. Whether the project would be used + for multiple languages or not. + "settings": { + "confidenceThreshold": 0.0 # The threshold of the intent + with the highest confidence, at which the prediction will automatically + be changed to "None". The value of the threshold should be between 0 and + 1 inclusive. Required. + } + }, + "projectFileVersion": "str", # The version of the exported file. Required. + "stringIndexType": "str", # Specifies the method used to interpret string + offsets. For additional information see https://aka.ms/text-analytics-offsets. + Required. "Utf16CodeUnit" + "assets": exported_project_assets + } + # response body for status code(s): 200 response == { "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the @@ -1511,7 +1650,7 @@ async def _train_initial(self, project_name: str, configuration: Union[JSON, IO] content_type = content_type or "application/json" _json = None _content = None - if isinstance(configuration, (IO, bytes)): + if isinstance(configuration, (IOBase, bytes)): _content = configuration else: _json = configuration @@ -1530,8 +1669,9 @@ async def _train_initial(self, project_name: str, configuration: Union[JSON, IO] } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1565,7 +1705,7 @@ async def begin_train( """Triggers a training job for a project. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/train + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/train for more information. :param project_name: The name of the project to use. Required. @@ -1706,7 +1846,7 @@ async def begin_train( """Triggers a training job for a project. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/train + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/train for more information. :param project_name: The name of the project to use. Required. @@ -1826,12 +1966,12 @@ async def begin_train( """Triggers a training job for a project. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/train + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/train for more information. :param project_name: The name of the project to use. Required. :type project_name: str - :param configuration: The training input parameters. Is either a model type or a IO type. + :param configuration: The training input parameters. Is either a JSON type or a IO type. Required. :type configuration: JSON or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -1851,6 +1991,27 @@ async def begin_train( Example: .. code-block:: python + # JSON input template you can fill out and use as your body input. + configuration = { + "modelLabel": "str", # Represents the output model label. Required. + "trainingMode": "str", # Represents the mode of the training operation. + Required. Known values are: "advanced" and "standard". + "evaluationOptions": { + "kind": "str", # Optional. Represents the evaluation kind. By + default, the evaluation kind is set to percentage. Known values are: + "percentage" and "manual". + "testingSplitPercentage": 0, # Optional. Represents the testing + dataset split percentage. Only needed in case the evaluation kind is + percentage. + "trainingSplitPercentage": 0 # Optional. Represents the training + dataset split percentage. Only needed in case the evaluation kind is + percentage. + }, + "trainingConfigVersion": "str" # Optional. Represents training config + version. By default, "latest" value is used which uses the latest released + training config version. + } + # response body for status code(s): 200 response == { "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the @@ -1998,7 +2159,7 @@ def list_deployments( """Lists the deployments belonging to a project. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/list-deployments + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/list-deployments for more information. :param project_name: The name of the project to use. Required. @@ -2026,15 +2187,8 @@ def list_deployments( "lastTrainedDateTime": "2020-02-20 00:00:00", # Represents deployment last trained time. Required. "modelId": "str", # Represents deployment modelId. Required. - "modelTrainingConfigVersion": "str", # Represents model training config + "modelTrainingConfigVersion": "str" # Represents model training config version. Required. - "assignedResources": [ - { - "region": "str", # Represents the resource region. Required. - "resourceId": "str" # Represents the Azure resource Id. - Required. - } - ] } """ _headers = kwargs.pop("headers", {}) or {} @@ -2100,8 +2254,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2133,7 +2288,7 @@ async def _swap_deployments_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(deployments, (IO, bytes)): + if isinstance(deployments, (IOBase, bytes)): _content = deployments else: _json = deployments @@ -2152,8 +2307,9 @@ async def _swap_deployments_initial( } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2187,7 +2343,7 @@ async def begin_swap_deployments( """Swaps two existing deployments with each other. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/swap-deployments + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/swap-deployments for more information. :param project_name: The name of the project to use. Required. @@ -2282,7 +2438,7 @@ async def begin_swap_deployments( """Swaps two existing deployments with each other. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/swap-deployments + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/swap-deployments for more information. :param project_name: The name of the project to use. Required. @@ -2369,13 +2525,13 @@ async def begin_swap_deployments( """Swaps two existing deployments with each other. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/swap-deployments + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/swap-deployments for more information. :param project_name: The name of the project to use. Required. :type project_name: str - :param deployments: The job object to swap two deployments. Is either a model type or a IO - type. Required. + :param deployments: The job object to swap two deployments. Is either a JSON type or a IO type. + Required. :type deployments: JSON or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -2394,6 +2550,14 @@ async def begin_swap_deployments( Example: .. code-block:: python + # JSON input template you can fill out and use as your body input. + deployments = { + "firstDeploymentName": "str", # Represents the first deployment name. + Required. + "secondDeploymentName": "str" # Represents the second deployment name. + Required. + } + # response body for status code(s): 200 response == { "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the @@ -2506,7 +2670,7 @@ async def get_deployment(self, project_name: str, deployment_name: str, **kwargs """Gets the details of a deployment. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-deployment + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-deployment for more information. :param project_name: The name of the project to use. Required. @@ -2530,15 +2694,8 @@ async def get_deployment(self, project_name: str, deployment_name: str, **kwargs "lastTrainedDateTime": "2020-02-20 00:00:00", # Represents deployment last trained time. Required. "modelId": "str", # Represents deployment modelId. Required. - "modelTrainingConfigVersion": "str", # Represents model training config + "modelTrainingConfigVersion": "str" # Represents model training config version. Required. - "assignedResources": [ - { - "region": "str", # Represents the resource region. Required. - "resourceId": "str" # Represents the Azure resource Id. - Required. - } - ] } """ error_map = { @@ -2566,8 +2723,9 @@ async def get_deployment(self, project_name: str, deployment_name: str, **kwargs } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2606,7 +2764,7 @@ async def _deploy_project_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(deployment, (IO, bytes)): + if isinstance(deployment, (IOBase, bytes)): _content = deployment else: _json = deployment @@ -2626,8 +2784,9 @@ async def _deploy_project_initial( } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2667,7 +2826,7 @@ async def begin_deploy_project( """Creates a new deployment or replaces an existing one. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/deploy-project + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/deploy-project for more information. :param project_name: The name of the project to use. Required. @@ -2695,13 +2854,7 @@ async def begin_deploy_project( # JSON input template you can fill out and use as your body input. deployment = { - "trainedModelLabel": "str", # Represents the trained model label. Required. - "assignedResourceIds": [ - "str" # Optional. Represents the resource IDs to be assigned to the - deployment."n If provided, the deployment will be rolled out to - the resources provided here as well as the original resource in which the - project is created. - ] + "trainedModelLabel": "str" # Represents the trained model label. Required. } # response body for status code(s): 200 @@ -2714,15 +2867,8 @@ async def begin_deploy_project( "lastTrainedDateTime": "2020-02-20 00:00:00", # Represents deployment last trained time. Required. "modelId": "str", # Represents deployment modelId. Required. - "modelTrainingConfigVersion": "str", # Represents model training config + "modelTrainingConfigVersion": "str" # Represents model training config version. Required. - "assignedResources": [ - { - "region": "str", # Represents the resource region. Required. - "resourceId": "str" # Represents the Azure resource Id. - Required. - } - ] } """ @@ -2739,7 +2885,7 @@ async def begin_deploy_project( """Creates a new deployment or replaces an existing one. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/deploy-project + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/deploy-project for more information. :param project_name: The name of the project to use. Required. @@ -2775,15 +2921,8 @@ async def begin_deploy_project( "lastTrainedDateTime": "2020-02-20 00:00:00", # Represents deployment last trained time. Required. "modelId": "str", # Represents deployment modelId. Required. - "modelTrainingConfigVersion": "str", # Represents model training config + "modelTrainingConfigVersion": "str" # Represents model training config version. Required. - "assignedResources": [ - { - "region": "str", # Represents the resource region. Required. - "resourceId": "str" # Represents the Azure resource Id. - Required. - } - ] } """ @@ -2794,14 +2933,14 @@ async def begin_deploy_project( """Creates a new deployment or replaces an existing one. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/deploy-project + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/deploy-project for more information. :param project_name: The name of the project to use. Required. :type project_name: str :param deployment_name: The name of the specific deployment of the project to use. Required. :type deployment_name: str - :param deployment: The new deployment info. Is either a model type or a IO type. Required. + :param deployment: The new deployment info. Is either a JSON type or a IO type. Required. :type deployment: JSON or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -2820,6 +2959,11 @@ async def begin_deploy_project( Example: .. code-block:: python + # JSON input template you can fill out and use as your body input. + deployment = { + "trainedModelLabel": "str" # Represents the trained model label. Required. + } + # response body for status code(s): 200 response == { "deploymentExpirationDate": "2020-02-20", # Represents deployment expiration @@ -2830,15 +2974,8 @@ async def begin_deploy_project( "lastTrainedDateTime": "2020-02-20 00:00:00", # Represents deployment last trained time. Required. "modelId": "str", # Represents deployment modelId. Required. - "modelTrainingConfigVersion": "str", # Represents model training config + "modelTrainingConfigVersion": "str" # Represents model training config version. Required. - "assignedResources": [ - { - "region": "str", # Represents the resource region. Required. - "resourceId": "str" # Represents the Azure resource Id. - Required. - } - ] } """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2922,8 +3059,9 @@ async def _delete_deployment_initial( } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2957,7 +3095,7 @@ async def begin_delete_deployment( """Deletes a project deployment. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/delete-deployment + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/delete-deployment for more information. :param project_name: The name of the project to use. Required. @@ -3083,250 +3221,28 @@ def get_long_running_output(pipeline_response): ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _delete_deployment_from_resources_initial( # pylint: disable=inconsistent-return-statements - self, project_name: str, deployment_name: str, body: Union[JSON, IO], **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + @distributed_trace_async + async def get_deployment_job_status( + self, project_name: str, deployment_name: str, job_id: str, **kwargs: Any + ) -> JSON: + """Gets the status of an existing deployment job. - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} + See + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-deployment-status + for more information. - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + :param project_name: The name of the project to use. Required. + :type project_name: str + :param deployment_name: The name of the specific deployment of the project to use. Required. + :type deployment_name: str + :param job_id: The job ID. Required. + :type job_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - _json = body - - request = build_conversation_authoring_delete_deployment_from_resources_request( - project_name=project_name, - deployment_name=deployment_name, - content_type=content_type, - api_version=self._config.api_version, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - response_headers = {} - response_headers["operation-location"] = self._deserialize("str", response.headers.get("operation-location")) - - if cls: - return cls(pipeline_response, None, response_headers) - - @overload - async def begin_delete_deployment_from_resources( - self, - project_name: str, - deployment_name: str, - body: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a project deployment from the specified assigned resources. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/delete-deployment-from-resources - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param deployment_name: The name of the specific deployment of the project to use. Required. - :type deployment_name: str - :param body: The options for deleting the deployment. Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: 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. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns None - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "assignedResourceIds": [ - "str" # Optional. Represents the resource IDs to delete the - deployment from."n If not provided, the deployment will be rolled - out from all the resources it is deployed to."n If provided, it - will delete the deployment only from the specified assigned resources, and - leave it for the rest. - ] - } - """ - - @overload - async def begin_delete_deployment_from_resources( - self, - project_name: str, - deployment_name: str, - body: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a project deployment from the specified assigned resources. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/delete-deployment-from-resources - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param deployment_name: The name of the specific deployment of the project to use. Required. - :type deployment_name: str - :param body: The options for deleting the deployment. Required. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: 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. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns None - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_delete_deployment_from_resources( - self, project_name: str, deployment_name: str, body: Union[JSON, IO], **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a project deployment from the specified assigned resources. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/delete-deployment-from-resources - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param deployment_name: The name of the specific deployment of the project to use. Required. - :type deployment_name: str - :param body: The options for deleting the deployment. Is either a model type or a IO type. - Required. - :type body: JSON or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: 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. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns None - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_deployment_from_resources_initial( # type: ignore - project_name=project_name, - deployment_name=deployment_name, - body=body, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - path_format_arguments = { - "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def get_deployment_delete_from_resources_status( - self, project_name: str, deployment_name: str, job_id: str, **kwargs: Any - ) -> JSON: - """Gets the status of an existing delete deployment from specific resources job. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-deployment-delete-from-resources-status - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param deployment_name: The name of the specific deployment of the project to use. Required. - :type deployment_name: str - :param job_id: The job ID. Required. - :type job_id: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python + Example: + .. code-block:: python # response body for status code(s): 200 response == { @@ -3396,7 +3312,7 @@ async def get_deployment_delete_from_resources_status( cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_conversation_authoring_get_deployment_delete_from_resources_status_request( + request = build_conversation_authoring_get_deployment_job_status_request( project_name=project_name, deployment_name=deployment_name, job_id=job_id, @@ -3409,8 +3325,9 @@ async def get_deployment_delete_from_resources_status( } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3430,19 +3347,15 @@ async def get_deployment_delete_from_resources_status( return cast(JSON, deserialized) @distributed_trace_async - async def get_deployment_job_status( - self, project_name: str, deployment_name: str, job_id: str, **kwargs: Any - ) -> JSON: - """Gets the status of an existing deployment job. + async def get_swap_deployments_job_status(self, project_name: str, job_id: str, **kwargs: Any) -> JSON: + """Gets the status of an existing swap deployment job. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-deployment-status + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-swap-deployments-status for more information. :param project_name: The name of the project to use. Required. :type project_name: str - :param deployment_name: The name of the specific deployment of the project to use. Required. - :type deployment_name: str :param job_id: The job ID. Required. :type job_id: str :return: JSON object @@ -3520,9 +3433,8 @@ async def get_deployment_job_status( cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_conversation_authoring_get_deployment_job_status_request( + request = build_conversation_authoring_get_swap_deployments_job_status_request( project_name=project_name, - deployment_name=deployment_name, job_id=job_id, api_version=self._config.api_version, headers=_headers, @@ -3533,8 +3445,9 @@ async def get_deployment_job_status( } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3554,11 +3467,11 @@ async def get_deployment_job_status( return cast(JSON, deserialized) @distributed_trace_async - async def get_swap_deployments_job_status(self, project_name: str, job_id: str, **kwargs: Any) -> JSON: - """Gets the status of an existing swap deployment job. + async def get_export_project_job_status(self, project_name: str, job_id: str, **kwargs: Any) -> JSON: + """Gets the status of an export job. Once job completes, returns the project metadata, and assets. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-swap-deployments-status + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-export-status for more information. :param project_name: The name of the project to use. Required. @@ -3619,6 +3532,8 @@ async def get_swap_deployments_job_status(self, project_name: str, job_id: str, ], "expirationDateTime": "2020-02-20 00:00:00", # Optional. The expiration date time of the job. + "resultUrl": "str", # Optional. The URL to use in order to download the + exported project. "warnings": [ { "code": "str", # The warning code. Required. @@ -3640,7 +3555,7 @@ async def get_swap_deployments_job_status(self, project_name: str, job_id: str, cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_conversation_authoring_get_swap_deployments_job_status_request( + request = build_conversation_authoring_get_export_project_job_status_request( project_name=project_name, job_id=job_id, api_version=self._config.api_version, @@ -3652,8 +3567,9 @@ async def get_swap_deployments_job_status(self, project_name: str, job_id: str, } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3673,11 +3589,11 @@ async def get_swap_deployments_job_status(self, project_name: str, job_id: str, return cast(JSON, deserialized) @distributed_trace_async - async def get_export_project_job_status(self, project_name: str, job_id: str, **kwargs: Any) -> JSON: - """Gets the status of an export job. Once job completes, returns the project metadata, and assets. + async def get_import_project_job_status(self, project_name: str, job_id: str, **kwargs: Any) -> JSON: + """Gets the status for an import. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-export-status + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-import-status for more information. :param project_name: The name of the project to use. Required. @@ -3738,8 +3654,6 @@ async def get_export_project_job_status(self, project_name: str, job_id: str, ** ], "expirationDateTime": "2020-02-20 00:00:00", # Optional. The expiration date time of the job. - "resultUrl": "str", # Optional. The URL to use in order to download the - exported project. "warnings": [ { "code": "str", # The warning code. Required. @@ -3761,7 +3675,7 @@ async def get_export_project_job_status(self, project_name: str, job_id: str, ** cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_conversation_authoring_get_export_project_job_status_request( + request = build_conversation_authoring_get_import_project_job_status_request( project_name=project_name, job_id=job_id, api_version=self._config.api_version, @@ -3773,8 +3687,9 @@ async def get_export_project_job_status(self, project_name: str, job_id: str, ** } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3793,145 +3708,26 @@ async def get_export_project_job_status(self, project_name: str, job_id: str, ** return cast(JSON, deserialized) - @distributed_trace_async - async def get_import_project_job_status(self, project_name: str, job_id: str, **kwargs: Any) -> JSON: - """Gets the status for an import. + @distributed_trace + def list_trained_models( + self, project_name: str, *, top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable[JSON]: + """Lists the trained models belonging to a project. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-import-status + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/list-trained-models for more information. :param project_name: The name of the project to use. Required. :type project_name: str - :param job_id: The job ID. Required. - :type job_id: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the - job. Required. - "jobId": "str", # The job ID. Required. - "lastUpdatedDateTime": "2020-02-20 00:00:00", # The last date time the job - was updated. Required. - "status": "str", # The 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", - "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. The expiration date - time of the job. - "warnings": [ - { - "code": "str", # The warning code. Required. - "message": "str" # The warning message. Required. - } - ] - } - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - - request = build_conversation_authoring_get_import_project_job_status_request( - project_name=project_name, - job_id=job_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) - - return cast(JSON, deserialized) - - @distributed_trace - def list_trained_models( - self, project_name: str, *, top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[JSON]: - """Lists the trained models belonging to a project. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/list-trained-models - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :keyword top: The maximum number of resources to return from the collection. Default value is - None. - :paramtype top: int - :keyword skip: An offset into the collection of the first resource to be returned. Default - value is None. - :paramtype skip: int - :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] + :keyword top: The maximum number of resources to return from the collection. Default value is + None. + :paramtype top: int + :keyword skip: An offset into the collection of the first resource to be returned. Default + value is None. + :paramtype skip: int + :return: An iterator like instance of JSON object + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -3939,6 +3735,8 @@ def list_trained_models( # response body for status code(s): 200 response == { + "hasSnapshot": bool, # The flag to indicate if the trained model has a + snapshot ready. Required. "label": "str", # The trained model label. Required. "lastTrainedDateTime": "2020-02-20 00:00:00", # The last trained date time of the model. Required. @@ -3946,10 +3744,8 @@ def list_trained_models( training request in seconds. Required. "modelExpirationDate": "2020-02-20", # The model expiration date. Required. "modelId": "str", # The model ID. Required. - "modelTrainingConfigVersion": "str", # The model training config version. + "modelTrainingConfigVersion": "str" # The model training config version. Required. - "hasSnapshot": bool # Optional. The flag to indicate if the trained model - has a snapshot ready. } """ _headers = kwargs.pop("headers", {}) or {} @@ -4015,8 +3811,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4033,7 +3830,7 @@ async def get_trained_model(self, project_name: str, trained_model_label: str, * """Gets the details of a trained model. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-trained-model + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-trained-model for more information. :param project_name: The name of the project to use. Required. @@ -4049,6 +3846,8 @@ async def get_trained_model(self, project_name: str, trained_model_label: str, * # response body for status code(s): 200 response == { + "hasSnapshot": bool, # The flag to indicate if the trained model has a + snapshot ready. Required. "label": "str", # The trained model label. Required. "lastTrainedDateTime": "2020-02-20 00:00:00", # The last trained date time of the model. Required. @@ -4056,10 +3855,8 @@ async def get_trained_model(self, project_name: str, trained_model_label: str, * training request in seconds. Required. "modelExpirationDate": "2020-02-20", # The model expiration date. Required. "modelId": "str", # The model ID. Required. - "modelTrainingConfigVersion": "str", # The model training config version. + "modelTrainingConfigVersion": "str" # The model training config version. Required. - "hasSnapshot": bool # Optional. The flag to indicate if the trained model - has a snapshot ready. } """ error_map = { @@ -4087,8 +3884,9 @@ async def get_trained_model(self, project_name: str, trained_model_label: str, * } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4114,7 +3912,7 @@ async def delete_trained_model( # pylint: disable=inconsistent-return-statement """Deletes an existing trained model. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/delete-trained-model + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/delete-trained-model for more information. :param project_name: The name of the project to use. Required. @@ -4150,8 +3948,9 @@ async def delete_trained_model( # pylint: disable=inconsistent-return-statement } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4191,8 +3990,9 @@ async def _load_snapshot_initial( } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4226,7 +4026,7 @@ async def begin_load_snapshot( """Restores the snapshot of this trained model to be the current working directory of the project. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/load-snapshot + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/load-snapshot for more information. :param project_name: The name of the project to use. Required. @@ -4367,7 +4167,7 @@ def list_model_evaluation_results( inference results for the data included in the evaluation process. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-model-evaluation-results + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-model-evaluation-results for more information. :param project_name: The name of the project to use. Required. @@ -4491,8 +4291,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4502,1196 +4303,21 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get_model_evaluation_summary(self, project_name: str, trained_model_label: str, **kwargs: Any) -> JSON: - """Gets the evaluation summary of a trained model. The summary includes high level performance - measurements of the model e.g., F1, Precision, Recall, etc. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-model-evaluation-summary - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param trained_model_label: The trained model label. Required. - :type trained_model_label: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "entitiesEvaluation": { - "confusionMatrix": { - "str": { - "str": { - "normalizedValue": 0.0, # Represents - normalized value in percentages. Required. - "rawValue": 0.0 # Represents raw value. - Required. - } - } - }, - "entities": { - "str": { - "f1": 0.0, # Represents the model precision. - Required. - "falseNegativeCount": 0, # Represents the count of - false negative. Required. - "falsePositiveCount": 0, # Represents the count of - false positive. Required. - "precision": 0.0, # Represents the model recall. - Required. - "recall": 0.0, # Represents the model F1 score. - Required. - "trueNegativeCount": 0, # Represents the count of - true negative. Required. - "truePositiveCount": 0 # Represents the count of - true positive. Required. - } - }, - "macroF1": 0.0, # Represents the macro F1. Required. - "macroPrecision": 0.0, # Represents the macro precision. Required. - "macroRecall": 0.0, # Represents the macro recall. Required. - "microF1": 0.0, # Represents the micro F1. Required. - "microPrecision": 0.0, # Represents the micro precision. Required. - "microRecall": 0.0 # Represents the micro recall. Required. - }, - "intentsEvaluation": { - "confusionMatrix": { - "str": { - "str": { - "normalizedValue": 0.0, # Represents - normalized value in percentages. Required. - "rawValue": 0.0 # Represents raw value. - Required. - } - } - }, - "intents": { - "str": { - "f1": 0.0, # Represents the model precision. - Required. - "falseNegativeCount": 0, # Represents the count of - false negative. Required. - "falsePositiveCount": 0, # Represents the count of - false positive. Required. - "precision": 0.0, # Represents the model recall. - Required. - "recall": 0.0, # Represents the model F1 score. - Required. - "trueNegativeCount": 0, # Represents the count of - true negative. Required. - "truePositiveCount": 0 # Represents the count of - true positive. Required. - } - }, - "macroF1": 0.0, # Represents the macro F1. Required. - "macroPrecision": 0.0, # Represents the macro precision. Required. - "macroRecall": 0.0, # Represents the macro recall. Required. - "microF1": 0.0, # Represents the micro F1. Required. - "microPrecision": 0.0, # Represents the micro precision. Required. - "microRecall": 0.0 # Represents the micro recall. Required. - }, - "evaluationOptions": { - "kind": "str", # Optional. Represents the evaluation kind. By - default, the evaluation kind is set to percentage. Known values are: - "percentage" and "manual". - "testingSplitPercentage": 0, # Optional. Represents the testing - dataset split percentage. Only needed in case the evaluation kind is - percentage. - "trainingSplitPercentage": 0 # Optional. Represents the training - dataset split percentage. Only needed in case the evaluation kind is - percentage. - } - } - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - - request = build_conversation_authoring_get_model_evaluation_summary_request( - project_name=project_name, - trained_model_label=trained_model_label, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) - - return cast(JSON, deserialized) - - @distributed_trace_async - async def get_load_snapshot_status( - self, project_name: str, trained_model_label: str, job_id: str, **kwargs: Any - ) -> JSON: - """Gets the status for loading a snapshot. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-load-snapshot-status - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param trained_model_label: The trained model label. Required. - :type trained_model_label: str - :param job_id: The job ID. Required. - :type job_id: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the - job. Required. - "jobId": "str", # The job ID. Required. - "lastUpdatedDateTime": "2020-02-20 00:00:00", # The last date time the job - was updated. Required. - "status": "str", # The 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", - "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. The expiration date - time of the job. - "warnings": [ - { - "code": "str", # The warning code. Required. - "message": "str" # The warning message. Required. - } - ] - } - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - - request = build_conversation_authoring_get_load_snapshot_status_request( - project_name=project_name, - trained_model_label=trained_model_label, - job_id=job_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) - - return cast(JSON, deserialized) - - @distributed_trace - def list_deployment_resources( - self, project_name: str, *, top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[JSON]: - """Lists the deployments resources assigned to the project. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/list-deployment-resources - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :keyword top: The maximum number of resources to return from the collection. Default value is - None. - :paramtype top: int - :keyword skip: An offset into the collection of the first resource to be returned. Default - value is None. - :paramtype skip: int - :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "azureResourceId": "str", # The resource ID. Required. - "region": "str" # The resource region. Required. - } - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_conversation_authoring_list_deployment_resources_request( - project_name=project_name, - top=top, - skip=skip, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "Endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "Endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - return request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized["value"] - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - async def _assign_deployment_resources_initial( - self, project_name: str, body: Union[JSON, IO], **kwargs: Any - ) -> Optional[JSON]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - _json = body - - request = build_conversation_authoring_assign_deployment_resources_request( - project_name=project_name, - content_type=content_type, - api_version=self._config.api_version, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = None - response_headers = {} - if response.status_code == 200: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if response.status_code == 202: - response_headers["operation-location"] = self._deserialize( - "str", response.headers.get("operation-location") - ) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - @overload - async def begin_assign_deployment_resources( - self, project_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[JSON]: - """Assign new Azure resources to a project to allow deploying new deployments to them. This API is - available only via AAD authentication and not supported via subscription key authentication. - For more details about AAD authentication, check here: - https://learn.microsoft.com/en-us/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-azure-active-directory - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/assign-deployment-resources - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param body: The new project resources info. Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: 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. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns JSON object - :rtype: ~azure.core.polling.AsyncLROPoller[JSON] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "resourcesMetadata": [ - { - "azureResourceId": "str", # Represents the Azure resource - ID. Required. - "customDomain": "str", # Represents the Azure resource - custom domain. Required. - "region": "str" # Represents the Azure resource region. - Required. - } - ] - } - - # response body for status code(s): 200 - response == { - "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the - job. Required. - "jobId": "str", # The job ID. Required. - "lastUpdatedDateTime": "2020-02-20 00:00:00", # The last date time the job - was updated. Required. - "status": "str", # The 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", - "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. The expiration date - time of the job. - "warnings": [ - { - "code": "str", # The warning code. Required. - "message": "str" # The warning message. Required. - } - ] - } - """ - - @overload - async def begin_assign_deployment_resources( - self, project_name: str, body: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[JSON]: - """Assign new Azure resources to a project to allow deploying new deployments to them. This API is - available only via AAD authentication and not supported via subscription key authentication. - For more details about AAD authentication, check here: - https://learn.microsoft.com/en-us/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-azure-active-directory - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/assign-deployment-resources - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param body: The new project resources info. Required. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: 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. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns JSON object - :rtype: ~azure.core.polling.AsyncLROPoller[JSON] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the - job. Required. - "jobId": "str", # The job ID. Required. - "lastUpdatedDateTime": "2020-02-20 00:00:00", # The last date time the job - was updated. Required. - "status": "str", # The 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", - "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. The expiration date - time of the job. - "warnings": [ - { - "code": "str", # The warning code. Required. - "message": "str" # The warning message. Required. - } - ] - } - """ - - @distributed_trace_async - async def begin_assign_deployment_resources( - self, project_name: str, body: Union[JSON, IO], **kwargs: Any - ) -> AsyncLROPoller[JSON]: - """Assign new Azure resources to a project to allow deploying new deployments to them. This API is - available only via AAD authentication and not supported via subscription key authentication. - For more details about AAD authentication, check here: - https://learn.microsoft.com/en-us/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-azure-active-directory - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/assign-deployment-resources - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param body: The new project resources info. Is either a model type or a IO type. Required. - :type body: JSON or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: 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. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns JSON object - :rtype: ~azure.core.polling.AsyncLROPoller[JSON] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the - job. Required. - "jobId": "str", # The job ID. Required. - "lastUpdatedDateTime": "2020-02-20 00:00:00", # The last date time the job - was updated. Required. - "status": "str", # The 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", - "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. The expiration date - time of the job. - "warnings": [ - { - "code": "str", # The warning code. Required. - "message": "str" # The warning message. Required. - } - ] - } - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[JSON] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._assign_deployment_resources_initial( - project_name=project_name, - body=body, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - if response.content: - deserialized = response.json() - else: - deserialized = None - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - path_format_arguments = { - "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _unassign_deployment_resources_initial( - self, project_name: str, body: Union[JSON, IO], **kwargs: Any - ) -> Optional[JSON]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IO, bytes)): - _content = body - else: - _json = body - - request = build_conversation_authoring_unassign_deployment_resources_request( - project_name=project_name, - content_type=content_type, - api_version=self._config.api_version, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - deserialized = None - response_headers = {} - if response.status_code == 200: - if response.content: - deserialized = response.json() - else: - deserialized = None - - if response.status_code == 202: - response_headers["operation-location"] = self._deserialize( - "str", response.headers.get("operation-location") - ) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - @overload - async def begin_unassign_deployment_resources( - self, project_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[JSON]: - """Unassign resources from a project. This disallows deploying new deployments to these resources, - and deletes existing deployments assigned to them. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/unassign-deployment-resources - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param body: The info for the deployment resources to be deleted. Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: 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. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns JSON object - :rtype: ~azure.core.polling.AsyncLROPoller[JSON] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "assignedResourceIds": [ - "str" # Represents the assigned resource IDs to be unassigned. - Required. - ] - } - - # response body for status code(s): 200 - response == { - "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the - job. Required. - "jobId": "str", # The job ID. Required. - "lastUpdatedDateTime": "2020-02-20 00:00:00", # The last date time the job - was updated. Required. - "status": "str", # The 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", - "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. The expiration date - time of the job. - "warnings": [ - { - "code": "str", # The warning code. Required. - "message": "str" # The warning message. Required. - } - ] - } - """ - - @overload - async def begin_unassign_deployment_resources( - self, project_name: str, body: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[JSON]: - """Unassign resources from a project. This disallows deploying new deployments to these resources, - and deletes existing deployments assigned to them. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/unassign-deployment-resources - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param body: The info for the deployment resources to be deleted. Required. - :type body: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: 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. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns JSON object - :rtype: ~azure.core.polling.AsyncLROPoller[JSON] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the - job. Required. - "jobId": "str", # The job ID. Required. - "lastUpdatedDateTime": "2020-02-20 00:00:00", # The last date time the job - was updated. Required. - "status": "str", # The 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", - "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. The expiration date - time of the job. - "warnings": [ - { - "code": "str", # The warning code. Required. - "message": "str" # The warning message. Required. - } - ] - } - """ - - @distributed_trace_async - async def begin_unassign_deployment_resources( - self, project_name: str, body: Union[JSON, IO], **kwargs: Any - ) -> AsyncLROPoller[JSON]: - """Unassign resources from a project. This disallows deploying new deployments to these resources, - and deletes existing deployments assigned to them. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/unassign-deployment-resources - for more information. - - :param project_name: The name of the project to use. Required. - :type project_name: str - :param body: The info for the deployment resources to be deleted. Is either a model type or a - IO type. Required. - :type body: JSON or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: 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. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns JSON object - :rtype: ~azure.core.polling.AsyncLROPoller[JSON] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the - job. Required. - "jobId": "str", # The job ID. Required. - "lastUpdatedDateTime": "2020-02-20 00:00:00", # The last date time the job - was updated. Required. - "status": "str", # The 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", - "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. The expiration date - time of the job. - "warnings": [ - { - "code": "str", # The warning code. Required. - "message": "str" # The warning message. Required. - } - ] - } - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[JSON] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._unassign_deployment_resources_initial( - project_name=project_name, - body=body, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - if response.content: - deserialized = response.json() - else: - deserialized = None - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - path_format_arguments = { - "Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get_assign_deployment_resources_status(self, project_name: str, job_id: str, **kwargs: Any) -> JSON: - """Gets the status of an existing assign deployment resources job. + async def get_model_evaluation_summary(self, project_name: str, trained_model_label: str, **kwargs: Any) -> JSON: + """Gets the evaluation summary of a trained model. The summary includes high level performance + measurements of the model e.g., F1, Precision, Recall, etc. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-assign-deployment-resources-status + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-model-evaluation-summary for more information. :param project_name: The name of the project to use. Required. :type project_name: str - :param job_id: The job ID. Required. - :type job_id: str + :param trained_model_label: The trained model label. Required. + :type trained_model_label: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -5701,57 +4327,89 @@ async def get_assign_deployment_resources_status(self, project_name: str, job_id # response body for status code(s): 200 response == { - "createdDateTime": "2020-02-20 00:00:00", # The creation date time of the - job. Required. - "jobId": "str", # The job ID. Required. - "lastUpdatedDateTime": "2020-02-20 00:00:00", # The last date time the job - was updated. Required. - "status": "str", # The 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", - "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. The expiration date - time of the job. - "warnings": [ - { - "code": "str", # The warning code. Required. - "message": "str" # The warning message. Required. - } - ] + "entitiesEvaluation": { + "confusionMatrix": { + "str": { + "str": { + "normalizedValue": 0.0, # Represents + normalized value in percentages. Required. + "rawValue": 0.0 # Represents raw value. + Required. + } + } + }, + "entities": { + "str": { + "f1": 0.0, # Represents the model precision. + Required. + "falseNegativeCount": 0, # Represents the count of + false negative. Required. + "falsePositiveCount": 0, # Represents the count of + false positive. Required. + "precision": 0.0, # Represents the model recall. + Required. + "recall": 0.0, # Represents the model F1 score. + Required. + "trueNegativeCount": 0, # Represents the count of + true negative. Required. + "truePositiveCount": 0 # Represents the count of + true positive. Required. + } + }, + "macroF1": 0.0, # Represents the macro F1. Required. + "macroPrecision": 0.0, # Represents the macro precision. Required. + "macroRecall": 0.0, # Represents the macro recall. Required. + "microF1": 0.0, # Represents the micro F1. Required. + "microPrecision": 0.0, # Represents the micro precision. Required. + "microRecall": 0.0 # Represents the micro recall. Required. + }, + "intentsEvaluation": { + "confusionMatrix": { + "str": { + "str": { + "normalizedValue": 0.0, # Represents + normalized value in percentages. Required. + "rawValue": 0.0 # Represents raw value. + Required. + } + } + }, + "intents": { + "str": { + "f1": 0.0, # Represents the model precision. + Required. + "falseNegativeCount": 0, # Represents the count of + false negative. Required. + "falsePositiveCount": 0, # Represents the count of + false positive. Required. + "precision": 0.0, # Represents the model recall. + Required. + "recall": 0.0, # Represents the model F1 score. + Required. + "trueNegativeCount": 0, # Represents the count of + true negative. Required. + "truePositiveCount": 0 # Represents the count of + true positive. Required. + } + }, + "macroF1": 0.0, # Represents the macro F1. Required. + "macroPrecision": 0.0, # Represents the macro precision. Required. + "macroRecall": 0.0, # Represents the macro recall. Required. + "microF1": 0.0, # Represents the micro F1. Required. + "microPrecision": 0.0, # Represents the micro precision. Required. + "microRecall": 0.0 # Represents the micro recall. Required. + }, + "evaluationOptions": { + "kind": "str", # Optional. Represents the evaluation kind. By + default, the evaluation kind is set to percentage. Known values are: + "percentage" and "manual". + "testingSplitPercentage": 0, # Optional. Represents the testing + dataset split percentage. Only needed in case the evaluation kind is + percentage. + "trainingSplitPercentage": 0 # Optional. Represents the training + dataset split percentage. Only needed in case the evaluation kind is + percentage. + } } """ error_map = { @@ -5767,9 +4425,9 @@ async def get_assign_deployment_resources_status(self, project_name: str, job_id cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_conversation_authoring_get_assign_deployment_resources_status_request( + request = build_conversation_authoring_get_model_evaluation_summary_request( project_name=project_name, - job_id=job_id, + trained_model_label=trained_model_label, api_version=self._config.api_version, headers=_headers, params=_params, @@ -5779,8 +4437,9 @@ async def get_assign_deployment_resources_status(self, project_name: str, job_id } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5800,15 +4459,19 @@ async def get_assign_deployment_resources_status(self, project_name: str, job_id return cast(JSON, deserialized) @distributed_trace_async - async def get_unassign_deployment_resources_status(self, project_name: str, job_id: str, **kwargs: Any) -> JSON: - """Gets the status of an existing unassign deployment resources job. + async def get_load_snapshot_status( + self, project_name: str, trained_model_label: str, job_id: str, **kwargs: Any + ) -> JSON: + """Gets the status for loading a snapshot. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-unassign-deployment-resources-status + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-load-snapshot-status for more information. :param project_name: The name of the project to use. Required. :type project_name: str + :param trained_model_label: The trained model label. Required. + :type trained_model_label: str :param job_id: The job ID. Required. :type job_id: str :return: JSON object @@ -5886,8 +4549,9 @@ async def get_unassign_deployment_resources_status(self, project_name: str, job_ cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_conversation_authoring_get_unassign_deployment_resources_status_request( + request = build_conversation_authoring_get_load_snapshot_status_request( project_name=project_name, + trained_model_label=trained_model_label, job_id=job_id, api_version=self._config.api_version, headers=_headers, @@ -5898,8 +4562,9 @@ async def get_unassign_deployment_resources_status(self, project_name: str, job_ } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5925,7 +4590,7 @@ def list_training_jobs( """Lists the non-expired training jobs created for a project. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/list-training-jobs + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/list-training-jobs for more information. :param project_name: The name of the project to use. Required. @@ -6094,8 +4759,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6112,7 +4778,7 @@ async def get_training_job_status(self, project_name: str, job_id: str, **kwargs """Gets the status for a training job. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-training-status + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-training-status for more information. :param project_name: The name of the project to use. Required. @@ -6239,8 +4905,9 @@ async def get_training_job_status(self, project_name: str, job_id: str, **kwargs } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6285,8 +4952,9 @@ async def _cancel_training_job_initial(self, project_name: str, job_id: str, **k } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6318,7 +4986,7 @@ async def begin_cancel_training_job(self, project_name: str, job_id: str, **kwar """Triggers a cancellation for a running training job. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/cancel-training-job + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/cancel-training-job for more information. :param project_name: The name of the project to use. Required. @@ -6482,7 +5150,7 @@ async def get_project_deletion_job_status(self, job_id: str, **kwargs: Any) -> J """Gets the status for a project deletion job. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-project-deletion-status + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-project-deletion-status for more information. :param job_id: The job ID. Required. @@ -6573,8 +5241,9 @@ async def get_project_deletion_job_status(self, job_id: str, **kwargs: Any) -> J } request.url = self._client.format_url(request.url, **path_format_arguments) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6593,121 +5262,6 @@ async def get_project_deletion_job_status(self, job_id: str, **kwargs: Any) -> J return cast(JSON, deserialized) - @distributed_trace - def list_assigned_resource_deployments( - self, *, top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[JSON]: - """Lists the deployments to which an Azure resource is assigned. This doesn't return deployments - belonging to projects owned by this resource. It only returns deployments belonging to projects - owned by other resources. - - See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/list-assigned-resource-deployments - for more information. - - :keyword top: The maximum number of resources to return from the collection. Default value is - None. - :paramtype top: int - :keyword skip: An offset into the collection of the first resource to be returned. Default - value is None. - :paramtype skip: int - :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "deploymentsMetadata": [ - { - "deploymentExpirationDate": "2020-02-20", # Represents - deployment expiration date in the runtime. Required. - "deploymentName": "str", # Represents the deployment name. - Required. - "lastDeployedDateTime": "2020-02-20 00:00:00" # Represents - deployment last deployed time. Required. - } - ], - "projectName": "str" # Represents the project name. Required. - } - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_conversation_authoring_list_assigned_resource_deployments_request( - top=top, - skip=skip, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "Endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "Endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - return request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized["value"] - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - @distributed_trace def list_supported_languages( self, *, project_kind: str, top: Optional[int] = None, skip: Optional[int] = None, **kwargs: Any @@ -6715,11 +5269,11 @@ def list_supported_languages( """Lists the supported languages for the given project type. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-supported-languages + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-supported-languages for more information. - :keyword project_kind: The project kind. Known values are: "Conversation", "Orchestration", and - "CustomConversationSummarization". Required. + :keyword project_kind: The project kind. Known values are: "Conversation" and "Orchestration". + Required. :paramtype project_kind: str :keyword top: The maximum number of resources to return from the collection. Default value is None. @@ -6805,8 +5359,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6831,7 +5386,7 @@ def list_supported_prebuilt_entities( """Lists the supported prebuilt entities that can be used while creating composed entities. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/get-supported-prebuilt-entities + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/get-supported-prebuilt-entities for more information. :keyword language: The language to get supported prebuilt entities for. Required if @@ -6925,8 +5480,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6945,11 +5501,11 @@ def list_training_config_versions( """Lists the support training config version for a given project type. See - https://learn.microsoft.com/rest/api/language/2022-10-01-preview/conversational-analysis-authoring/list-training-config-versions + https://learn.microsoft.com/rest/api/language/2023-04-01/conversational-analysis-authoring/list-training-config-versions for more information. - :keyword project_kind: The project kind. Known values are: "Conversation", "Orchestration", and - "CustomConversationSummarization". Required. + :keyword project_kind: The project kind. Known values are: "Conversation" and "Orchestration". + Required. :paramtype project_kind: str :keyword top: The maximum number of resources to return from the collection. Default value is None. @@ -7035,8 +5591,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/aio/_patch.py b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/aio/_patch.py index a3a5eb5fda79..851e53103b39 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/aio/_patch.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/azure/ai/language/conversations/authoring/aio/_patch.py @@ -29,11 +29,9 @@ def _authentication_policy(credential): class ConversationAuthoringClient(GeneratedConversationAuthoringClient): - """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://docs.microsoft.com/en-us/azure/cognitive-services/language-service/overview. + """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). Further documentation + can be found in https://docs.microsoft.com/azure/cognitive-services/language-service/overview. See https://docs.microsoft.com/rest/api/language/conversational-analysis-authoring for more information about requests and responses you can pass to this client. @@ -45,12 +43,11 @@ class ConversationAuthoringClient(GeneratedConversationAuthoringClient): This can be the an instance of AzureKeyCredential if using a Language API key or a token credential from :mod:`azure.identity`. :type credential: ~azure.core.credentials.AzureKeyCredential or ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: 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. + :keyword api_version: Api Version. Available values are "2023-04-01" and "2022-05-01". Default value is + "2023-04-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + Retry-After header is present. """ def __init__( diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/samples/README.md b/sdk/cognitivelanguage/azure-ai-language-conversations/samples/README.md index 0a3804ed91ab..9cae6af3254c 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/samples/README.md +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/samples/README.md @@ -26,10 +26,7 @@ These sample programs show common scenarios for the Conversational Language Unde | [sample_analyze_orchestration_app_luis_response.py][sample_analyze_orchestration_app_luis_response] and [sample_analyze_orchestration_app_luis_response_async.py][sample_analyze_orchestration_app_luis_response_async]| Analyze user utterance using an orchestration project, which selects the best candidate from one of your different apps to analyze user query (ex: Qna, Conversation, and Luis). In this case, it uses a Luis project. | | [sample_analyze_orchestration_app_qna_response.py][sample_analyze_orchestration_app_qna_response] and [sample_analyze_orchestration_app_qna_response_async.py][sample_analyze_orchestration_app_qna_response_async]| Analyze user utterance using an orchestration project, which selects the best candidate from one of your different apps to analyze user query (ex: Qna, Conversation, and Luis). In this case, it uses a Qna project. | | [sample_conv_summarization.py][sample_conv_summarization] and [sample_conv_summarization_async.py][sample_conv_summarization_async]| Summarize conversation in the form of issues and resolutions (ex: tech support conversation) | -| [sample_conv_pii_transcript_input.py][sample_conv_pii_transcript_input] and [sample_conv_pii_transcript_input_async.py][sample_conv_pii_transcript_input_async]| Extract and redact personally-identifiable info from/in conversations | -| [sample_conv_sentiment.py][sample_conv_sentiment] and [sample_conv_sentiment_async.py][sample_conv_sentiment_async]| Analyze sentiment in conversations | | [sample_manage_projects.py][sample_manage_projects] and [sample_manage_projects_async.py][sample_manage_projects_async]| Shows common authoring operations on projects. | -| [sample_assign_deployment_resources.py][sample_assign_deployment_resources] and [sample_assign_deployment_resources_async.py][sample_assign_deployment_resources_async]| Assign deployment resources to a project and deploy a project to specific deployment resources | ## Prerequisites @@ -42,7 +39,7 @@ These sample programs show common scenarios for the Conversational Language Unde 1. Install the Azure Conversational Language Understanding client library for Python with [pip][pip]: ```bash -pip install azure-ai-language-conversations --pre +pip install azure-ai-language-conversations ``` For more information about how the versioning of the SDK corresponds to the versioning of the service's API, see [here][versioning_story_readme]. @@ -85,15 +82,6 @@ what you can do with the Azure Conversational Language Understanding client libr [sample_conv_summarization]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/cognitivelanguage/azure-ai-language-conversations/samples/sample_conv_summarization.py [sample_conv_summarization_async]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/cognitivelanguage/azure-ai-language-conversations/samples/async/sample_conv_summarization_async.py -[sample_conv_pii_transcript_input]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/cognitivelanguage/azure-ai-language-conversations/samples/sample_conv_pii_transcript_input.py -[sample_conv_pii_transcript_input_async]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/cognitivelanguage/azure-ai-language-conversations/samples/async/sample_conv_pii_transcript_input_async.py - -[sample_assign_deployment_resources]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/cognitivelanguage/azure-ai-language-conversations/samples/authoring/sample_assign_deployment_resources.py -[sample_assign_deployment_resources_async]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/cognitivelanguage/azure-ai-language-conversations/samples/async/authoring/sample_assign_deployment_resources_async.py - -[sample_conv_sentiment]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/cognitivelanguage/azure-ai-language-conversations/samples/sample_conv_sentiment.py -[sample_conv_sentiment_async]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/cognitivelanguage/azure-ai-language-conversations/samples/async/sample_conv_sentiment_async.py - [sample_manage_projects]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/cognitivelanguage/azure-ai-language-conversations/samples/authoring/sample_manage_projects.py [sample_manage_projects_async]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/cognitivelanguage/azure-ai-language-conversations/samples/async/authoring/sample_manage_projects_async.py diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/samples/async/authoring/sample_assign_deployment_resources_async.py b/sdk/cognitivelanguage/azure-ai-language-conversations/samples/async/authoring/sample_assign_deployment_resources_async.py deleted file mode 100644 index 8129c7a6aef6..000000000000 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/samples/async/authoring/sample_assign_deployment_resources_async.py +++ /dev/null @@ -1,108 +0,0 @@ -# coding=utf-8 -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ - -""" -FILE: sample_assign_deployment_resources_async.py - -DESCRIPTION: - This sample demonstrates how to assign deployment resources to a project and deploy a project - to specific deployment resources. Assigning resources allow you to train your model in one - resource and deploy them to other assigned resources. - - Assigning deployment resources requires you to authenticate with AAD, you cannot assign - deployment resources with key based authentication. You must have the role Cognitive Services - Language Owner assigned to the authoring resource and the target resources. - -USAGE: - python sample_assign_deployment_resources_async.py - - Set the environment variables with your own values before running the sample: - 1) AZURE_CONVERSATIONS_ENDPOINT - endpoint for your CLU resource. - 2) AZURE_CLIENT_ID - the client ID of your active directory application. - 3) AZURE_TENANT_ID - the tenant ID of your active directory application. - 4) AZURE_CLIENT_SECRET - the secret of your active directory application. -""" - -import asyncio - - -async def sample_assign_resources(): - import os - from azure.identity.aio import DefaultAzureCredential - from azure.ai.language.conversations.authoring.aio import ( - ConversationAuthoringClient, - ) - - clu_endpoint = os.environ["AZURE_CONVERSATIONS_ENDPOINT"] - credential = DefaultAzureCredential() - - client = ConversationAuthoringClient(clu_endpoint, credential=credential) - project_name = "test_project" - - async with client: - poller = await client.begin_assign_deployment_resources( - project_name=project_name, - body={ - "resourcesMetadata": [ - { - "azureResourceId": "/subscriptions//resourceGroups//providers/Microsoft.CognitiveServices/accounts/", - "customDomain": ".cognitiveservices.azure.com", - "region": "", - }, - { - "azureResourceId": "/subscriptions//resourceGroups//providers/Microsoft.CognitiveServices/accounts/", - "customDomain": ".cognitiveservices.azure.com", - "region": "", - }, - ], - }, - ) - - response = await poller.result() - print(response) - - -async def sample_deploy_model(): - import os - from azure.identity.aio import DefaultAzureCredential - from azure.ai.language.conversations.authoring.aio import ( - ConversationAuthoringClient, - ) - - clu_endpoint = os.environ["AZURE_CONVERSATIONS_ENDPOINT"] - - project_name = "test_project" - deployment_name = "production" - credential = DefaultAzureCredential() - client = ConversationAuthoringClient(clu_endpoint, credential=credential) - - async with client: - client = ConversationAuthoringClient(clu_endpoint, credential) - - ## If assigned resource Ids are not provided, project is deployed to all assigned resources - - poller = await client.begin_deploy_project( - project_name=project_name, - deployment_name=deployment_name, - deployment={ - "trainedModelLabel": "sample", - "assignedResourceIds": [ - "/subscriptions//resourceGroups//providers/Microsoft.CognitiveServices/accounts/", - "/subscriptions//resourceGroups//providers/Microsoft.CognitiveServices/accounts/", - ], - }, - ) - response = await poller.result() - print(response) - - -async def main(): - await sample_assign_resources() - await sample_deploy_model() - - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/samples/async/sample_conv_pii_transcript_input_async.py b/sdk/cognitivelanguage/azure-ai-language-conversations/samples/async/sample_conv_pii_transcript_input_async.py deleted file mode 100644 index 988c85f972a4..000000000000 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/samples/async/sample_conv_pii_transcript_input_async.py +++ /dev/null @@ -1,132 +0,0 @@ -# coding=utf-8 -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ - -""" -FILE: sample_conv_pii_transcript_input_async.py - -DESCRIPTION: - This sample demonstrates how to analyze a conversation for PII (personally identifiable information). - - For more info about how to setup a CLU conversation project, see the README. - -USAGE: - python sample_conv_pii_transcript_input_async.py - - Set the environment variables with your own values before running the sample: - 1) AZURE_CONVERSATIONS_ENDPOINT - endpoint for your CLU resource. - 2) AZURE_CONVERSATIONS_KEY - API key for your CLU resource. -""" - -import asyncio - -async def sample_conv_pii_transcript_input_async(): - # [START analyze_conversation_app] - # import libraries - import os - from azure.core.credentials import AzureKeyCredential - - from azure.ai.language.conversations.aio import ConversationAnalysisClient - - # get secrets - endpoint = os.environ["AZURE_CONVERSATIONS_ENDPOINT"] - key = os.environ["AZURE_CONVERSATIONS_KEY"] - - # analyze quey - client = ConversationAnalysisClient(endpoint, AzureKeyCredential(key)) - async with client: - - poller = await client.begin_conversation_analysis( - task={ - "displayName": "Analyze PII in conversation", - "analysisInput": { - "conversations": [ - { - "conversationItems": [ - { - "id": "1", - "participantId": "0", - "modality": "transcript", - "text": "It is john doe.", - "lexical": "It is john doe", - "itn": "It is john doe", - "maskedItn": "It is john doe" - }, - { - "id": "2", - "participantId": "1", - "modality": "transcript", - "text": "Yes, 633-27-8199 is my phone", - "lexical": "yes six three three two seven eight one nine nine is my phone", - "itn": "yes 633278199 is my phone", - "maskedItn": "yes 633278199 is my phone", - }, - { - "id": "3", - "participantId": "1", - "modality": "transcript", - "text": "j.doe@yahoo.com is my email", - "lexical": "j dot doe at yahoo dot com is my email", - "maskedItn": "j.doe@yahoo.com is my email", - "itn": "j.doe@yahoo.com is my email", - } - ], - "modality": "transcript", - "id": "1", - "language": "en" - } - ] - }, - "tasks": [ - { - "kind": "ConversationalPIITask", - "parameters": { - "redactionSource": "lexical", - "piiCategories": [ - "all" - ] - } - } - ] - } - ) - - # view result - result = await poller.result() - task_result = result['tasks']['items'][0] - print("... view task status ...") - print(f"status: {task_result['status']}") - conv_pii_result = task_result['results'] - if conv_pii_result['errors']: - print("... errors occurred ...") - for error in conv_pii_result['errors']: - print(error) - else: - conversation_result = conv_pii_result['conversations'][0] - if conversation_result['warnings']: - print("... view warnings ...") - for warning in conversation_result['warnings']: - print(warning) - else: - print("... view task result ...") - for conversation in conversation_result['conversationItems']: - print(f"conversation id: {conversation['id']}") - print("... entities ...") - for entity in conversation['entities']: - print(f"text: {entity['text']}") - print(f"category: {entity['category']}") - print(f"confidence: {entity['confidenceScore']}") - print(f"offset: {entity['offset']}") - print(f"length: {entity['length']}") - - - # [END analyze_conversation_app] - - -async def main(): - await sample_conv_pii_transcript_input_async() - -if __name__ == '__main__': - asyncio.run(main()) diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/samples/async/sample_conv_sentiment_async.py b/sdk/cognitivelanguage/azure-ai-language-conversations/samples/async/sample_conv_sentiment_async.py deleted file mode 100644 index 72d7fe4c0d3d..000000000000 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/samples/async/sample_conv_sentiment_async.py +++ /dev/null @@ -1,120 +0,0 @@ -# coding=utf-8 -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ - -""" -FILE: sample_conv_sentiment_async.py - -DESCRIPTION: - This sample demonstrates how to analyze a conversation for sentiment analysis. - - For more info about how to setup a CLU conversation project, see the README. - -USAGE: - python sample_conv_sentiment_async.py - - Set the environment variables with your own values before running the sample: - 1) AZURE_CONVERSATIONS_ENDPOINT - endpoint for your CLU resource. - 2) AZURE_CONVERSATIONS_KEY - API key for your CLU resource. -""" - -import asyncio - - -async def sample_conv_sentiment_async(): - # import libraries - import os - from azure.core.credentials import AzureKeyCredential - from azure.ai.language.conversations.aio import ConversationAnalysisClient - - # get secrets - endpoint = os.environ["AZURE_CONVERSATIONS_ENDPOINT"] - key = os.environ["AZURE_CONVERSATIONS_KEY"] - - # analyze query - client = ConversationAnalysisClient(endpoint, AzureKeyCredential(key)) - async with client: - - poller = await client.begin_conversation_analysis( - task={ - "displayName": "Analyze sentiment in conversation", - "analysisInput": { - "conversations": [ - { - "conversationItems": [ - { - "id": "1", - "participantId": "Customer", - "modality": "transcript", - "text": "My cat doesn't like the food, Can I get a refund?", - "lexical": "my cat doesn't like the food can i get a refund", - }, - { - "id": "2", - "participantId": "Agent", - "modality": "transcript", - "text": "Sure. You have been refunded. Have a nice day.", - "lexical": "sure you have been refunded have a nice day", - }, - { - "id": "3", - "participantId": "Customer", - "modality": "transcript", - "text": "Thanks for your help", - "lexical": "thanks for your help", - }, - ], - "modality": "transcript", - "id": "conversation1", - "language": "en", - } - ] - }, - "tasks": [ - { - "kind": "ConversationalSentimentTask", - "parameters": { - "modelVersion": "2022-10-01-preview", - "predictionSource": "text", - }, - } - ], - } - ) - - # view result - result = await poller.result() - task_result = result["tasks"]["items"][0] - print("... view task status ...") - print(f"status: {task_result['status']}") - conv_sentiment_result = task_result["results"] - if conv_sentiment_result["errors"]: - print("... errors occurred ...") - for error in conv_sentiment_result["errors"]: - print(error) - else: - conversation_result = conv_sentiment_result["conversations"][0] - if conversation_result["warnings"]: - print("... view warnings ...") - for warning in conversation_result["warnings"]: - print(warning) - else: - print("... view task result ...") - for conversation_item in conversation_result["conversationItems"]: - confidence_score = conversation_item["confidenceScores"] - print(f"id: {conversation_item['id']}") - print(f"participantId: {conversation_item['participantId']}") - print(f"sentiment: {conversation_item['sentiment']}") - print( - f"confidenceScores: positive={confidence_score['positive']} " - f"neutral={confidence_score['neutral']} negative={confidence_score['negative']}" - ) - - -async def main(): - await sample_conv_sentiment_async() - -if __name__ == '__main__': - asyncio.run(main()) diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/samples/authoring/sample_assign_deployment_resources.py b/sdk/cognitivelanguage/azure-ai-language-conversations/samples/authoring/sample_assign_deployment_resources.py deleted file mode 100644 index 9db76662d0f0..000000000000 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/samples/authoring/sample_assign_deployment_resources.py +++ /dev/null @@ -1,96 +0,0 @@ -# coding=utf-8 -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ - -""" -FILE: sample_assign_deployment_resources.py - -DESCRIPTION: - This sample demonstrates how to assign deployment resources to a project and deploy a project - to specific deployment resources. Assigning resources allow you to train your model in one - resource and deploy them to other assigned resources. - - Assigning deployment resources requires you to authenticate with AAD, you cannot assign - deployment resources with key based authentication. You must have the role Cognitive Services - Language Owner assigned to the authoring resource and the target resources. - -USAGE: - python sample_assign_deployment_resources.py - - Set the environment variables with your own values before running the sample: - 1) AZURE_CONVERSATIONS_ENDPOINT - endpoint for your CLU resource. - 2) AZURE_CLIENT_ID - the client ID of your active directory application. - 3) AZURE_TENANT_ID - the tenant ID of your active directory application. - 4) AZURE_CLIENT_SECRET - the secret of your active directory application. -""" - - -def sample_assign_resources(): - import os - from azure.identity import DefaultAzureCredential - from azure.ai.language.conversations.authoring import ConversationAuthoringClient - - clu_endpoint = os.environ["AZURE_CONVERSATIONS_ENDPOINT"] - credential = DefaultAzureCredential() - - client = ConversationAuthoringClient(clu_endpoint, credential=credential) - - project_name = "test_project" - - poller = client.begin_assign_deployment_resources( - project_name=project_name, - body={ - "resourcesMetadata": [ - { - "azureResourceId": "/subscriptions//resourceGroups//providers/Microsoft.CognitiveServices/accounts/", - "customDomain": ".cognitiveservices.azure.com", - "region": "", - }, - { - "azureResourceId": "/subscriptions//resourceGroups//providers/Microsoft.CognitiveServices/accounts/", - "customDomain": ".cognitiveservices.azure.com", - "region": "", - }, - ], - }, - ) - - response = poller.result() - print(response) - - -def sample_deploy_model(): - import os - from azure.identity import DefaultAzureCredential - from azure.ai.language.conversations.authoring import ConversationAuthoringClient - - clu_endpoint = os.environ["AZURE_CONVERSATIONS_ENDPOINT"] - credential = DefaultAzureCredential() - - project_name = "test_project" - deployment_name = "production" - - client = ConversationAuthoringClient(clu_endpoint, credential=credential) - - ## If assigned resource Ids are not provided, project is deployed to all assigned resources - - poller = client.begin_deploy_project( - project_name=project_name, - deployment_name=deployment_name, - deployment={ - "trainedModelLabel": "sample", - "assignedResourceIds": [ - "/subscriptions//resourceGroups//providers/Microsoft.CognitiveServices/accounts/", - "/subscriptions//resourceGroups//providers/Microsoft.CognitiveServices/accounts/", - ], - }, - ) - response = poller.result() - print(response) - - -if __name__ == "__main__": - sample_assign_resources() - sample_deploy_model() diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/samples/sample_conv_pii_transcript_input.py b/sdk/cognitivelanguage/azure-ai-language-conversations/samples/sample_conv_pii_transcript_input.py deleted file mode 100644 index 9204d7274dea..000000000000 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/samples/sample_conv_pii_transcript_input.py +++ /dev/null @@ -1,127 +0,0 @@ -# coding=utf-8 -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ - -""" -FILE: sample_conv_pii_transcript_input.py - -DESCRIPTION: - This sample demonstrates how to analyze a conversation for PII (personally identifiable information). - - For more info about how to setup a CLU conversation project, see the README. - -USAGE: - python sample_conv_pii_transcript_input.py - - Set the environment variables with your own values before running the sample: - 1) AZURE_CONVERSATIONS_ENDPOINT - endpoint for your CLU resource. - 2) AZURE_CONVERSATIONS_KEY - API key for your CLU resource. -""" - -def sample_conv_pii_transcript_input(): - # [START analyze_conversation_app] - # import libraries - import os - from azure.core.credentials import AzureKeyCredential - - from azure.ai.language.conversations import ConversationAnalysisClient - - # get secrets - endpoint = os.environ["AZURE_CONVERSATIONS_ENDPOINT"] - key = os.environ["AZURE_CONVERSATIONS_KEY"] - - # analyze quey - client = ConversationAnalysisClient(endpoint, AzureKeyCredential(key)) - with client: - - poller = client.begin_conversation_analysis( - task={ - "displayName": "Analyze PII in conversation", - "analysisInput": { - "conversations": [ - { - "conversationItems": [ - { - "id": "1", - "participantId": "0", - "modality": "transcript", - "text": "It is john doe.", - "lexical": "It is john doe", - "itn": "It is john doe", - "maskedItn": "It is john doe" - }, - { - "id": "2", - "participantId": "1", - "modality": "transcript", - "text": "Yes, 633-27-8199 is my phone", - "lexical": "yes six three three two seven eight one nine nine is my phone", - "itn": "yes 633278199 is my phone", - "maskedItn": "yes 633278199 is my phone", - }, - { - "id": "3", - "participantId": "1", - "modality": "transcript", - "text": "j.doe@yahoo.com is my email", - "lexical": "j dot doe at yahoo dot com is my email", - "maskedItn": "j.doe@yahoo.com is my email", - "itn": "j.doe@yahoo.com is my email", - } - ], - "modality": "transcript", - "id": "1", - "language": "en" - } - ] - }, - "tasks": [ - { - "kind": "ConversationalPIITask", - "parameters": { - "redactionSource": "lexical", - "piiCategories": [ - "all" - ] - } - } - ] - } - ) - - # view result - result = poller.result() - task_result = result["tasks"]["items"][0] - print("... view task status ...") - print(f"status: {task_result['status']}") - conv_pii_result = task_result["results"] - if conv_pii_result["errors"]: - print("... errors occurred ...") - for error in conv_pii_result["errors"]: - print(error) - else: - conversation_result = conv_pii_result["conversations"][0] - if conversation_result["warnings"]: - print("... view warnings ...") - for warning in conversation_result["warnings"]: - print(warning) - else: - print("... view task result ...") - for conversation in conversation_result["conversationItems"]: - print(f"conversation id: {conversation['id']}") - print("... entities ...") - for entity in conversation["entities"]: - print(f"text: {entity['text']}") - print(f"category: {entity['category']}") - print(f"confidence: {entity['confidenceScore']}") - print(f"offset: {entity['offset']}") - print(f"length: {entity['length']}") - - - # [END analyze_conversation_app] - - -if __name__ == '__main__': - sample_conv_pii_transcript_input() diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/samples/sample_conv_sentiment.py b/sdk/cognitivelanguage/azure-ai-language-conversations/samples/sample_conv_sentiment.py deleted file mode 100644 index 9d7ce34dfd9b..000000000000 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/samples/sample_conv_sentiment.py +++ /dev/null @@ -1,115 +0,0 @@ -# coding=utf-8 -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ - -""" -FILE: sample_conv_sentiment.py - -DESCRIPTION: - This sample demonstrates how to analyze a conversation for sentiment analysis. - - For more info about how to setup a CLU conversation project, see the README. - -USAGE: - python sample_conv_sentiment.py - - Set the environment variables with your own values before running the sample: - 1) AZURE_CONVERSATIONS_ENDPOINT - endpoint for your CLU resource. - 2) AZURE_CONVERSATIONS_KEY - API key for your CLU resource. -""" - - -def sample_conv_sentiment(): - # import libraries - import os - from azure.core.credentials import AzureKeyCredential - from azure.ai.language.conversations import ConversationAnalysisClient - - # get secrets - endpoint = os.environ["AZURE_CONVERSATIONS_ENDPOINT"] - key = os.environ["AZURE_CONVERSATIONS_KEY"] - - # analyze query - client = ConversationAnalysisClient(endpoint, AzureKeyCredential(key)) - with client: - - poller = client.begin_conversation_analysis( - task={ - "displayName": "Analyze sentiment in conversation", - "analysisInput": { - "conversations": [ - { - "conversationItems": [ - { - "id": "1", - "participantId": "Customer", - "modality": "transcript", - "text": "My cat doesn't like the food, Can I get a refund?", - "lexical": "my cat doesn't like the food can i get a refund", - }, - { - "id": "2", - "participantId": "Agent", - "modality": "transcript", - "text": "Sure. You have been refunded. Have a nice day.", - "lexical": "sure you have been refunded have a nice day", - }, - { - "id": "3", - "participantId": "Customer", - "modality": "transcript", - "text": "Thanks for your help", - "lexical": "thanks for your help", - }, - ], - "modality": "transcript", - "id": "conversation1", - "language": "en", - } - ] - }, - "tasks": [ - { - "kind": "ConversationalSentimentTask", - "parameters": { - "modelVersion": "2022-10-01-preview", - "predictionSource": "text", - }, - } - ], - } - ) - - # view result - result = poller.result() - task_result = result["tasks"]["items"][0] - print("... view task status ...") - print(f"status: {task_result['status']}") - conv_sentiment_result = task_result["results"] - if conv_sentiment_result["errors"]: - print("... errors occurred ...") - for error in conv_sentiment_result["errors"]: - print(error) - else: - conversation_result = conv_sentiment_result["conversations"][0] - if conversation_result["warnings"]: - print("... view warnings ...") - for warning in conversation_result["warnings"]: - print(warning) - else: - print("... view task result ...") - for conversation_item in conversation_result["conversationItems"]: - confidence_score = conversation_item["confidenceScores"] - print(f"id: {conversation_item['id']}") - print(f"participantId: {conversation_item['participantId']}") - print(f"sentiment: {conversation_item['sentiment']}") - print( - f"confidenceScores: positive={confidence_score['positive']} " - f"neutral={confidence_score['neutral']} negative={confidence_score['negative']}" - ) - - -if __name__ == "__main__": - sample_conv_sentiment() diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/swagger/README.md b/sdk/cognitivelanguage/azure-ai-language-conversations/swagger/README.md index d699c736a88a..517197fb4069 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/swagger/README.md +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/swagger/README.md @@ -33,7 +33,7 @@ no-namespace-folders: true python: true openapi-type: data-plane version-tolerant: true -package-version: 1.1.0b4 +package-version: 1.1.0 add-credential: true credential-scopes: https://cognitiveservices.azure.com/.default black: true @@ -45,26 +45,26 @@ modelerfour: ```yaml batch: - - tag: release_runtime_1_1_preview - - tag: release_authoring_1_1_preview + - tag: release_runtime_1_1 + - tag: release_authoring_1_1 ``` ## Runtime -These settings apply only when `--tag=release_runtime_1_1_preview` is specified on the command line. +These settings apply only when `--tag=release_runtime_1_1` is specified on the command line. -```yaml $(tag) == 'release_runtime_1_1_preview' -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/10c39b3174718aba55e53cb7b0ae1cef45b18368/specification/cognitiveservices/data-plane/Language/preview/2022-10-01-preview/analyzeconversations.json +```yaml $(tag) == 'release_runtime_1_1' +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/53240ebc58b3c4e99de723194032064db1d97e63/specification/cognitiveservices/data-plane/Language/stable/2023-04-01/analyzeconversations.json output-folder: ../azure/ai/language/conversations title: ConversationAnalysisClient ``` ## Authoring -These settings apply only when `--tag=release_authoring_1_1_preview` is specified on the command line. +These settings apply only when `--tag=release_authoring_1_1` is specified on the command line. -```yaml $(tag) == 'release_authoring_1_1_preview' -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/10c39b3174718aba55e53cb7b0ae1cef45b18368/specification/cognitiveservices/data-plane/Language/preview/2022-10-01-preview/analyzeconversations-authoring.json +```yaml $(tag) == 'release_authoring_1_1' +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/53240ebc58b3c4e99de723194032064db1d97e63/specification/cognitiveservices/data-plane/Language/stable/2023-04-01/analyzeconversations-authoring.json output-folder: ../azure/ai/language/conversations/authoring title: ConversationAuthoringClient ``` @@ -184,9 +184,9 @@ directive: ### Runtime API Directives -```yaml $(tag) == 'release_runtime_1_1_preview' -# Give analyze job LRO a return type +```yaml $(tag) == 'release_runtime_1_1' directive: + # Give analyze job LRO a return type - where-operation: AnalyzeConversation_SubmitJob transform: > $["responses"]["200"] = { @@ -195,63 +195,39 @@ directive: "$ref": "#/definitions/AnalyzeConversationJobState" } }; -``` - -```yaml $(tag) == 'release_runtime_1_1_preview' -# Rename Runtime client operation -directive: + # Rename Runtime client operation - rename-operation: from: ConversationAnalysis_AnalyzeConversation to: AnalyzeConversation -``` - -```yaml $(tag) == 'release_runtime_1_1_preview' -# Rename Runtime client async operation -directive: + # Rename Runtime client async operation - rename-operation: from: AnalyzeConversation_SubmitJob to: ConversationAnalysis -``` - -```yaml $(tag) == 'release_runtime_1_1_preview' -# Rename analyze_conversation `body` to `tasks` -directive: - - from: swagger-document - where: $["paths"]["/:analyze-conversations"]["post"] - transform: > - $["parameters"][1]["x-ms-client-name"] = "task"; -``` - -```yaml $(tag) == 'release_runtime_1_1_preview' -# Rename begin_conversation_analysis `body` to `tasks` -directive: - - from: swagger-document - where: $["paths"]["/analyze-conversations/jobs"]["post"] - transform: > - $["parameters"][1]["x-ms-client-name"] = "task"; -``` - -```yaml $(tag) == 'release_runtime_1_1_preview' -# Remove async GET operation status -directive: - - from: swagger-document - where: $["paths"] - transform: > - delete $["/analyze-conversations/jobs/{jobId}"]; -``` - -```yaml $(tag) == 'release_runtime_1_1_preview' -# Remove async cancel operation -directive: - - from: swagger-document - where: $["paths"] - transform: > - delete $["/analyze-conversations/jobs/{jobId}:cancel"]; + # Rename analyze_conversation `body` to `tasks` + - from: swagger-document + where: $["paths"]["/:analyze-conversations"]["post"] + transform: > + $["parameters"][1]["x-ms-client-name"] = "task"; + # Rename begin_conversation_analysis `body` to `tasks` + - from: swagger-document + where: $["paths"]["/analyze-conversations/jobs"]["post"] + transform: > + $["parameters"][1]["x-ms-client-name"] = "task"; + # Remove async GET operation status + - from: swagger-document + where: $["paths"] + transform: > + delete $["/analyze-conversations/jobs/{jobId}"]; + # Remove async cancel operation + - from: swagger-document + where: $["paths"] + transform: > + delete $["/analyze-conversations/jobs/{jobId}:cancel"]; ``` ### Authoring API Directives -```yaml $(tag) == 'release_authoring_1_1_preview' +```yaml $(tag) == 'release_authoring_1_1' # Give LROs return types directive: - where-operation: ConversationalAnalysisAuthoring_CancelTrainingJob @@ -318,14 +294,6 @@ directive: "$ref": "#/definitions/ConversationalAnalysisAuthoringTrainingJobState" } }; - - where-operation: ConversationalAnalysisAuthoring_AssignDeploymentResources - transform: > - $["responses"]["200"] = { - "description": "mock schema to get poller response when calling .result()", - "schema": { - "$ref": "#/definitions/ConversationalAnalysisAuthoringDeploymentResourcesJobState" - } - }; - where-operation: ConversationalAnalysisAuthoring_LoadSnapshot transform: > $["responses"]["200"] = { @@ -334,19 +302,7 @@ directive: "$ref": "#/definitions/ConversationalAnalysisAuthoringLoadSnapshotJobState" } }; - - where-operation: ConversationalAnalysisAuthoring_UnassignDeploymentResources - transform: > - $["responses"]["200"] = { - "description": "mock schema to get poller response when calling .result()", - "schema": { - "$ref": "#/definitions/ConversationalAnalysisAuthoringDeploymentResourcesJobState" - } - }; -``` - -```yaml $(tag) == 'release_authoring_1_1_preview' -# Rename `body` param for operations -directive: + # Rename `body` param for operations - where-operation: ConversationalAnalysisAuthoring_DeployProject transform: > $.parameters[2]["x-ms-client-name"] = "deployment"; @@ -362,11 +318,7 @@ directive: - where-operation: ConversationalAnalysisAuthoring_CreateProject transform: > $.parameters[1]["x-ms-client-name"] = "project"; -``` - -```yaml $(tag) == 'release_authoring_1_1_preview' -# Rename Authoring client operations -directive: + # Rename Authoring client operations - rename-operation: from: ConversationalAnalysisAuthoring_ListProjects to: ListProjects @@ -451,34 +403,10 @@ directive: - rename-operation: from: ConversationalAnalysisAuthoring_ListTrainingConfigVersions to: ListTrainingConfigVersions - - rename-operation: - from: ConversationalAnalysisAuthoring_DeleteDeploymentFromResources - to: DeleteDeploymentFromResources - - rename-operation: - from: ConversationalAnalysisAuthoring_GetDeploymentDeleteFromResourcesStatus - to: GetDeploymentDeleteFromResourcesStatus - rename-operation: from: ConversationalAnalysisAuthoring_LoadSnapshot to: LoadSnapshot - rename-operation: from: ConversationalAnalysisAuthoring_GetLoadSnapshotStatus to: GetLoadSnapshotStatus - - rename-operation: - from: ConversationalAnalysisAuthoring_ListDeploymentResources - to: ListDeploymentResources - - rename-operation: - from: ConversationalAnalysisAuthoring_AssignDeploymentResources - to: AssignDeploymentResources - - rename-operation: - from: ConversationalAnalysisAuthoring_GetAssignDeploymentResourcesStatus - to: GetAssignDeploymentResourcesStatus - - rename-operation: - from: ConversationalAnalysisAuthoring_UnassignDeploymentResources - to: UnassignDeploymentResources - - rename-operation: - from: ConversationalAnalysisAuthoring_GetUnassignDeploymentResourcesStatus - to: GetUnassignDeploymentResourcesStatus - - rename-operation: - from: ConversationalAnalysisAuthoring_ListAssignedResourceDeployments - to: ListAssignedResourceDeployments -``` +``` \ No newline at end of file diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conv_pii_transcript_input.py b/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conv_pii_transcript_input.py deleted file mode 100644 index 9e33f3850f16..000000000000 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conv_pii_transcript_input.py +++ /dev/null @@ -1,90 +0,0 @@ -# coding=utf-8 -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -from azure.ai.language.conversations import ConversationAnalysisClient -from azure.core.credentials import AzureKeyCredential -from devtools_testutils import AzureRecordedTestCase - - -class TestConversationalPii(AzureRecordedTestCase): - - def test_conversational_pii(self, recorded_test, conversation_creds): - # analyze query - client = ConversationAnalysisClient( - conversation_creds["endpoint"], - AzureKeyCredential(conversation_creds["key"]) - ) - with client: - poller = client.begin_conversation_analysis( - task={ - "displayName": "Analyze PII in conversation", - "analysisInput": { - "conversations": [ - { - "conversationItems": [ - { - "id": "1", - "participantId": "0", - "modality": "transcript", - "text": "It is john doe.", - "lexical": "It is john doe", - "itn": "It is john doe", - "maskedItn": "It is john doe" - }, - { - "id": "2", - "participantId": "1", - "modality": "transcript", - "text": "Yes, 633-27-8199 is my phone", - "lexical": "yes six three three two seven eight one nine nine is my phone", - "itn": "yes 633278199 is my phone", - "maskedItn": "yes 633278199 is my phone", - }, - { - "id": "3", - "participantId": "1", - "modality": "transcript", - "text": "j.doe@yahoo.com is my email", - "lexical": "j dot doe at yahoo dot com is my email", - "maskedItn": "j.doe@yahoo.com is my email", - "itn": "j.doe@yahoo.com is my email", - } - ], - "modality": "transcript", - "id": "1", - "language": "en" - } - ] - }, - "tasks": [ - { - "kind": "ConversationalPIITask", - "parameters": { - "redactionSource": "lexical", - "piiCategories": [ - "all" - ] - } - } - ] - } - ) - - # assert - main object - result = poller.result() - assert not result is None - assert result["status"] == "succeeded" - - # assert - task result - task_result = result["tasks"]["items"][0] - assert task_result["status"] == "succeeded" - assert task_result["kind"] == "conversationalPIIResults" - - # assert - conv result - conversation_items = task_result["results"]["conversations"][0]["conversationItems"] - assert not conversation_items is None - for conversation in conversation_items: - assert not conversation["redactedContent"] is None - assert not conversation["entities"] is None diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conv_pii_transcript_input_async.py b/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conv_pii_transcript_input_async.py deleted file mode 100644 index 25641f21460c..000000000000 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conv_pii_transcript_input_async.py +++ /dev/null @@ -1,93 +0,0 @@ -# coding=utf-8 -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -import pytest - -from azure.ai.language.conversations.aio import ConversationAnalysisClient -from azure.core.credentials import AzureKeyCredential -from devtools_testutils import AzureRecordedTestCase - - -class TestConversationalPiiAsync(AzureRecordedTestCase): - - @pytest.mark.asyncio - async def test_conversational_pii(self, recorded_test, conversation_creds): - # analyze query - client = ConversationAnalysisClient( - conversation_creds["endpoint"], - AzureKeyCredential(conversation_creds["key"]) - ) - async with client: - poller = await client.begin_conversation_analysis( - task={ - "displayName": "Analyze PII in conversation", - "analysisInput": { - "conversations": [ - { - "conversationItems": [ - { - "id": "1", - "participantId": "0", - "modality": "transcript", - "text": "It is john doe.", - "lexical": "It is john doe", - "itn": "It is john doe", - "maskedItn": "It is john doe" - }, - { - "id": "2", - "participantId": "1", - "modality": "transcript", - "text": "Yes, 633-27-8199 is my phone", - "lexical": "yes six three three two seven eight one nine nine is my phone", - "itn": "yes 633278199 is my phone", - "maskedItn": "yes 633278199 is my phone", - }, - { - "id": "3", - "participantId": "1", - "modality": "transcript", - "text": "j.doe@yahoo.com is my email", - "lexical": "j dot doe at yahoo dot com is my email", - "maskedItn": "j.doe@yahoo.com is my email", - "itn": "j.doe@yahoo.com is my email", - } - ], - "modality": "transcript", - "id": "1", - "language": "en" - } - ] - }, - "tasks": [ - { - "kind": "ConversationalPIITask", - "parameters": { - "redactionSource": "lexical", - "piiCategories": [ - "all" - ] - } - } - ] - } - ) - - # assert - main object - result = await poller.result() - assert not result is None - assert result["status"] == "succeeded" - - # assert - task result - task_result = result["tasks"]["items"][0] - assert task_result["status"] == "succeeded" - assert task_result["kind"] == "conversationalPIIResults" - - # assert - conv result - conversation_items = task_result["results"]["conversations"][0]["conversationItems"] - assert not conversation_items is None - for conversation in conversation_items: - assert not conversation["redactedContent"] is None - assert not conversation["entities"] is None diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conv_sentiment.py b/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conv_sentiment.py deleted file mode 100644 index 7973c89ae851..000000000000 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conv_sentiment.py +++ /dev/null @@ -1,70 +0,0 @@ -# coding=utf-8 -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -import pytest -from azure.ai.language.conversations import ConversationAnalysisClient -from azure.core.credentials import AzureKeyCredential -from devtools_testutils import AzureRecordedTestCase - - -class TestConversationalSentimentTask(AzureRecordedTestCase): - - def test_conversational_sentiment_task(self, recorded_test, conversation_creds): - # analyze query - client = ConversationAnalysisClient( - conversation_creds["endpoint"], - AzureKeyCredential(conversation_creds["key"]) - ) - with client: - poller = client.begin_conversation_analysis( - task={ - "displayName": "Sentiment Analysis from a call center conversation", - "analysisInput": { - "conversations": [ - { - "id": "1", - "language": "en", - "modality": "transcript", - "conversationItems": [ - { - "participantId": "1", - "id": "1", - "text": "I like the service. I do not like the food", - "lexical": "i like the service i do not like the food", - } - ] - } - ] - }, - "tasks": [ - { - "taskName": "Conversation Sentiment Analysis", - "kind": "ConversationalSentimentTask", - "parameters": { - "modelVersion": "latest", - "predictionSource": "text" - } - } - ] - } - ) - - # assert - main object - result = poller.result() - assert result is not None - assert result["status"] == "succeeded" - - # assert - task result - task_result = result["tasks"]["items"][0] - assert task_result["status"] == "succeeded" - # assert task_result["kind"] == "conversationalSentimentResults" https://dev.azure.com/msazure/Cognitive%20Services/_workitems/edit/16041272 - - # assert - conv result - sentiment_result = task_result["results"]["conversations"][0] - conversation_sentiment = sentiment_result["conversationItems"][0] - assert conversation_sentiment["sentiment"] == "mixed" - assert conversation_sentiment["participantId"] == "1" - assert conversation_sentiment["confidenceScores"] - diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conv_sentiment_async.py b/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conv_sentiment_async.py deleted file mode 100644 index 8f9137e19490..000000000000 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conv_sentiment_async.py +++ /dev/null @@ -1,71 +0,0 @@ -# coding=utf-8 -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -import pytest -from azure.ai.language.conversations.aio import ConversationAnalysisClient -from azure.core.credentials import AzureKeyCredential -from devtools_testutils import AzureRecordedTestCase - - -class TestConversationalSentimentTaskAsync(AzureRecordedTestCase): - - @pytest.mark.asyncio - async def test_conversational_sentiment_task(self, recorded_test, conversation_creds): - # analyze query - client = ConversationAnalysisClient( - conversation_creds["endpoint"], - AzureKeyCredential(conversation_creds["key"]) - ) - async with client: - poller = await client.begin_conversation_analysis( - task={ - "displayName": "Sentiment Analysis from a call center conversation", - "analysisInput": { - "conversations": [ - { - "id": "1", - "language": "en", - "modality": "transcript", - "conversationItems": [ - { - "participantId": "1", - "id": "1", - "text": "I like the service. I do not like the food", - "lexical": "i like the service i do not like the food", - } - ] - } - ] - }, - "tasks": [ - { - "taskName": "Conversation Sentiment Analysis", - "kind": "ConversationalSentimentTask", - "parameters": { - "modelVersion": "latest", - "predictionSource": "text" - } - } - ] - } - ) - - # assert - main object - result = await poller.result() - assert result is not None - assert result["status"] == "succeeded" - - # assert - task result - task_result = result["tasks"]["items"][0] - assert task_result["status"] == "succeeded" - # assert task_result["kind"] == "conversationalSentimentResults" https://dev.azure.com/msazure/Cognitive%20Services/_workitems/edit/16041272 - - # assert - conv result - sentiment_result = task_result["results"]["conversations"][0] - conversation_sentiment = sentiment_result["conversationItems"][0] - assert conversation_sentiment["sentiment"] == "mixed" - assert conversation_sentiment["participantId"] == "1" - assert conversation_sentiment["confidenceScores"] - diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conversation_app.py b/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conversation_app.py index 4b199c8df07f..f562dfd815d3 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conversation_app.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conversation_app.py @@ -62,7 +62,7 @@ def test_conversation_app(self, recorded_test, conversation_creds): assert result["result"]["prediction"]["entities"][0]["text"] == 'Carol' assert result["result"]["prediction"]["entities"][0]["confidenceScore"] > 0 - @pytest.mark.skip("no runtime AAD yet for 2022-10-01-preview") + @pytest.mark.skip("no runtime AAD yet for 2023-04-01") def test_conversation_app_aad_auth(self, recorded_test, conversation_creds): token = self.get_credential(ConversationAnalysisClient) client = ConversationAnalysisClient(conversation_creds["endpoint"], token) diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conversation_app_async.py b/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conversation_app_async.py index 28ac8140011b..57f2d220ed63 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conversation_app_async.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/tests/test_conversation_app_async.py @@ -63,7 +63,7 @@ async def test_conversation_app(self, recorded_test, conversation_creds): assert result["result"]["prediction"]["entities"][0]["text"] == 'Carol' assert result["result"]["prediction"]["entities"][0]["confidenceScore"] > 0 - @pytest.mark.skip("no runtime AAD yet for 2022-10-01-preview") + @pytest.mark.skip("no runtime AAD yet for 2023-04-01") @pytest.mark.asyncio async def test_conversation_app_aad_auth(self, recorded_test, conversation_creds): token = self.get_credential(ConversationAnalysisClient, is_async=True)