-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare Conversations Language Understanding SDK 1.1.0-beta.1
* Convert to DPG with HLC models * Ignore long sync LRO test Caused by Azure#29140 (seemingly) * Add swagger transforms Works around Azure#29141 and Azure#29143 * Convert to DPG Also fixes Azure#26379 * Update public APIs and documentation * Resolve PR feedback * Resolve offline feedback * Update generated code
- Loading branch information
Showing
167 changed files
with
10,392 additions
and
1,982 deletions.
There are no files selected for viewing
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
103 changes: 103 additions & 0 deletions
103
....Conversations/samples/Sample6_AnalyzeConversation_ConversationSummarization.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# Analyze a conversation | ||
|
||
This sample demonstrates how to analyze a conversation with Conversation Summarization. To get started, you'll need to create a Cognitive Language service endpoint and an API key. See the [README](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/cognitivelanguage/Azure.AI.Language.Conversations/README.md) for links and instructions. | ||
|
||
To analyze an utterance, you need to first create a `ConversationAnalysisClient` using an endpoint and API key. These can be stored in an environment variable, configuration setting, or any way that works for your application. | ||
|
||
```C# Snippet:ConversationAnalysisClient_Create | ||
Uri endpoint = new Uri("https://myaccount.cognitive.microsoft.com"); | ||
AzureKeyCredential credential = new AzureKeyCredential("{api-key}"); | ||
|
||
ConversationAnalysisClient client = new ConversationAnalysisClient(endpoint, credential); | ||
``` | ||
|
||
Once you have created a client, you can call synchronous or asynchronous methods. | ||
|
||
## Synchronous | ||
|
||
```C# Snippet:AnalyzeConversation_ConversationSummarization | ||
var data = new | ||
{ | ||
analysisInput = new | ||
{ | ||
conversations = new[] | ||
{ | ||
new | ||
{ | ||
conversationItems = new[] | ||
{ | ||
new | ||
{ | ||
text = "Hello, how can I help you?", | ||
id = "1", | ||
participantId = "Agent", | ||
}, | ||
new | ||
{ | ||
text = "How to upgrade Office? I am getting error messages the whole day.", | ||
id = "2", | ||
participantId = "Customer", | ||
}, | ||
new | ||
{ | ||
text = "Press the upgrade button please. Then sign in and follow the instructions.", | ||
id = "3", | ||
participantId = "Agent", | ||
}, | ||
}, | ||
id = "1", | ||
language = "en", | ||
modality = "text", | ||
}, | ||
} | ||
}, | ||
tasks = new[] | ||
{ | ||
new | ||
{ | ||
parameters = new | ||
{ | ||
summaryAspects = new[] | ||
{ | ||
"issue", | ||
"resolution", | ||
} | ||
}, | ||
kind = "ConversationalSummarizationTask", | ||
taskName = "1", | ||
}, | ||
}, | ||
}; | ||
|
||
Operation<BinaryData> analyzeConversationOperation = client.SubmitJob(WaitUntil.Started, RequestContent.Create(data)); | ||
analyzeConversationOperation.WaitForCompletion(); | ||
|
||
using JsonDocument result = JsonDocument.Parse(analyzeConversationOperation.Value.ToStream()); | ||
JsonElement jobResults = result.RootElement; | ||
foreach (JsonElement task in jobResults.GetProperty("tasks").GetProperty("items").EnumerateArray()) | ||
{ | ||
JsonElement results = task.GetProperty("results"); | ||
|
||
Console.WriteLine("Conversations:"); | ||
foreach (JsonElement conversation in results.GetProperty("conversations").EnumerateArray()) | ||
{ | ||
Console.WriteLine($"Conversation: #{conversation.GetProperty("id").GetString()}"); | ||
Console.WriteLine("Summaries:"); | ||
foreach (JsonElement summary in conversation.GetProperty("summaries").EnumerateArray()) | ||
{ | ||
Console.WriteLine($"Text: {summary.GetProperty("text").GetString()}"); | ||
Console.WriteLine($"Aspect: {summary.GetProperty("aspect").GetString()}"); | ||
} | ||
Console.WriteLine(); | ||
} | ||
} | ||
``` | ||
|
||
## Asynchronous | ||
|
||
Using the same `data` definition above, you can make an asynchronous request by calling `AnalyzeConversationAsync`: | ||
|
||
```C# Snippet:AnalyzeConversationAsync_ConversationSummarization | ||
Operation<BinaryData> analyzeConversationOperation = await client.SubmitJobAsync(WaitUntil.Started, RequestContent.Create(data)); | ||
await analyzeConversationOperation.WaitForCompletionAsync(); | ||
``` |
117 changes: 117 additions & 0 deletions
117
...guage.Conversations/samples/Sample7_AnalyzeConversation_ConversationPII_Text.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
# Analyze a conversation | ||
|
||
This sample demonstrates how to analyze a conversation with Conversation PII (Text input). To get started, you'll need to create a Cognitive Language service endpoint and an API key. See the [README](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/cognitivelanguage/Azure.AI.Language.Conversations/README.md) for links and instructions. | ||
|
||
To analyze an utterance, you need to first create a `ConversationAnalysisClient` using an endpoint and API key. These can be stored in an environment variable, configuration setting, or any way that works for your application. | ||
|
||
```C# Snippet:ConversationAnalysisClient_Create | ||
Uri endpoint = new Uri("https://myaccount.cognitive.microsoft.com"); | ||
AzureKeyCredential credential = new AzureKeyCredential("{api-key}"); | ||
|
||
ConversationAnalysisClient client = new ConversationAnalysisClient(endpoint, credential); | ||
``` | ||
|
||
Once you have created a client, you can call synchronous or asynchronous methods. | ||
|
||
## Synchronous | ||
|
||
```C# Snippet:AnalyzeConversation_ConversationPII_Text | ||
var data = new | ||
{ | ||
analysisInput = new | ||
{ | ||
conversations = new[] | ||
{ | ||
new | ||
{ | ||
conversationItems = new[] | ||
{ | ||
new | ||
{ | ||
text = "Hi, I am John Doe.", | ||
id = "1", | ||
participantId = "0", | ||
}, | ||
new | ||
{ | ||
text = "Hi John, how are you doing today?", | ||
id = "2", | ||
participantId = "1", | ||
}, | ||
new | ||
{ | ||
text = "Pretty good.", | ||
id = "3", | ||
participantId = "0", | ||
}, | ||
}, | ||
id = "1", | ||
language = "en", | ||
modality = "text", | ||
}, | ||
} | ||
}, | ||
tasks = new[] | ||
{ | ||
new | ||
{ | ||
parameters = new | ||
{ | ||
piiCategories = new[] | ||
{ | ||
"All", | ||
}, | ||
includeAudioRedaction = false, | ||
modelVersion = "2022-05-15-preview", | ||
loggingOptOut = false, | ||
}, | ||
kind = "ConversationalPIITask", | ||
taskName = "analyze", | ||
}, | ||
}, | ||
}; | ||
|
||
Operation<BinaryData> analyzeConversationOperation = client.SubmitJob(WaitUntil.Started, RequestContent.Create(data)); | ||
analyzeConversationOperation.WaitForCompletion(); | ||
|
||
using JsonDocument result = JsonDocument.Parse(analyzeConversationOperation.Value.ToStream()); | ||
JsonElement jobResults = result.RootElement; | ||
foreach (JsonElement task in jobResults.GetProperty("tasks").GetProperty("items").EnumerateArray()) | ||
{ | ||
JsonElement results = task.GetProperty("results"); | ||
|
||
Console.WriteLine("Conversations:"); | ||
foreach (JsonElement conversation in results.GetProperty("conversations").EnumerateArray()) | ||
{ | ||
Console.WriteLine($"Conversation: #{conversation.GetProperty("id").GetString()}"); | ||
Console.WriteLine("Conversation Items:"); | ||
foreach (JsonElement conversationItem in conversation.GetProperty("conversationItems").EnumerateArray()) | ||
{ | ||
Console.WriteLine($"Conversation Item: #{conversationItem.GetProperty("id").GetString()}"); | ||
|
||
Console.WriteLine($"Redacted Text: {conversationItem.GetProperty("redactedContent").GetProperty("text").GetString()}"); | ||
|
||
Console.WriteLine("Entities:"); | ||
foreach (JsonElement entity in conversationItem.GetProperty("entities").EnumerateArray()) | ||
{ | ||
Console.WriteLine($"Text: {entity.GetProperty("text").GetString()}"); | ||
Console.WriteLine($"Offset: {entity.GetProperty("offset").GetInt32()}"); | ||
Console.WriteLine($"Category: {entity.GetProperty("category").GetString()}"); | ||
Console.WriteLine($"Confidence Score: {entity.GetProperty("confidenceScore").GetSingle()}"); | ||
Console.WriteLine($"Length: {entity.GetProperty("length").GetInt32()}"); | ||
Console.WriteLine(); | ||
} | ||
} | ||
Console.WriteLine(); | ||
} | ||
} | ||
``` | ||
|
||
## Asynchronous | ||
|
||
Using the same `data` definition above, you can make an asynchronous request by calling `AnalyzeConversationAsync`: | ||
|
||
```C# Snippet:AnalyzeConversationAsync_ConversationPII_Text | ||
Operation<BinaryData> analyzeConversationOperation = await client.SubmitJobAsync(WaitUntil.Started, RequestContent.Create(data)); | ||
await analyzeConversationOperation.WaitForCompletionAsync(); | ||
``` |
Oops, something went wrong.