Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare Conversations Language Understanding SDK 1.1.0-beta.1 #29144

Merged
merged 8 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
## 1.1.0-beta.1 (Unreleased)

### Features Added
* Added Conversation issue summarization task (Long-running operation)
* Added Conversation PII extraction task (Long-running operation)

### Breaking Changes
- Client now uses python dictionaries for method parameters and results instead of classes.
- Many input and result parameter name changes in `analyze_conversation()` method
* Added `ConversationAnalysisProjectsClient` to manage projects.
* Added conversation issue summarization as a long-running operation.
* Added conversation personally identifiable information (PII) extraction as a long-running operation.

### Bugs Fixed
### Breaking Changes

### Other Changes
- Removed all models. See README.md for samples to use this client library.

## 1.0.0-beta.3 (2022-04-20)

Expand Down
793 changes: 512 additions & 281 deletions sdk/cognitivelanguage/Azure.AI.Language.Conversations/README.md

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,56 @@
using System.Threading;
using System.Threading.Tasks;
using Azure.AI.Language.Conversations.Perf.Infrastructure;
using Azure.Core;
using Azure.Test.Perf;
using CommandLine;

namespace Azure.AI.Language.Conversations.Perf.Scenarios
{
public class AnalyzeConversation : AnalysisScenarioBase<AnalyzeConversation.ConversationAnalysisClient>
{
private RequestContent _content;

public AnalyzeConversation(ConversationAnalysisClient options) : base(options)
{
}

public override Task SetupAsync()
{
var data = new
{
analysisInput = new
{
conversationItem = new
{
text = "Send an email to Carol about the tomorrow's demo",
id = "1",
participantId = "1",
}
},
parameters = new
{
projectName = TestEnvironment.ProjectName,
deploymentName = TestEnvironment.DeploymentName,

// Use Utf16CodeUnit for Strings in .NET.
stringIndexType = "Utf16CodeUnit",
},
kind = "Conversation",
};

_content = RequestContent.Create(data);
return Task.CompletedTask;
}

public override void Run(CancellationToken cancellationToken)
{
Client.AnalyzeConversation("Send an email to Carol about the tomorrow's demo", TestEnvironment.Project);
Client.AnalyzeConversation(_content);
}

public override async Task RunAsync(CancellationToken cancellationToken)
{
await Client.AnalyzeConversationAsync("Send an email to Carol about the tomorrow's demo", TestEnvironment.Project);
await Client.AnalyzeConversationAsync(_content);
}

public class ConversationAnalysisClient : PerfOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ Conversation Analysis is a cloud-based conversational AI service that applies cu
- [Analyze an utterance - Conversation project](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/cognitivelanguage/Azure.AI.Language.Conversations/samples/Sample1_AnalyzeConversation_ConversationPrediction.md)
- [Analyze an utterance - Orchestration project](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/cognitivelanguage/Azure.AI.Language.Conversations/samples/Sample2_AnalyzeConversation_OrchestrationPrediction.md)
- [Analyze an utterance in a different language](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/cognitivelanguage/Azure.AI.Language.Conversations/samples/Sample3_AnalyzeConversationWithLanguage.md)
- [Analyze an utterance using extra options](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/cognitivelanguage/Azure.AI.Language.Conversations/samples/Sample4_AnalyzeConversationWithOptions.md)
- [Analyze an utterance using extra options](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/cognitivelanguage/Azure.AI.Language.Conversations/samples/Sample4_AnalyzeConversationWithOptions.md)
- [Analyze a conversation with Conversation Summarization](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/cognitivelanguage/Azure.AI.Language.Conversations/samples/Sample5_SubmitJob_ConversationSummarization.md)
- [Analyze a conversation with Conversation PII using text input](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/cognitivelanguage/Azure.AI.Language.Conversations/samples/Sample6_SubmitJob_ConversationPII_Text.md)
- [Analyze a conversation with Conversation PII using transcript input](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/cognitivelanguage/Azure.AI.Language.Conversations/samples/Sample7_SubmitJob_ConversationPII_Transcript.md)
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,69 @@ Once you have created a client, you can call synchronous or asynchronous methods
## Synchronous

```C# Snippet:ConversationAnalysis_AnalyzeConversation
ConversationsProject conversationsProject = new ConversationsProject("Menu", "production");
string projectName = "Menu";
string deploymentName = "production";

Response<AnalyzeConversationTaskResult> response = client.AnalyzeConversation(
"Send an email to Carol about the tomorrow's demo.",
conversationsProject);
var data = new
{
analysisInput = new
{
conversationItem = new
{
text = "Send an email to Carol about tomorrow's demo",
id = "1",
participantId = "1",
}
},
parameters = new
{
projectName,
deploymentName,

CustomConversationalTaskResult customConversationalTaskResult = response.Value as CustomConversationalTaskResult;
ConversationPrediction conversationPrediction = customConversationalTaskResult.Result.Prediction as ConversationPrediction;
// Use Utf16CodeUnit for strings in .NET.
stringIndexType = "Utf16CodeUnit",
},
kind = "Conversation",
};

Console.WriteLine($"Top intent: {conversationPrediction.TopIntent}");
Response response = client.AnalyzeConversation(RequestContent.Create(data));

using JsonDocument result = JsonDocument.Parse(response.ContentStream);
JsonElement conversationalTaskResult = result.RootElement;
JsonElement conversationPrediction = conversationalTaskResult.GetProperty("result").GetProperty("prediction");

Console.WriteLine($"Top intent: {conversationPrediction.GetProperty("topIntent").GetString()}");

Console.WriteLine("Intents:");
foreach (ConversationIntent intent in conversationPrediction.Intents)
foreach (JsonElement intent in conversationPrediction.GetProperty("intents").EnumerateArray())
{
Console.WriteLine($"Category: {intent.Category}");
Console.WriteLine($"Confidence: {intent.Confidence}");
Console.WriteLine($"Category: {intent.GetProperty("category").GetString()}");
Console.WriteLine($"Confidence: {intent.GetProperty("confidenceScore").GetSingle()}");
Console.WriteLine();
}

Console.WriteLine("Entities:");
foreach (ConversationEntity entity in conversationPrediction.Entities)
foreach (JsonElement entity in conversationPrediction.GetProperty("entities").EnumerateArray())
{
Console.WriteLine($"Category: {entity.Category}");
Console.WriteLine($"Text: {entity.Text}");
Console.WriteLine($"Offset: {entity.Offset}");
Console.WriteLine($"Length: {entity.Length}");
Console.WriteLine($"Confidence: {entity.Confidence}");
Console.WriteLine($"Category: {entity.GetProperty("category").GetString()}");
Console.WriteLine($"Text: {entity.GetProperty("text").GetString()}");
Console.WriteLine($"Offset: {entity.GetProperty("offset").GetInt32()}");
Console.WriteLine($"Length: {entity.GetProperty("length").GetInt32()}");
Console.WriteLine($"Confidence: {entity.GetProperty("confidenceScore").GetSingle()}");
Console.WriteLine();

foreach (BaseResolution resolution in entity.Resolutions)
if (!entity.TryGetProperty("resolutions", out JsonElement resolutions))
{
continue;
}

foreach (JsonElement resolution in resolutions.EnumerateArray())
{
if (resolution is DateTimeResolution dateTimeResolution)
if (resolution.GetProperty("resolutionKind").GetString() == "DateTimeResolution")
{
Console.WriteLine($"Datetime Sub Kind: {dateTimeResolution.DateTimeSubKind}");
Console.WriteLine($"Timex: {dateTimeResolution.Timex}");
Console.WriteLine($"Value: {dateTimeResolution.Value}");
Console.WriteLine($"Datetime Sub Kind: {resolution.GetProperty("dateTimeSubKind").GetString()}");
Console.WriteLine($"Timex: {resolution.GetProperty("timex").GetString()}");
Console.WriteLine($"Value: {resolution.GetProperty("value").GetString()}");
Console.WriteLine();
}
}
Expand All @@ -61,43 +88,69 @@ foreach (ConversationEntity entity in conversationPrediction.Entities)
## Asynchronous

```C# Snippet:ConversationAnalysis_AnalyzeConversationAsync
ConversationsProject conversationsProject = new ConversationsProject("Menu", "production");
string projectName = "Menu";
string deploymentName = "production";

Response<AnalyzeConversationTaskResult> response = await client.AnalyzeConversationAsync(
"Send an email to Carol about the tomorrow's demo.",
conversationsProject);
var data = new
{
analysisInput = new
{
conversationItem = new
{
text = "Send an email to Carol about tomorrow's demo",
id = "1",
participantId = "1",
}
},
parameters = new
{
projectName,
deploymentName,

CustomConversationalTaskResult customConversationalTaskResult = response.Value as CustomConversationalTaskResult;
ConversationPrediction conversationPrediction = customConversationalTaskResult.Result.Prediction as ConversationPrediction;
// Use Utf16CodeUnit for strings in .NET.
stringIndexType = "Utf16CodeUnit",
},
kind = "Conversation",
};

Console.WriteLine($"Project Kind: {customConversationalTaskResult.Result.Prediction.ProjectKind}");
Console.WriteLine($"Top intent: {conversationPrediction.TopIntent}");
Response response = await client.AnalyzeConversationAsync(RequestContent.Create(data));

using JsonDocument result = await JsonDocument.ParseAsync(response.ContentStream);
JsonElement conversationalTaskResult = result.RootElement;
JsonElement conversationPrediction = conversationalTaskResult.GetProperty("result").GetProperty("prediction");

Console.WriteLine($"Top intent: {conversationPrediction.GetProperty("topIntent").GetString()}");

Console.WriteLine("Intents:");
foreach (ConversationIntent intent in conversationPrediction.Intents)
foreach (JsonElement intent in conversationPrediction.GetProperty("intents").EnumerateArray())
{
Console.WriteLine($"Category: {intent.Category}");
Console.WriteLine($"Confidence: {intent.Confidence}");
Console.WriteLine($"Category: {intent.GetProperty("category").GetString()}");
Console.WriteLine($"Confidence: {intent.GetProperty("confidenceScore").GetSingle()}");
Console.WriteLine();
}

Console.WriteLine("Entities:");
foreach (ConversationEntity entity in conversationPrediction.Entities)
foreach (JsonElement entity in conversationPrediction.GetProperty("entities").EnumerateArray())
{
Console.WriteLine($"Category: {entity.Category}");
Console.WriteLine($"Text: {entity.Text}");
Console.WriteLine($"Offset: {entity.Offset}");
Console.WriteLine($"Length: {entity.Length}");
Console.WriteLine($"Confidence: {entity.Confidence}");
Console.WriteLine($"Category: {entity.GetProperty("category").GetString()}");
Console.WriteLine($"Text: {entity.GetProperty("text").GetString()}");
Console.WriteLine($"Offset: {entity.GetProperty("offset").GetInt32()}");
Console.WriteLine($"Length: {entity.GetProperty("length").GetInt32()}");
Console.WriteLine($"Confidence: {entity.GetProperty("confidenceScore").GetSingle()}");
Console.WriteLine();

foreach (BaseResolution resolution in entity.Resolutions)
if (!entity.TryGetProperty("resolutions", out JsonElement resolutions))
{
continue;
}

foreach (JsonElement resolution in resolutions.EnumerateArray())
{
if (resolution is DateTimeResolution dateTimeResolution)
if (resolution.GetProperty("resolutionKind").GetString() == "DateTimeResolution")
{
Console.WriteLine($"Datetime Sub Kind: {dateTimeResolution.DateTimeSubKind}");
Console.WriteLine($"Timex: {dateTimeResolution.Timex}");
Console.WriteLine($"Value: {dateTimeResolution.Value}");
Console.WriteLine($"Datetime Sub Kind: {resolution.GetProperty("dateTimeSubKind").GetString()}");
Console.WriteLine($"Timex: {resolution.GetProperty("timex").GetString()}");
Console.WriteLine($"Value: {resolution.GetProperty("value").GetString()}");
Console.WriteLine();
}
}
Expand Down
Loading