Skip to content

Commit

Permalink
[CLU] 2023-04-01 (Azure#30180)
Browse files Browse the repository at this point in the history
* regenerate CLU with 2023-04-01

* update _patch.py

* rerecord and remove test/samples for features no longer supported in GA

* regen on latest commit, heath's feedback on README.md

* clean up docs and changelog
  • Loading branch information
kristapratico authored May 17, 2023
1 parent abf5415 commit 79080d1
Show file tree
Hide file tree
Showing 37 changed files with 1,311 additions and 5,677 deletions.
19 changes: 16 additions & 3 deletions sdk/cognitivelanguage/azure-ai-language-conversations/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
178 changes: 2 additions & 176 deletions sdk/cognitivelanguage/azure-ai-language-conversations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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].
Expand Down Expand Up @@ -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": "[email protected] is my email",
"lexical": "j dot doe at yahoo dot com is my email",
"maskedItn": "[email protected] is my email",
"itn": "[email protected] 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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,13 @@
# 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
from azure.core.pipeline import policies

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
Expand All @@ -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.")
Expand Down
Loading

0 comments on commit 79080d1

Please sign in to comment.