forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* regenerated swagger * Fixing convienience layer * Naming errors fixes * Fixes * regenerated swagger * modified convience layer client * added sample * lol * added directives * adding LRO support * Added samples and tests * changed directives * var usage * var usage * updated samples, readme and update log * directives * Converted generation to DPG * regeneration * export api * fixes * regenerated snippets + export api * rerecorded tests * added breaking changes to the log * fix * fix * addressing comments * updated snippets * fixed directive * Updated sample
- Loading branch information
Salah Mostafa
authored
May 23, 2022
1 parent
b283376
commit f54d173
Showing
314 changed files
with
13,671 additions
and
2,619 deletions.
There are no files selected for viewing
6 changes: 5 additions & 1 deletion
6
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
297 changes: 274 additions & 23 deletions
297
sdk/cognitivelanguage/Azure.AI.Language.Conversations/README.md
Large diffs are not rendered by default.
Oops, something went wrong.
646 changes: 559 additions & 87 deletions
646
...age/Azure.AI.Language.Conversations/api/Azure.AI.Language.Conversations.netstandard2.0.cs
Large diffs are not rendered by default.
Oops, something went wrong.
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
76 changes: 76 additions & 0 deletions
76
....Conversations/samples/Sample5_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,76 @@ | ||
# 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.api.cognitive.microsoft.com"); | ||
AzureKeyCredential credential = new AzureKeyCredential("{api-key}"); | ||
|
||
ConversationAnalysisClient client = new ConversationAnalysisClient(endpoint, credential); | ||
``` | ||
|
||
Once you have created a client, you can prepare the input: | ||
|
||
```C# Snippet:StartAnalyzeConversation_ConversationSummarization_Input | ||
var textConversationItems = new List<TextConversationItem>() | ||
{ | ||
new TextConversationItem("1", "Agent", "Hello, how can I help you?"), | ||
new TextConversationItem("2", "Customer", "How to upgrade Office? I am getting error messages the whole day."), | ||
new TextConversationItem("3", "Agent", "Press the upgrade button please. Then sign in and follow the instructions."), | ||
}; | ||
|
||
var input = new List<TextConversation>() | ||
{ | ||
new TextConversation("1", "en", textConversationItems) | ||
}; | ||
|
||
var conversationSummarizationTaskParameters = new ConversationSummarizationTaskParameters(new List<SummaryAspect>() { SummaryAspect.Issue, SummaryAspect.Resolution }); | ||
|
||
var tasks = new List<AnalyzeConversationLROTask>() | ||
{ | ||
new AnalyzeConversationSummarizationTask("1", AnalyzeConversationLROTaskKind.ConversationalSummarizationTask, conversationSummarizationTaskParameters), | ||
}; | ||
``` | ||
|
||
then you can start analyzing by calling the `StartAnalyzeConversation`, and because this is a long running operation, you have to wait until it's finished by calling `WaitForCompletion` function. | ||
|
||
## Synchronous | ||
|
||
```C# Snippet:StartAnalyzeConversation_StartAnalayzing | ||
var analyzeConversationOperation = client.StartAnalyzeConversation(input, tasks); | ||
analyzeConversationOperation.WaitForCompletion(); | ||
``` | ||
|
||
## Asynchronous | ||
|
||
```C# Snippet:StartAnalyzeConversationAsync_StartAnalayzing | ||
var analyzeConversationOperation = await client.StartAnalyzeConversationAsync(input, tasks); | ||
await analyzeConversationOperation.WaitForCompletionAsync(); | ||
``` | ||
|
||
You can finally print the results: | ||
|
||
```C# Snippet:StartAnalyzeConversation_ConversationSummarization_Results | ||
var jobResults = analyzeConversationOperation.Value; | ||
foreach (var result in jobResults.Tasks.Items) | ||
{ | ||
var analyzeConversationSummarization = result as AnalyzeConversationSummarizationResult; | ||
|
||
var results = analyzeConversationSummarization.Results; | ||
|
||
Console.WriteLine("Conversations:"); | ||
foreach (var conversation in results.Conversations) | ||
{ | ||
Console.WriteLine($"Conversation #:{conversation.Id}"); | ||
Console.WriteLine("Summaries:"); | ||
foreach (var summary in conversation.Summaries) | ||
{ | ||
Console.WriteLine($"Text: {summary.Text}"); | ||
Console.WriteLine($"Aspect: {summary.Aspect}"); | ||
} | ||
Console.WriteLine(); | ||
} | ||
} | ||
``` |
88 changes: 88 additions & 0 deletions
88
...guage.Conversations/samples/Sample6_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,88 @@ | ||
# 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.api.cognitive.microsoft.com"); | ||
AzureKeyCredential credential = new AzureKeyCredential("{api-key}"); | ||
|
||
ConversationAnalysisClient client = new ConversationAnalysisClient(endpoint, credential); | ||
``` | ||
|
||
Once you have created a client, you can prepare the input: | ||
|
||
```C# Snippet:StartAnalyzeConversation_ConversationPII_Text_Input | ||
var textConversationItems = new List<TextConversationItem>() | ||
{ | ||
new TextConversationItem("1", "0", "Hi, I am John Doe."), | ||
new TextConversationItem("2", "1", "Hi John, how are you doing today?"), | ||
new TextConversationItem("3", "0", "Pretty good."), | ||
}; | ||
|
||
var input = new List<TextConversation>() | ||
{ | ||
new TextConversation("1", "en", textConversationItems) | ||
}; | ||
|
||
var conversationPIITaskParameters = new ConversationPIITaskParameters(false, "2022-05-15-preview", new List<ConversationPIICategory>() { ConversationPIICategory.All }, false, null); | ||
|
||
var tasks = new List<AnalyzeConversationLROTask>() | ||
{ | ||
new AnalyzeConversationPIITask("analyze", AnalyzeConversationLROTaskKind.ConversationalPIITask, conversationPIITaskParameters), | ||
}; | ||
``` | ||
|
||
then you can start analyzing by calling the `AnalyzeConversation`, and because this is a long running operation, you have to wait until it's finished by calling `WaitForCompletion` function. | ||
|
||
## Synchronous | ||
|
||
```C# Snippet:StartAnalyzeConversation_StartAnalayzing | ||
var analyzeConversationOperation = client.StartAnalyzeConversation(input, tasks); | ||
analyzeConversationOperation.WaitForCompletion(); | ||
``` | ||
|
||
## Asynchronous | ||
|
||
```C# Snippet:StartAnalyzeConversationAsync_StartAnalayzing | ||
var analyzeConversationOperation = await client.StartAnalyzeConversationAsync(input, tasks); | ||
await analyzeConversationOperation.WaitForCompletionAsync(); | ||
``` | ||
|
||
You can finally print the results: | ||
|
||
```C# Snippet:StartAnalyzeConversation_ConversationPII_Text_Results | ||
var jobResults = analyzeConversationOperation.Value; | ||
foreach (var result in jobResults.Tasks.Items) | ||
{ | ||
var analyzeConversationPIIResult = result as AnalyzeConversationPIIResult; | ||
|
||
var results = analyzeConversationPIIResult.Results; | ||
|
||
Console.WriteLine("Conversations:"); | ||
foreach (var conversation in results.Conversations) | ||
{ | ||
Console.WriteLine($"Conversation #:{conversation.Id}"); | ||
Console.WriteLine("Conversation Items: "); | ||
foreach (var conversationItem in conversation.ConversationItems) | ||
{ | ||
Console.WriteLine($"Conversation Item #:{conversationItem.Id}"); | ||
|
||
Console.WriteLine($"Redacted Text: {conversationItem.RedactedContent.Text}"); | ||
|
||
Console.WriteLine("Entities:"); | ||
foreach (var entity in conversationItem.Entities) | ||
{ | ||
Console.WriteLine($"Text: {entity.Text}"); | ||
Console.WriteLine($"Offset: {entity.Offset}"); | ||
Console.WriteLine($"Category: {entity.Category}"); | ||
Console.WriteLine($"Confidence Score: {entity.ConfidenceScore}"); | ||
Console.WriteLine($"Length: {entity.Length}"); | ||
Console.WriteLine(); | ||
} | ||
} | ||
Console.WriteLine(); | ||
} | ||
} | ||
``` |
Oops, something went wrong.