forked from Azure/azure-sdk-for-python
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
1 parent
abf5415
commit 79080d1
Showing
37 changed files
with
1,311 additions
and
5,677 deletions.
There are no files selected for viewing
19 changes: 16 additions & 3 deletions
19
sdk/cognitivelanguage/azure-ai-language-conversations/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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": "[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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.