Encamina.Enmarcha.AI.QuestionsAnswering.Azure
8.2.0
dotnet add package Encamina.Enmarcha.AI.QuestionsAnswering.Azure --version 8.2.0
NuGet\Install-Package Encamina.Enmarcha.AI.QuestionsAnswering.Azure -Version 8.2.0
<PackageReference Include="Encamina.Enmarcha.AI.QuestionsAnswering.Azure" Version="8.2.0" />
paket add Encamina.Enmarcha.AI.QuestionsAnswering.Azure --version 8.2.0
#r "nuget: Encamina.Enmarcha.AI.QuestionsAnswering.Azure, 8.2.0"
// Install Encamina.Enmarcha.AI.QuestionsAnswering.Azure as a Cake Addin #addin nuget:?package=Encamina.Enmarcha.AI.QuestionsAnswering.Azure&version=8.2.0 // Install Encamina.Enmarcha.AI.QuestionsAnswering.Azure as a Cake Tool #tool nuget:?package=Encamina.Enmarcha.AI.QuestionsAnswering.Azure&version=8.2.0
AI - Azure Questions Answering
Azure Intent Prediction is a wrapper project for Azure Cognitive Language Services Question Answering client library. Its main functionality is to simplify and abstract the usage of the library, primarily focused on question answering.
Setup
Nuget package
First, install NuGet. Then, install Encamina.Enmarcha.AI.QuestionsAnswering.Azure from the package manager console:
PM> Install-Package Encamina.Enmarcha.AI.QuestionsAnswering.Azure
.NET CLI:
Install .NET CLI. Next, install Encamina.Enmarcha.AI.QuestionsAnswering.Azure from the .NET CLI:
dotnet add package Encamina.Enmarcha.AI.QuestionsAnswering.Azure
How to use
Question Answering
First, you need to add the QuestionAnsweringConfigurations to your project configuration. You can achieve this by using any configuration provider. The followng code is an example of how the settings would appear using the appsettings.json file:
{
// ...
"QuestionAnsweringConfigurations": {
"QuestionAnsweringOptions": [
{
"Name": "DefaultQuestionAnswering", // Name of this configuration
"EndpointUrl": "https://example.cognitiveservices.azure.com/", // Language Service endpoint's url
"KeyCredential": "<API-KEY>", // Language Service (security) key
"DeploymentSlot": "development", // Deployment type, allowing the 'test' and 'prod' ('production' works as well)
"KnowledgeBaseName": "<YOUR-PROJECT-NAME>", // Name of the Question Answering project in Language Service which represents a Knowledge Base
"ConfidenceThreshold": 0.65, // Minimum threshold score for answers, value ranges from 0 to 1
"Top": 3 // Maximum number of answers to be returned per question.
}
]
}
// ...
}
Next, in Program.cs
or a similar entry point file in your project, add the following code.
// Entry point
var builder = WebApplication.CreateBuilder(new WebApplicationOptions
{
// ...
});
// ...
// Or others configuration providers...
builder.Configuration.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
builder.Services.AddDefaultCognitiveServiceProvider()
.AddAzureQuestionAnsweringServices(builder.Configuration);
The extension methods AddDefaultCognitiveServiceProvider
and AddAzureQuestionAnsweringServices
manage the configuration to create instances of ICognitiveServiceProvider
. With this, you can retrieve instances of IQuestionAnsweringService
(whose implementation is QuestionAnsweringService). As seen in the configuration JSON, QuestionAnsweringConfigurations
is an array, allowing you to generate different Question Answerings configurations and retrieve the appropriate one based on the Name
. Now, you can inject ICognitiveServiceProvider
through the constructor for use.
public class MyClass
{
private readonly IQuestionAnsweringService questionAnsweringService;
public MyClass(ICognitiveServiceProvider cognitiveServiceProvider)
{
// The value "DefaultQuestionAnswering" is the name specified in the JSON from the previous code.
// This is just an example code; avoid hardcoding strings :)
questionAnsweringService = cognitiveServiceProvider.GetQuestionsAnsweringService("DefaultQuestionAnswering");
}
public async Task<string> GetAnswerAsync(string userInput, CancellationToken cancellationToken)
{
var questionRequest = new QuestionRequest() { Question = userInput };
var questionResult = await questionAnsweringService.GetAnswersAsync(questionRequest, CancellationToken.None);
return questionResult.Answers.MaxBy(d => d.ConfidenceScore).Value;
}
}
Metadata Handler
CachedTableStorageCompositeMetadataHandler provides metadata handling using parameters stored in an Azure Table Storage with the optional posibility to cached these parameters to improve performance. First, you need to add the Azure Storage data to your project configuration. You can achieve this by using any configuration provider. The followng code is an example of how the settings would appear using the appsettings.json
file:
{
// ...
"ConnectionStrings": {
"TableStorage": "<TABLE-STORAGE-CONNECTION-STRING>" // Table Storage connection string
},
"TableName": "Metadata", // Table Storage table name
// ...
}
Next, in Program.cs
or a similar entry point file in your project, add the following code.
// Entry point
var builder = WebApplication.CreateBuilder(new WebApplicationOptions
{
// ...
});
// ...
// Or others configuration providers...
builder.Configuration.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
builder.Services.AddCachedTableStorageCompositeMetadataHandler(options =>
{
options.TableConnectionString = builder.Configuration.GetConnectionString("TableStorage");
options.TableName = builder.Configuration.GetValue<string>("TableName");
});
The extension methods AddCachedTableStorageCompositeMetadataHandler
manages of configuring everything necessary to create instances of IMetadataHandler
based on CachedTableStorageCompositeMetadataHandler implementation. Now, you can inject IMetadataHandler
through the constructor for use.
public class MyClass
{
private readonly IMetadataHandler metadataHandler;
public MyClass(IMetadataHandler metadataHandler)
{
this.metadataHandler = metadataHandler;
}
public async Task<IDictionary<string, string>> GetMetadataAsync(string message, CancellationToken cancellationToken)
{
var metadataOptions = await metadataHandler.HandleMessageAsync(message, currentMetadataOptions: null, cancellationToken);
return metadataOptions.Metadata;
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Azure.AI.Language.QuestionAnswering (>= 1.1.0)
- Azure.Data.Tables (>= 12.9.0)
- CommunityToolkit.Diagnostics (>= 8.2.2)
- Encamina.Enmarcha.AI (>= 8.2.0)
- Encamina.Enmarcha.AI.Abstractions (>= 8.2.0)
- Microsoft.Extensions.Caching.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Hosting (>= 8.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 8.0.0)
- System.Linq.Async (>= 6.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
8.2.0 | 62 | 10/22/2024 |
8.2.0-preview-01-m01 | 95 | 9/17/2024 |
8.1.9-preview-02 | 53 | 10/22/2024 |
8.1.9-preview-01 | 62 | 10/4/2024 |
8.1.8 | 80 | 9/23/2024 |
8.1.8-preview-07 | 77 | 9/12/2024 |
8.1.8-preview-06 | 73 | 9/11/2024 |
8.1.8-preview-05 | 77 | 9/10/2024 |
8.1.8-preview-04 | 98 | 8/16/2024 |
8.1.8-preview-03 | 86 | 8/13/2024 |
8.1.8-preview-02 | 88 | 8/13/2024 |
8.1.8-preview-01 | 92 | 8/12/2024 |
8.1.7 | 98 | 8/7/2024 |
8.1.7-preview-09 | 60 | 7/3/2024 |
8.1.7-preview-08 | 87 | 7/2/2024 |
8.1.7-preview-07 | 81 | 6/10/2024 |
8.1.7-preview-06 | 82 | 6/10/2024 |
8.1.7-preview-05 | 80 | 6/6/2024 |
8.1.7-preview-04 | 84 | 6/6/2024 |
8.1.7-preview-03 | 92 | 5/24/2024 |
8.1.7-preview-02 | 88 | 5/10/2024 |
8.1.7-preview-01 | 92 | 5/8/2024 |
8.1.6 | 1,101 | 5/7/2024 |
8.1.6-preview-08 | 59 | 5/2/2024 |
8.1.6-preview-07 | 90 | 4/29/2024 |
8.1.6-preview-06 | 103 | 4/26/2024 |
8.1.6-preview-05 | 85 | 4/24/2024 |
8.1.6-preview-04 | 86 | 4/22/2024 |
8.1.6-preview-03 | 89 | 4/22/2024 |
8.1.6-preview-02 | 96 | 4/17/2024 |
8.1.6-preview-01 | 184 | 4/15/2024 |
8.1.5 | 117 | 4/15/2024 |
8.1.5-preview-15 | 101 | 4/10/2024 |
8.1.5-preview-14 | 101 | 3/20/2024 |
8.1.5-preview-13 | 96 | 3/18/2024 |
8.1.5-preview-12 | 110 | 3/13/2024 |
8.1.5-preview-11 | 83 | 3/13/2024 |
8.1.5-preview-10 | 83 | 3/13/2024 |
8.1.5-preview-09 | 85 | 3/12/2024 |
8.1.5-preview-08 | 54 | 3/12/2024 |
8.1.5-preview-07 | 81 | 3/8/2024 |
8.1.5-preview-06 | 75 | 3/8/2024 |
8.1.5-preview-05 | 81 | 3/7/2024 |
8.1.5-preview-04 | 88 | 3/7/2024 |
8.1.5-preview-03 | 78 | 3/7/2024 |
8.1.5-preview-02 | 93 | 2/28/2024 |
8.1.5-preview-01 | 92 | 2/19/2024 |
8.1.4 | 159 | 2/15/2024 |
8.1.3 | 121 | 2/13/2024 |
8.1.3-preview-07 | 82 | 2/13/2024 |
8.1.3-preview-06 | 95 | 2/12/2024 |
8.1.3-preview-05 | 74 | 2/9/2024 |
8.1.3-preview-04 | 83 | 2/8/2024 |
8.1.3-preview-03 | 87 | 2/7/2024 |
8.1.3-preview-02 | 97 | 2/2/2024 |
8.1.3-preview-01 | 88 | 2/2/2024 |
8.1.2 | 117 | 2/1/2024 |
8.1.2-preview-9 | 97 | 1/22/2024 |
8.1.2-preview-8 | 82 | 1/19/2024 |
8.1.2-preview-7 | 85 | 1/19/2024 |
8.1.2-preview-6 | 67 | 1/19/2024 |
8.1.2-preview-5 | 85 | 1/19/2024 |
8.1.2-preview-4 | 81 | 1/19/2024 |
8.1.2-preview-3 | 86 | 1/18/2024 |
8.1.2-preview-2 | 78 | 1/18/2024 |
8.1.2-preview-16 | 79 | 1/31/2024 |
8.1.2-preview-15 | 73 | 1/31/2024 |
8.1.2-preview-14 | 83 | 1/25/2024 |
8.1.2-preview-13 | 71 | 1/25/2024 |
8.1.2-preview-12 | 101 | 1/23/2024 |
8.1.2-preview-11 | 75 | 1/23/2024 |
8.1.2-preview-10 | 78 | 1/22/2024 |
8.1.2-preview-1 | 81 | 1/18/2024 |
8.1.1 | 116 | 1/18/2024 |
8.1.0 | 98 | 1/18/2024 |
8.0.3 | 144 | 12/29/2023 |
8.0.1 | 149 | 12/14/2023 |
8.0.0 | 137 | 12/7/2023 |
6.0.4.3 | 118 | 12/29/2023 |
6.0.4.2 | 119 | 12/20/2023 |
6.0.4.1 | 216 | 12/19/2023 |
6.0.4 | 146 | 12/4/2023 |
6.0.3.20 | 118 | 11/27/2023 |
6.0.3.19 | 123 | 11/22/2023 |