Encamina.Enmarcha.AI 8.2.0

dotnet add package Encamina.Enmarcha.AI --version 8.2.0                
NuGet\Install-Package Encamina.Enmarcha.AI -Version 8.2.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Encamina.Enmarcha.AI" Version="8.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Encamina.Enmarcha.AI --version 8.2.0                
#r "nuget: Encamina.Enmarcha.AI, 8.2.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Encamina.Enmarcha.AI as a Cake Addin
#addin nuget:?package=Encamina.Enmarcha.AI&version=8.2.0

// Install Encamina.Enmarcha.AI as a Cake Tool
#tool nuget:?package=Encamina.Enmarcha.AI&version=8.2.0                

AI

Nuget package

This project contains base classes, interfaces, and common functionalities shared across all ENMARCHA projects related to AI. Essentially, it serves as the common ground for orchestrating the creation and retrieval of cognitive services.

Setup

Nuget package

First, install NuGet. Then, install Encamina.Enmarcha.AI from the package manager console:

PM> Install-Package Encamina.Enmarcha.AI

.NET CLI:

Install .NET CLI. Next, install Encamina.Enmarcha.AI from the .NET CLI:

dotnet add package Encamina.Enmarcha.AI

How to use

The main way to use this project is in conjunction with another ENMARCHA project related to AI. The following code snippet represents the most common usage of this project. Starting from a Program.cs or a similar entry point file in your project, add the following code:

// Entry point
var builder = WebApplication.CreateBuilder(new WebApplicationOptions
{
   // ...
});

// ...

builder.Services.AddDefaultCognitiveServiceProvider();

The AddDefaultCognitiveServiceProvider extension method adds a default cognitive service provider to the IServiceCollection as a singleton. This allows you to resolve the ICognitiveServiceProvider interface, which is responsible for providing instances of cognitive services based on their name. This setup enables you to configure different implementations for the same cognitive service and retrieve them based on their respective names.

public class MyClass
{
    private readonly ICognitiveServiceProvider cognitiveServiceProvider;

    public MyClass(ICognitiveServiceProvider cognitiveServiceProvider)
    {
        this.cognitiveServiceProvider = cognitiveServiceProvider;
    }

    public Task PredictIntentAsync()
    {
        // The name is configured when setting up the Intent Prediction service. This service is not
        // included within this NuGet package.
        var intentPredictionService = cognitiveServiceProvider.GetIntentPredictionService("NAME_OF_INTENT_PREDICTION_SERVICE");

        // Utilizing the Intent Prediction Service...

        return Task.CompletedTask;
    }
}

The above code is not fully functional as the intent prediction service (available in another NuGet package) has yet to be configured.

Another functionality available in this NuGet package is an implementation of ITextSplitter, Specifically RecursiveCharacterTextSplitter. This implementation is the recommended of ITextSplitter for generic texts. It splits texts in order until the chunks are small enough (based on ITextSplitter.ChunkSize). As long as possible, it will strive to keep all paragraphs, sentences, and then words, intact, since those would generically seem to be the strongest semantically related pieces of text that could be split. There is an extension method available to add it directly to the dependency container. First, you need to add the TextSplitterOptions to your project configuration. You can achieve this by using any configuration provider. The following code is an example of the appsettings.json file that contains the TextSplitterOptions settings:

{
    // ...
    "TextSplitterOptions": {
        "ChunkOverlap": 64, // Number of elements (characters, tokens, etc.) overlapping between chunks
        "ChunkSize": 512, // Number of elements (characters, tokens, etc.) in each chunk.
        "Separators": [ "\n\r", "\n\n", "\n", ". ", ", ", " ", "" ] // Collection of separator characters to use when splitting the text and creating chunks
    },
    // ...
}

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.AddOptions<TextSplitterOptions>().Bind(builder.Configuration.GetSection(nameof(TextSplitterOptions)))
    .ValidateDataAnnotations()
    .ValidateOnStart();

builder.Services.AddRecursiveCharacterTextSplitter();

The extension method AddRecursiveCharacterTextSplitter manages to configure everything necessary to create instances of ITextSplitter. With this setup, you can retrieve instances of ITextSplitter (whose implementation is RecursiveCharacterTextSplitter). Now, you can resolve ITextSplitter interface as needed.

public class MyClass
{
    private readonly ITextSplitter textSplitter;

    public MyClass(ITextSplitter textSplitter)
    {
        this.textSplitter = textSplitter;
    }

    public IEnumerable<string> SplitText(string text)
    {        
        return textSplitter.Split(text, lengthFunction: ILengthFunctions.LengthByCharacterCount);
    }
}
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on Encamina.Enmarcha.AI:

Package Downloads
Encamina.Enmarcha.Bot

Package Description

Encamina.Enmarcha.AI.IntentsPrediction.Azure

Package Description

Encamina.Enmarcha.AI.QuestionsAnswering.Azure

Package Description

Encamina.Enmarcha.AI.LanguagesDetection.Azure

Package Description

Encamina.Enmarcha.AI.TextsTranslation.Azure

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.2.0 406 10/22/2024
8.2.0-preview-01-m01 228 9/17/2024
8.1.9-preview-02 171 10/22/2024
8.1.9-preview-01 396 10/4/2024
8.1.8 359 9/23/2024
8.1.8-preview-07 650 9/12/2024
8.1.8-preview-06 348 9/11/2024
8.1.8-preview-05 251 9/10/2024
8.1.8-preview-04 510 8/16/2024
8.1.8-preview-03 303 8/13/2024
8.1.8-preview-02 238 8/13/2024
8.1.8-preview-01 264 8/12/2024
8.1.7 280 8/7/2024
8.1.7-preview-09 265 7/3/2024
8.1.7-preview-08 252 7/2/2024
8.1.7-preview-07 222 6/10/2024
8.1.7-preview-06 217 6/10/2024
8.1.7-preview-05 242 6/6/2024
8.1.7-preview-04 224 6/6/2024
8.1.7-preview-03 249 5/24/2024
8.1.7-preview-02 239 5/10/2024
8.1.7-preview-01 253 5/8/2024
8.1.6 1,374 5/7/2024
8.1.6-preview-08 224 5/2/2024
8.1.6-preview-07 253 4/29/2024
8.1.6-preview-06 624 4/26/2024
8.1.6-preview-05 250 4/24/2024
8.1.6-preview-04 284 4/22/2024
8.1.6-preview-03 243 4/22/2024
8.1.6-preview-02 315 4/17/2024
8.1.6-preview-01 330 4/15/2024
8.1.5 305 4/15/2024
8.1.5-preview-15 267 4/10/2024
8.1.5-preview-14 272 3/20/2024
8.1.5-preview-13 257 3/18/2024
8.1.5-preview-12 296 3/13/2024
8.1.5-preview-11 242 3/13/2024
8.1.5-preview-10 254 3/13/2024
8.1.5-preview-09 253 3/12/2024
8.1.5-preview-08 245 3/12/2024
8.1.5-preview-07 232 3/8/2024
8.1.5-preview-06 434 3/8/2024
8.1.5-preview-05 238 3/7/2024
8.1.5-preview-04 286 3/7/2024
8.1.5-preview-03 284 3/7/2024
8.1.5-preview-02 373 2/28/2024
8.1.5-preview-01 294 2/19/2024
8.1.4 512 2/15/2024
8.1.3 308 2/13/2024
8.1.3-preview-07 250 2/13/2024
8.1.3-preview-06 269 2/12/2024
8.1.3-preview-05 233 2/9/2024
8.1.3-preview-04 239 2/8/2024
8.1.3-preview-03 269 2/7/2024
8.1.3-preview-02 259 2/2/2024
8.1.3-preview-01 217 2/2/2024
8.1.2 321 2/1/2024
8.1.2-preview-9 275 1/22/2024
8.1.2-preview-8 219 1/19/2024
8.1.2-preview-7 231 1/19/2024
8.1.2-preview-6 208 1/19/2024
8.1.2-preview-5 241 1/19/2024
8.1.2-preview-4 242 1/19/2024
8.1.2-preview-3 217 1/18/2024
8.1.2-preview-2 260 1/18/2024
8.1.2-preview-16 236 1/31/2024
8.1.2-preview-15 242 1/31/2024
8.1.2-preview-14 381 1/25/2024
8.1.2-preview-13 233 1/25/2024
8.1.2-preview-12 264 1/23/2024
8.1.2-preview-11 236 1/23/2024
8.1.2-preview-10 228 1/22/2024
8.1.2-preview-1 213 1/18/2024
8.1.1 304 1/18/2024
8.1.0 280 1/18/2024
8.0.3 351 12/29/2023
8.0.1 308 12/14/2023
8.0.0 352 12/7/2023
6.0.4.3 361 12/29/2023
6.0.4.2 290 12/20/2023
6.0.4.1 346 12/19/2023
6.0.4 340 12/4/2023
6.0.3.20 321 11/27/2023
6.0.3.19 296 11/22/2023