Skip to content

Commit

Permalink
Resolve archboard feedback for CLU 1.0 GA (Azure#29340)
Browse files Browse the repository at this point in the history
* Resolve archboard feedback

Partial resolution for Azure#29331

* Delete local swagger used for testing changes

* Fix Sample5 typo

* Add some recorded tests to check multilingual transform

* Fix tests post-rebase

* Rename ConveratinAnalysisProjectsClient to ConversationAuthoringClient

* Remove explicit pageable parameters

...until Azure#29342 is resolved
  • Loading branch information
heaths authored and sofiar-msft committed Dec 7, 2022
1 parent d04dd03 commit e810ced
Show file tree
Hide file tree
Showing 32 changed files with 1,195 additions and 725 deletions.
32 changes: 21 additions & 11 deletions sdk/cognitivelanguage/Azure.AI.Language.Conversations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ dotnet add package Azure.AI.Language.Conversations --prerelease
- An [Azure subscription][azure_subscription]
- An existing Azure Language Service Resource

Though you can use this SDK to create and import conversation projects, [Language Studio][language_studio] is the preferred method for creating projects.

### Authenticate the client

In order to interact with the Conversations service, you'll need to create an instance of the [`ConversationAnalysisClient`][conversationanalysis_client_class] class. You will need an **endpoint**, and an **API key** to instantiate a client object. For more information regarding authenticating with Cognitive Services, see [Authenticate requests to Azure Cognitive Services][cognitive_auth].
Expand All @@ -36,6 +38,15 @@ Alternatively, use the [Azure CLI][azure_cli] command shown below to get the API
az cognitiveservices account keys list --resource-group <resource-group-name> --name <resource-name>
```

#### Namespaces

Start by importing the namespace for the [`ConversationAnalysisClient`][conversationanalysis_client_class] and related class:

```C# Snippet:ConversationAnalysisClient_Namespaces
using Azure.Core;
using Azure.AI.Language.Conversations;
```

#### Create a ConversationAnalysisClient

Once you've determined your **endpoint** and **API key** you can instantiate a `ConversationAnalysisClient`:
Expand Down Expand Up @@ -131,19 +142,17 @@ foreach (JsonElement entity in conversationPrediction.GetProperty("entities").En
Console.WriteLine($"Confidence: {entity.GetProperty("confidenceScore").GetSingle()}");
Console.WriteLine();

if (!entity.TryGetProperty("resolutions", out JsonElement resolutions))
if (entity.TryGetProperty("resolutions", out JsonElement resolutions))
{
continue;
}

foreach (JsonElement resolution in resolutions.EnumerateArray())
{
if (resolution.GetProperty("resolutionKind").GetString() == "DateTimeResolution")
foreach (JsonElement resolution in resolutions.EnumerateArray())
{
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();
if (resolution.GetProperty("resolutionKind").GetString() == "DateTimeResolution")
{
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 Expand Up @@ -389,6 +398,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con
[cognitive_auth]: https://docs.microsoft.com/azure/cognitive-services/authentication/
[contributing]: https://github.com/Azure/azure-sdk-for-net/blob/main/CONTRIBUTING.md
[core_logging]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/Diagnostics.md
[language_studio]: https://language.cognitive.azure.com/
[nuget]: https://www.nuget.org/

[conversationanalysis_client_class]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/cognitivelanguage/Azure.AI.Language.Conversations/src/ConversationAnalysisClient.cs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ public enum ServiceVersion
V2022_05_01 = 1,
}
}
public partial class ConversationAnalysisProjectsClient
}
namespace Azure.AI.Language.Conversations.Authoring
{
public partial class ConversationAuthoringClient
{
protected ConversationAnalysisProjectsClient() { }
public ConversationAnalysisProjectsClient(System.Uri endpoint, Azure.AzureKeyCredential credential) { }
public ConversationAnalysisProjectsClient(System.Uri endpoint, Azure.AzureKeyCredential credential, Azure.AI.Language.Conversations.ConversationAnalysisClientOptions options) { }
protected ConversationAuthoringClient() { }
public ConversationAuthoringClient(System.Uri endpoint, Azure.AzureKeyCredential credential) { }
public ConversationAuthoringClient(System.Uri endpoint, Azure.AzureKeyCredential credential, Azure.AI.Language.Conversations.ConversationAnalysisClientOptions options) { }
public virtual System.Uri Endpoint { get { throw null; } }
public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } }
public virtual Azure.Operation<System.BinaryData> CancelTrainingJob(Azure.WaitUntil waitUntil, string projectName, string jobId, Azure.RequestContext context = null) { throw null; }
Expand All @@ -43,36 +46,36 @@ public ConversationAnalysisProjectsClient(System.Uri endpoint, Azure.AzureKeyCre
public virtual System.Threading.Tasks.Task<Azure.Response> GetDeploymentAsync(string projectName, string deploymentName, Azure.RequestContext context = null) { throw null; }
public virtual Azure.Response GetDeploymentJobStatus(string projectName, string deploymentName, string jobId, Azure.RequestContext context = null) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> GetDeploymentJobStatusAsync(string projectName, string deploymentName, string jobId, Azure.RequestContext context = null) { throw null; }
public virtual Azure.Pageable<System.BinaryData> GetDeployments(string projectName, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), Azure.RequestContext context = null) { throw null; }
public virtual Azure.AsyncPageable<System.BinaryData> GetDeploymentsAsync(string projectName, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), Azure.RequestContext context = null) { throw null; }
public virtual Azure.Pageable<System.BinaryData> GetDeployments(string projectName, Azure.RequestContext context = null) { throw null; }
public virtual Azure.AsyncPageable<System.BinaryData> GetDeploymentsAsync(string projectName, Azure.RequestContext context = null) { throw null; }
public virtual Azure.Response GetExportProjectJobStatus(string projectName, string jobId, Azure.RequestContext context = null) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> GetExportProjectJobStatusAsync(string projectName, string jobId, Azure.RequestContext context = null) { throw null; }
public virtual Azure.Response GetImportProjectJobStatus(string projectName, string jobId, Azure.RequestContext context = null) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> GetImportProjectJobStatusAsync(string projectName, string jobId, Azure.RequestContext context = null) { throw null; }
public virtual Azure.Pageable<System.BinaryData> GetModelEvaluationResults(string projectName, string trainedModelLabel, string stringIndexType = "Utf16CodeUnit", int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), Azure.RequestContext context = null) { throw null; }
public virtual Azure.AsyncPageable<System.BinaryData> GetModelEvaluationResultsAsync(string projectName, string trainedModelLabel, string stringIndexType = "Utf16CodeUnit", int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), Azure.RequestContext context = null) { throw null; }
public virtual Azure.Pageable<System.BinaryData> GetModelEvaluationResults(string projectName, string trainedModelLabel, string stringIndexType = "Utf16CodeUnit", Azure.RequestContext context = null) { throw null; }
public virtual Azure.AsyncPageable<System.BinaryData> GetModelEvaluationResultsAsync(string projectName, string trainedModelLabel, string stringIndexType = "Utf16CodeUnit", Azure.RequestContext context = null) { throw null; }
public virtual Azure.Response GetModelEvaluationSummary(string projectName, string trainedModelLabel, Azure.RequestContext context = null) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> GetModelEvaluationSummaryAsync(string projectName, string trainedModelLabel, Azure.RequestContext context = null) { throw null; }
public virtual Azure.Response GetProject(string projectName, Azure.RequestContext context = null) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> GetProjectAsync(string projectName, Azure.RequestContext context = null) { throw null; }
public virtual Azure.Response GetProjectDeletionJobStatus(string jobId, Azure.RequestContext context = null) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> GetProjectDeletionJobStatusAsync(string jobId, Azure.RequestContext context = null) { throw null; }
public virtual Azure.Pageable<System.BinaryData> GetProjects(int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), Azure.RequestContext context = null) { throw null; }
public virtual Azure.AsyncPageable<System.BinaryData> GetProjectsAsync(int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), Azure.RequestContext context = null) { throw null; }
public virtual Azure.Pageable<System.BinaryData> GetSupportedLanguages(string projectKind, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), Azure.RequestContext context = null) { throw null; }
public virtual Azure.AsyncPageable<System.BinaryData> GetSupportedLanguagesAsync(string projectKind, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), Azure.RequestContext context = null) { throw null; }
public virtual Azure.Pageable<System.BinaryData> GetSupportedPrebuiltEntities(string language = null, bool? multilingual = default(bool?), int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), Azure.RequestContext context = null) { throw null; }
public virtual Azure.AsyncPageable<System.BinaryData> GetSupportedPrebuiltEntitiesAsync(string language = null, bool? multilingual = default(bool?), int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), Azure.RequestContext context = null) { throw null; }
public virtual Azure.Pageable<System.BinaryData> GetProjects(Azure.RequestContext context = null) { throw null; }
public virtual Azure.AsyncPageable<System.BinaryData> GetProjectsAsync(Azure.RequestContext context = null) { throw null; }
public virtual Azure.Pageable<System.BinaryData> GetSupportedLanguages(string projectKind, Azure.RequestContext context = null) { throw null; }
public virtual Azure.AsyncPageable<System.BinaryData> GetSupportedLanguagesAsync(string projectKind, Azure.RequestContext context = null) { throw null; }
public virtual Azure.Pageable<System.BinaryData> GetSupportedPrebuiltEntities(string language = null, bool? multilingual = default(bool?), Azure.RequestContext context = null) { throw null; }
public virtual Azure.AsyncPageable<System.BinaryData> GetSupportedPrebuiltEntitiesAsync(string language = null, bool? multilingual = default(bool?), Azure.RequestContext context = null) { throw null; }
public virtual Azure.Response GetSwapDeploymentsJobStatus(string projectName, string jobId, Azure.RequestContext context = null) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> GetSwapDeploymentsJobStatusAsync(string projectName, string jobId, Azure.RequestContext context = null) { throw null; }
public virtual Azure.Response GetTrainedModel(string projectName, string trainedModelLabel, Azure.RequestContext context = null) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> GetTrainedModelAsync(string projectName, string trainedModelLabel, Azure.RequestContext context = null) { throw null; }
public virtual Azure.Pageable<System.BinaryData> GetTrainedModels(string projectName, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), Azure.RequestContext context = null) { throw null; }
public virtual Azure.AsyncPageable<System.BinaryData> GetTrainedModelsAsync(string projectName, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), Azure.RequestContext context = null) { throw null; }
public virtual Azure.Pageable<System.BinaryData> GetTrainingConfigVersions(string projectKind, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), Azure.RequestContext context = null) { throw null; }
public virtual Azure.AsyncPageable<System.BinaryData> GetTrainingConfigVersionsAsync(string projectKind, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), Azure.RequestContext context = null) { throw null; }
public virtual Azure.Pageable<System.BinaryData> GetTrainingJobs(string projectName, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), Azure.RequestContext context = null) { throw null; }
public virtual Azure.AsyncPageable<System.BinaryData> GetTrainingJobsAsync(string projectName, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), Azure.RequestContext context = null) { throw null; }
public virtual Azure.Pageable<System.BinaryData> GetTrainedModels(string projectName, Azure.RequestContext context = null) { throw null; }
public virtual Azure.AsyncPageable<System.BinaryData> GetTrainedModelsAsync(string projectName, Azure.RequestContext context = null) { throw null; }
public virtual Azure.Pageable<System.BinaryData> GetTrainingConfigVersions(string projectKind, Azure.RequestContext context = null) { throw null; }
public virtual Azure.AsyncPageable<System.BinaryData> GetTrainingConfigVersionsAsync(string projectKind, Azure.RequestContext context = null) { throw null; }
public virtual Azure.Pageable<System.BinaryData> GetTrainingJobs(string projectName, Azure.RequestContext context = null) { throw null; }
public virtual Azure.AsyncPageable<System.BinaryData> GetTrainingJobsAsync(string projectName, Azure.RequestContext context = null) { throw null; }
public virtual Azure.Response GetTrainingJobStatus(string projectName, string jobId, Azure.RequestContext context = null) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> GetTrainingJobStatusAsync(string projectName, string jobId, Azure.RequestContext context = null) { throw null; }
public virtual Azure.Operation<System.BinaryData> ImportProject(Azure.WaitUntil waitUntil, string projectName, Azure.Core.RequestContent content, string exportedProjectFormat = null, Azure.RequestContext context = null) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,51 +67,26 @@ foreach (JsonElement entity in conversationPrediction.GetProperty("entities").En
Console.WriteLine($"Confidence: {entity.GetProperty("confidenceScore").GetSingle()}");
Console.WriteLine();

if (!entity.TryGetProperty("resolutions", out JsonElement resolutions))
if (entity.TryGetProperty("resolutions", out JsonElement resolutions))
{
continue;
}

foreach (JsonElement resolution in resolutions.EnumerateArray())
{
if (resolution.GetProperty("resolutionKind").GetString() == "DateTimeResolution")
foreach (JsonElement resolution in resolutions.EnumerateArray())
{
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();
if (resolution.GetProperty("resolutionKind").GetString() == "DateTimeResolution")
{
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();
}
}
}
}
```

## Asynchronous

```C# Snippet:ConversationAnalysis_AnalyzeConversationAsync
string projectName = "Menu";
string deploymentName = "production";

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,

// Use Utf16CodeUnit for strings in .NET.
stringIndexType = "Utf16CodeUnit",
},
kind = "Conversation",
};
Using the same `data` definition above, you can make an asynchronous request by calling `AnalyzeConversationAsync`:

```C# Snippet:ConversationAnalysis_AnalyzeConversationAsync
Response response = await client.AnalyzeConversationAsync(RequestContent.Create(data));
```
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,9 @@ JsonElement orchestrationPrediction = conversationalTaskResult.GetProperty("resu

## Asynchronous

```C# Snippet:ConversationAnalysis_AnalyzeConversationOrchestrationPredictionAsync
string projectName = "DomainOrchestrator";
string deploymentName = "production";

var data = new
{
analysisInput = new
{
conversationItem = new
{
text = "How are you?",
id = "1",
participantId = "1",
}
},
parameters = new
{
projectName,
deploymentName,

// Use Utf16CodeUnit for strings in .NET.
stringIndexType = "Utf16CodeUnit",
},
kind = "Conversation",
};
Using the same `data` definition above, you can make an asynchronous request by calling `AnalyzeConversationAsync`:

```C# Snippet:ConversationAnalysis_AnalyzeConversationOrchestrationPredictionAsync
Response response = await client.AnalyzeConversationAsync(RequestContent.Create(data));

using JsonDocument result = await JsonDocument.ParseAsync(response.ContentStream);
Expand Down Expand Up @@ -136,19 +113,17 @@ if (targetIntentResult.GetProperty("targetProjectKind").GetString() == "Conversa
Console.WriteLine($"Length: {entity.GetProperty("length").GetInt32()}");
Console.WriteLine();

if (!entity.TryGetProperty("resolutions", out JsonElement resolutions))
{
continue;
}

foreach (JsonElement resolution in resolutions.EnumerateArray())
if (entity.TryGetProperty("resolutions", out JsonElement resolutions))
{
if (resolution.GetProperty("resolutionKind").GetString() == "DateTimeResolution")
foreach (JsonElement resolution in resolutions.EnumerateArray())
{
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();
if (resolution.GetProperty("resolutionKind").GetString() == "DateTimeResolution")
{
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

0 comments on commit e810ced

Please sign in to comment.