forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release Conversations Language Understanding SDK 1.1.0-beta.1 (Azure#…
…29542) * 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 * Stop always recording authoring tests * Update samples * Update CHANGELOG for release
- Loading branch information
Showing
158 changed files
with
10,487 additions
and
1,907 deletions.
There are no files selected for viewing
12 changes: 6 additions & 6 deletions
12
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
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.AnalyzeConversation(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.AnalyzeConversationAsync(WaitUntil.Started, RequestContent.Create(data)); | ||
await analyzeConversationOperation.WaitForCompletionAsync(); | ||
``` |
Oops, something went wrong.