Skip to content

Commit e4a3f6f

Browse files
Salah Mostafazhihaoxue
authored andcommitted
CLU Build SDK (Azure#28639)
* 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
1 parent 855414b commit e4a3f6f

File tree

314 files changed

+13671
-2619
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

314 files changed

+13671
-2619
lines changed

sdk/cognitivelanguage/Azure.AI.Language.Conversations/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# Release History
22

3-
## 1.0.0-beta.4 (Unreleased)
3+
## 1.1.0-beta.1 (Unreleased)
44

55
### Features Added
6+
* Added Conversation issue summarization task (Long-running operation)
7+
* Added Conversation PII extraction task (Long-running operation)
68

79
### Breaking Changes
10+
- Client now uses python dictionaries for method parameters and results instead of classes.
11+
- Many input and result parameter name changes in `analyze_conversation()` method
812

913
### Bugs Fixed
1014

sdk/cognitivelanguage/Azure.AI.Language.Conversations/README.md

Lines changed: 274 additions & 23 deletions
Large diffs are not rendered by default.

sdk/cognitivelanguage/Azure.AI.Language.Conversations/api/Azure.AI.Language.Conversations.netstandard2.0.cs

Lines changed: 559 additions & 87 deletions
Large diffs are not rendered by default.

sdk/cognitivelanguage/Azure.AI.Language.Conversations/samples/Sample1_AnalyzeConversation_ConversationPrediction.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Response<AnalyzeConversationTaskResult> response = client.AnalyzeConversation(
2323
conversationsProject);
2424

2525
CustomConversationalTaskResult customConversationalTaskResult = response.Value as CustomConversationalTaskResult;
26-
ConversationPrediction conversationPrediction = customConversationalTaskResult.Results.Prediction as ConversationPrediction;
26+
ConversationPrediction conversationPrediction = customConversationalTaskResult.Result.Prediction as ConversationPrediction;
2727

2828
Console.WriteLine($"Top intent: {conversationPrediction.TopIntent}");
2929

@@ -68,9 +68,9 @@ Response<AnalyzeConversationTaskResult> response = await client.AnalyzeConversat
6868
conversationsProject);
6969

7070
CustomConversationalTaskResult customConversationalTaskResult = response.Value as CustomConversationalTaskResult;
71-
ConversationPrediction conversationPrediction = customConversationalTaskResult.Results.Prediction as ConversationPrediction;
71+
ConversationPrediction conversationPrediction = customConversationalTaskResult.Result.Prediction as ConversationPrediction;
7272

73-
Console.WriteLine($"Project Kind: {customConversationalTaskResult.Results.Prediction.ProjectKind}");
73+
Console.WriteLine($"Project Kind: {customConversationalTaskResult.Result.Prediction.ProjectKind}");
7474
Console.WriteLine($"Top intent: {conversationPrediction.TopIntent}");
7575

7676
Console.WriteLine("Intents:");

sdk/cognitivelanguage/Azure.AI.Language.Conversations/samples/Sample2_AnalyzeConversation_OrchestrationPrediction.md

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Response<AnalyzeConversationResult> response = client.AnalyzeConversation(
2121
"How are you?",
2222
orchestrationProject);
2323
CustomConversationalTaskResult customConversationalTaskResult = response.Value as CustomConversationalTaskResult;
24-
var orchestratorPrediction = customConversationalTaskResult.Results.Prediction as OrchestratorPrediction;
24+
var orchestratorPrediction = customConversationalTaskResult.Result.Prediction as OrchestratorPrediction;
2525
```
2626

2727
## Asynchronous
@@ -32,7 +32,7 @@ Response<AnalyzeConversationResult> response = await client.AnalyzeConversation
3232
"How are you?",
3333
orchestrationProject);
3434
CustomConversationalTaskResult customConversationalTaskResult = response.Value as CustomConversationalTaskResult;
35-
var orchestratorPrediction = customConversationalTaskResult.Results.Prediction as OrchestratorPrediction;
35+
var orchestratorPrediction = customConversationalTaskResult.Result.Prediction as OrchestratorPrediction;
3636
```
3737

3838
## Accessing project specific results
@@ -45,22 +45,14 @@ Depending on the project chosen by your orchestration model, you may get results
4545
string respondingProjectName = orchestratorPrediction.TopIntent;
4646
TargetIntentResult targetIntentResult = orchestratorPrediction.Intents[respondingProjectName];
4747

48-
if (targetIntentResult.TargetKind == TargetKind.QuestionAnswering)
48+
if (targetIntentResult.TargetProjectKind == TargetProjectKind.QuestionAnswering)
4949
{
5050
Console.WriteLine($"Top intent: {respondingProjectName}");
5151

5252
QuestionAnsweringTargetIntentResult qnaTargetIntentResult = targetIntentResult as QuestionAnsweringTargetIntentResult;
5353

54-
KnowledgeBaseAnswers qnaAnswers = qnaTargetIntentResult.Result;
55-
56-
Console.WriteLine("Answers: \n");
57-
foreach (KnowledgeBaseAnswer answer in qnaAnswers.Answers)
58-
{
59-
Console.WriteLine($"Answer: {answer.Answer}");
60-
Console.WriteLine($"Confidence: {answer.Confidence}");
61-
Console.WriteLine($"Source: {answer.Source}");
62-
Console.WriteLine();
63-
}
54+
BinaryData questionAnsweringResponse = qnaTargetIntentResult.Result;
55+
Console.WriteLine($"Qustion Answering Response: {questionAnsweringResponse.ToString()}");
6456
}
6557
```
6658

@@ -70,7 +62,7 @@ if (targetIntentResult.TargetKind == TargetKind.QuestionAnswering)
7062
string respondingProjectName = orchestratorPrediction.TopIntent;
7163
TargetIntentResult targetIntentResult = orchestratorPrediction.Intents[respondingProjectName];
7264

73-
if (targetIntentResult.TargetKind == TargetKind.Conversation)
65+
if (targetIntentResult.TargetProjectKind == TargetProjectKind.Conversation)
7466
{
7567
ConversationTargetIntentResult cluTargetIntentResult = targetIntentResult as ConversationTargetIntentResult;
7668

@@ -116,7 +108,7 @@ if (targetIntentResult.TargetKind == TargetKind.Conversation)
116108
string respondingProjectName = orchestratorPrediction.TopIntent;
117109
TargetIntentResult targetIntentResult = orchestratorPrediction.Intents[respondingProjectName];
118110

119-
if (targetIntentResult.TargetKind == TargetKind.Luis)
111+
if (targetIntentResult.TargetProjectKind == TargetProjectKind.Luis)
120112
{
121113
LuisTargetIntentResult luisTargetIntentResult = targetIntentResult as LuisTargetIntentResult;
122114
BinaryData luisResponse = luisTargetIntentResult.Result;

sdk/cognitivelanguage/Azure.AI.Language.Conversations/samples/Sample3_AnalyzeConversationWithLanguage.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ Response<AnalyzeConversationTaskResult> response = client.AnalyzeConversation(
3333
options);
3434

3535
CustomConversationalTaskResult customConversationalTaskResult = response.Value as CustomConversationalTaskResult;
36-
ConversationPrediction conversationPrediction = customConversationalTaskResult.Results.Prediction as ConversationPrediction;
36+
ConversationPrediction conversationPrediction = customConversationalTaskResult.Result.Prediction as ConversationPrediction;
3737

38-
Console.WriteLine($"Project Kind: {customConversationalTaskResult.Results.Prediction.ProjectKind}");
38+
Console.WriteLine($"Project Kind: {customConversationalTaskResult.Result.Prediction.ProjectKind}");
3939
Console.WriteLine($"Top intent: {conversationPrediction.TopIntent}");
4040

4141
Console.WriteLine("Intents:");
@@ -89,9 +89,9 @@ Response<AnalyzeConversationTaskResult> response = await client.AnalyzeConversat
8989
options);
9090

9191
CustomConversationalTaskResult customConversationalTaskResult = response.Value as CustomConversationalTaskResult;
92-
ConversationPrediction conversationPrediction = customConversationalTaskResult.Results.Prediction as ConversationPrediction;
92+
ConversationPrediction conversationPrediction = customConversationalTaskResult.Result.Prediction as ConversationPrediction;
9393

94-
Console.WriteLine($"Project Kind: {customConversationalTaskResult.Results.Prediction.ProjectKind}");
94+
Console.WriteLine($"Project Kind: {customConversationalTaskResult.Result.Prediction.ProjectKind}");
9595
Console.WriteLine($"Top intent: {conversationPrediction.TopIntent}");
9696

9797
Console.WriteLine("Intents:");

sdk/cognitivelanguage/Azure.AI.Language.Conversations/samples/Sample4_AnalyzeConversationWithOptions.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ TextConversationItem input = new TextConversationItem(
2222
text: "Send an email to Carol about the tomorrow's demo.");
2323
AnalyzeConversationOptions options = new AnalyzeConversationOptions(input)
2424
{
25-
IsLoggingEnabled = true,
2625
Verbose = true
2726
};
2827

@@ -34,9 +33,9 @@ Response<AnalyzeConversationTaskResult> response = client.AnalyzeConversation(
3433
options);
3534

3635
CustomConversationalTaskResult customConversationalTaskResult = response.Value as CustomConversationalTaskResult;
37-
ConversationPrediction conversationPrediction = customConversationalTaskResult.Results.Prediction as ConversationPrediction;
36+
ConversationPrediction conversationPrediction = customConversationalTaskResult.Result.Prediction as ConversationPrediction;
3837

39-
Console.WriteLine($"Project Kind: {customConversationalTaskResult.Results.Prediction.ProjectKind}");
38+
Console.WriteLine($"Project Kind: {customConversationalTaskResult.Result.Prediction.ProjectKind}");
4039
Console.WriteLine($"Top intent: {conversationPrediction.TopIntent}");
4140

4241
Console.WriteLine("Intents:");
@@ -79,7 +78,6 @@ TextConversationItem input = new TextConversationItem(
7978
text: "Send an email to Carol about the tomorrow's demo.");
8079
AnalyzeConversationOptions options = new AnalyzeConversationOptions(input)
8180
{
82-
IsLoggingEnabled = true,
8381
Verbose = true
8482
};
8583

@@ -91,9 +89,9 @@ Response<AnalyzeConversationTaskResult> response = await client.AnalyzeConversat
9189
options);
9290

9391
CustomConversationalTaskResult customConversationalTaskResult = response.Value as CustomConversationalTaskResult;
94-
ConversationPrediction conversationPrediction = customConversationalTaskResult.Results.Prediction as ConversationPrediction;
92+
ConversationPrediction conversationPrediction = customConversationalTaskResult.Result.Prediction as ConversationPrediction;
9593

96-
Console.WriteLine($"Project Kind: {customConversationalTaskResult.Results.Prediction.ProjectKind}");
94+
Console.WriteLine($"Project Kind: {customConversationalTaskResult.Result.Prediction.ProjectKind}");
9795
Console.WriteLine($"Top intent: {conversationPrediction.TopIntent}");
9896

9997
Console.WriteLine("Intents:");
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Analyze a conversation
2+
3+
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.
4+
5+
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.
6+
7+
```C# Snippet:ConversationAnalysisClient_Create
8+
Uri endpoint = new Uri("https://myaccount.api.cognitive.microsoft.com");
9+
AzureKeyCredential credential = new AzureKeyCredential("{api-key}");
10+
11+
ConversationAnalysisClient client = new ConversationAnalysisClient(endpoint, credential);
12+
```
13+
14+
Once you have created a client, you can prepare the input:
15+
16+
```C# Snippet:StartAnalyzeConversation_ConversationSummarization_Input
17+
var textConversationItems = new List<TextConversationItem>()
18+
{
19+
new TextConversationItem("1", "Agent", "Hello, how can I help you?"),
20+
new TextConversationItem("2", "Customer", "How to upgrade Office? I am getting error messages the whole day."),
21+
new TextConversationItem("3", "Agent", "Press the upgrade button please. Then sign in and follow the instructions."),
22+
};
23+
24+
var input = new List<TextConversation>()
25+
{
26+
new TextConversation("1", "en", textConversationItems)
27+
};
28+
29+
var conversationSummarizationTaskParameters = new ConversationSummarizationTaskParameters(new List<SummaryAspect>() { SummaryAspect.Issue, SummaryAspect.Resolution });
30+
31+
var tasks = new List<AnalyzeConversationLROTask>()
32+
{
33+
new AnalyzeConversationSummarizationTask("1", AnalyzeConversationLROTaskKind.ConversationalSummarizationTask, conversationSummarizationTaskParameters),
34+
};
35+
```
36+
37+
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.
38+
39+
## Synchronous
40+
41+
```C# Snippet:StartAnalyzeConversation_StartAnalayzing
42+
var analyzeConversationOperation = client.StartAnalyzeConversation(input, tasks);
43+
analyzeConversationOperation.WaitForCompletion();
44+
```
45+
46+
## Asynchronous
47+
48+
```C# Snippet:StartAnalyzeConversationAsync_StartAnalayzing
49+
var analyzeConversationOperation = await client.StartAnalyzeConversationAsync(input, tasks);
50+
await analyzeConversationOperation.WaitForCompletionAsync();
51+
```
52+
53+
You can finally print the results:
54+
55+
```C# Snippet:StartAnalyzeConversation_ConversationSummarization_Results
56+
var jobResults = analyzeConversationOperation.Value;
57+
foreach (var result in jobResults.Tasks.Items)
58+
{
59+
var analyzeConversationSummarization = result as AnalyzeConversationSummarizationResult;
60+
61+
var results = analyzeConversationSummarization.Results;
62+
63+
Console.WriteLine("Conversations:");
64+
foreach (var conversation in results.Conversations)
65+
{
66+
Console.WriteLine($"Conversation #:{conversation.Id}");
67+
Console.WriteLine("Summaries:");
68+
foreach (var summary in conversation.Summaries)
69+
{
70+
Console.WriteLine($"Text: {summary.Text}");
71+
Console.WriteLine($"Aspect: {summary.Aspect}");
72+
}
73+
Console.WriteLine();
74+
}
75+
}
76+
```
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Analyze a conversation
2+
3+
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.
4+
5+
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.
6+
7+
```C# Snippet:ConversationAnalysisClient_Create
8+
Uri endpoint = new Uri("https://myaccount.api.cognitive.microsoft.com");
9+
AzureKeyCredential credential = new AzureKeyCredential("{api-key}");
10+
11+
ConversationAnalysisClient client = new ConversationAnalysisClient(endpoint, credential);
12+
```
13+
14+
Once you have created a client, you can prepare the input:
15+
16+
```C# Snippet:StartAnalyzeConversation_ConversationPII_Text_Input
17+
var textConversationItems = new List<TextConversationItem>()
18+
{
19+
new TextConversationItem("1", "0", "Hi, I am John Doe."),
20+
new TextConversationItem("2", "1", "Hi John, how are you doing today?"),
21+
new TextConversationItem("3", "0", "Pretty good."),
22+
};
23+
24+
var input = new List<TextConversation>()
25+
{
26+
new TextConversation("1", "en", textConversationItems)
27+
};
28+
29+
var conversationPIITaskParameters = new ConversationPIITaskParameters(false, "2022-05-15-preview", new List<ConversationPIICategory>() { ConversationPIICategory.All }, false, null);
30+
31+
var tasks = new List<AnalyzeConversationLROTask>()
32+
{
33+
new AnalyzeConversationPIITask("analyze", AnalyzeConversationLROTaskKind.ConversationalPIITask, conversationPIITaskParameters),
34+
};
35+
```
36+
37+
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.
38+
39+
## Synchronous
40+
41+
```C# Snippet:StartAnalyzeConversation_StartAnalayzing
42+
var analyzeConversationOperation = client.StartAnalyzeConversation(input, tasks);
43+
analyzeConversationOperation.WaitForCompletion();
44+
```
45+
46+
## Asynchronous
47+
48+
```C# Snippet:StartAnalyzeConversationAsync_StartAnalayzing
49+
var analyzeConversationOperation = await client.StartAnalyzeConversationAsync(input, tasks);
50+
await analyzeConversationOperation.WaitForCompletionAsync();
51+
```
52+
53+
You can finally print the results:
54+
55+
```C# Snippet:StartAnalyzeConversation_ConversationPII_Text_Results
56+
var jobResults = analyzeConversationOperation.Value;
57+
foreach (var result in jobResults.Tasks.Items)
58+
{
59+
var analyzeConversationPIIResult = result as AnalyzeConversationPIIResult;
60+
61+
var results = analyzeConversationPIIResult.Results;
62+
63+
Console.WriteLine("Conversations:");
64+
foreach (var conversation in results.Conversations)
65+
{
66+
Console.WriteLine($"Conversation #:{conversation.Id}");
67+
Console.WriteLine("Conversation Items: ");
68+
foreach (var conversationItem in conversation.ConversationItems)
69+
{
70+
Console.WriteLine($"Conversation Item #:{conversationItem.Id}");
71+
72+
Console.WriteLine($"Redacted Text: {conversationItem.RedactedContent.Text}");
73+
74+
Console.WriteLine("Entities:");
75+
foreach (var entity in conversationItem.Entities)
76+
{
77+
Console.WriteLine($"Text: {entity.Text}");
78+
Console.WriteLine($"Offset: {entity.Offset}");
79+
Console.WriteLine($"Category: {entity.Category}");
80+
Console.WriteLine($"Confidence Score: {entity.ConfidenceScore}");
81+
Console.WriteLine($"Length: {entity.Length}");
82+
Console.WriteLine();
83+
}
84+
}
85+
Console.WriteLine();
86+
}
87+
}
88+
```

0 commit comments

Comments
 (0)