Encamina.Enmarcha.AI 8.1.3-preview-02

This is a prerelease version of Encamina.Enmarcha.AI.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Encamina.Enmarcha.AI --version 8.1.3-preview-02                
NuGet\Install-Package Encamina.Enmarcha.AI -Version 8.1.3-preview-02                
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.1.3-preview-02" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Encamina.Enmarcha.AI --version 8.1.3-preview-02                
#r "nuget: Encamina.Enmarcha.AI, 8.1.3-preview-02"                
#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.1.3-preview-02&prerelease

// Install Encamina.Enmarcha.AI as a Cake Tool
#tool nuget:?package=Encamina.Enmarcha.AI&version=8.1.3-preview-02&prerelease                

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 561 10/22/2024
8.2.0-preview-01-m01 240 9/17/2024
8.1.9-preview-03 206 11/19/2024
8.1.9-preview-02 174 10/22/2024
8.1.9-preview-01 409 10/4/2024
8.1.8 366 9/23/2024
8.1.8-preview-07 785 9/12/2024
8.1.8-preview-06 353 9/11/2024
8.1.8-preview-05 256 9/10/2024
8.1.8-preview-04 513 8/16/2024
8.1.8-preview-03 306 8/13/2024
8.1.8-preview-02 241 8/13/2024
8.1.8-preview-01 267 8/12/2024
8.1.7 285 8/7/2024
8.1.7-preview-09 268 7/3/2024
8.1.7-preview-08 255 7/2/2024
8.1.7-preview-07 225 6/10/2024
8.1.7-preview-06 220 6/10/2024
8.1.7-preview-05 245 6/6/2024
8.1.7-preview-04 227 6/6/2024
8.1.7-preview-03 252 5/24/2024
8.1.7-preview-02 242 5/10/2024
8.1.7-preview-01 256 5/8/2024
8.1.6 1,529 5/7/2024
8.1.6-preview-08 227 5/2/2024
8.1.6-preview-07 256 4/29/2024
8.1.6-preview-06 632 4/26/2024
8.1.6-preview-05 253 4/24/2024
8.1.6-preview-04 287 4/22/2024
8.1.6-preview-03 246 4/22/2024
8.1.6-preview-02 318 4/17/2024
8.1.6-preview-01 333 4/15/2024
8.1.5 310 4/15/2024
8.1.5-preview-15 270 4/10/2024
8.1.5-preview-14 277 3/20/2024
8.1.5-preview-13 260 3/18/2024
8.1.5-preview-12 299 3/13/2024
8.1.5-preview-11 245 3/13/2024
8.1.5-preview-10 257 3/13/2024
8.1.5-preview-09 256 3/12/2024
8.1.5-preview-08 250 3/12/2024
8.1.5-preview-07 237 3/8/2024
8.1.5-preview-06 437 3/8/2024
8.1.5-preview-05 243 3/7/2024
8.1.5-preview-04 289 3/7/2024
8.1.5-preview-03 287 3/7/2024
8.1.5-preview-02 376 2/28/2024
8.1.5-preview-01 297 2/19/2024
8.1.4 517 2/15/2024
8.1.3 313 2/13/2024
8.1.3-preview-07 253 2/13/2024
8.1.3-preview-06 277 2/12/2024
8.1.3-preview-05 236 2/9/2024
8.1.3-preview-04 242 2/8/2024
8.1.3-preview-03 272 2/7/2024
8.1.3-preview-02 264 2/2/2024
8.1.3-preview-01 220 2/2/2024
8.1.2 326 2/1/2024
8.1.2-preview-9 278 1/22/2024
8.1.2-preview-8 222 1/19/2024
8.1.2-preview-7 234 1/19/2024
8.1.2-preview-6 213 1/19/2024
8.1.2-preview-5 246 1/19/2024
8.1.2-preview-4 247 1/19/2024
8.1.2-preview-3 222 1/18/2024
8.1.2-preview-2 263 1/18/2024
8.1.2-preview-16 239 1/31/2024
8.1.2-preview-15 245 1/31/2024
8.1.2-preview-14 390 1/25/2024
8.1.2-preview-13 236 1/25/2024
8.1.2-preview-12 269 1/23/2024
8.1.2-preview-11 239 1/23/2024
8.1.2-preview-10 231 1/22/2024
8.1.2-preview-1 218 1/18/2024
8.1.1 309 1/18/2024
8.1.0 285 1/18/2024
8.0.3 358 12/29/2023
8.0.1 313 12/14/2023
8.0.0 359 12/7/2023
6.0.4.3 366 12/29/2023
6.0.4.2 295 12/20/2023
6.0.4.1 351 12/19/2023
6.0.4 345 12/4/2023
6.0.3.20 326 11/27/2023
6.0.3.19 301 11/22/2023