Skip to content

Commit

Permalink
[CLU] 1.1.0b2 (#25014)
Browse files Browse the repository at this point in the history
  • Loading branch information
kristapratico authored Jul 1, 2022
1 parent 62b22ab commit 6bea2f0
Show file tree
Hide file tree
Showing 48 changed files with 2,800 additions and 139 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release History

## 1.1.0b2 (2022-07-01)

### Features Added
* Added Azure Active Directory (AAD) authentication support
* Added support for authoring operations with `ConversationAuthoringClient` under the `azure.ai.language.conversations.authoring` namespace.

## 1.1.0b1 (2022-05-26)

### Features Added
Expand Down
187 changes: 184 additions & 3 deletions sdk/cognitivelanguage/azure-ai-language-conversations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
Conversational Language Understanding - aka **CLU** for short - is a cloud-based conversational AI service which provides many language understanding capabilities like:
- 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 summarize conversations in the form of issues, and final resolutions
- Conversational PII: Used to extract and redact personally-identifiable info (PII)

[Source code][conversationallanguage_client_src] | [Package (PyPI)][conversationallanguage_pypi_package] | [API reference documentation][api_reference_documentation] | [Samples][conversationallanguage_samples] | [Product documentation][conversationallanguage_docs] | [Analysis REST API][conversationallanguage_restdocs] | [Authoring REST API][conversationallanguage_restdocs_authoring]

Expand All @@ -27,10 +28,10 @@ _Azure SDK Python packages support for Python 2.7 ended 01 January 2022. For mor
Install the Azure Conversations client library for Python with [pip][pip_link]:

```bash
pip install azure-ai-language-conversations
pip install azure-ai-language-conversations --pre
```

> Note: This version of the client library defaults to the 2022-05-01 version of the service
> Note: This version of the client library defaults to the 2022-05-15-preview 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 @@ -244,6 +245,186 @@ if top_intent_object["targetProjectKind"] == "Luis":
print("\n{}".format(entity))
```

### Conversational Summarization

You can use this sample if you need to summarize a conversation in the form of an issue, and final resolution. For example, a dialog from tech support:

```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 conversations from xxx",
"analysisInput": {
"conversations": [
{
"conversationItems": [
{
"text": "Hello, how can I help you?",
"modality": "text",
"id": "1",
"participantId": "Agent"
},
{
"text": "How to upgrade Office? I am getting error messages the whole day.",
"modality": "text",
"id": "2",
"participantId": "Customer"
},
{
"text": "Press the upgrade button please. Then sign in and follow the instructions.",
"modality": "text",
"id": "3",
"participantId": "Agent"
}
],
"modality": "text",
"id": "conversation1",
"language": "en"
},
]
},
"tasks": [
{
"taskName": "analyze 1",
"kind": "ConversationalSummarizationTask",
"parameters": {
"summaryAspects": ["Issue, Resolution"]
}
}
]
}
)

# view result
result = poller.result()
task_result = result["tasks"]["items"][0]
print("... view task status ...")
print("status: {}".format(task_result["status"]))
resolution_result = task_result["results"]
if resolution_result["errors"]:
print("... errors occured ...")
for error in resolution_result["errors"]:
print(error)
else:
conversation_result = resolution_result["conversations"][0]
if conversation_result["warnings"]:
print("... view warnings ...")
for warning in conversation_result["warnings"]:
print(warning)
else:
summaries = conversation_result["summaries"]
print("... view task result ...")
print("issue: {}".format(summaries[0]["text"]))
print("resolution: {}".format(summaries[1]["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 occured ...")
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"]))
```

### 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 @@ -42,9 +42,11 @@ 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-05-01". Note that overriding this
default value may result in unsupported behavior.
:keyword api_version: Api Version. Default value is "2022-05-15-preview". 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.
"""

def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,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-05-01". Note that overriding this
default value may result in unsupported behavior.
:keyword api_version: Api Version. Default value is "2022-05-15-preview". 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 = kwargs.pop("api_version", "2022-05-01") # type: str
api_version = kwargs.pop("api_version", "2022-05-15-preview") # type: str

if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
Expand Down
Loading

0 comments on commit 6bea2f0

Please sign in to comment.