Encamina.Enmarcha.AI 8.1.5

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Encamina.Enmarcha.AI --version 8.1.5
NuGet\Install-Package Encamina.Enmarcha.AI -Version 8.1.5
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.5" />
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.5
#r "nuget: Encamina.Enmarcha.AI, 8.1.5"
#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.5

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

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.1.6-preview-08 0 5/2/2024
8.1.6-preview-07 171 4/29/2024
8.1.6-preview-06 179 4/26/2024
8.1.6-preview-05 168 4/24/2024
8.1.6-preview-04 194 4/22/2024
8.1.6-preview-03 169 4/22/2024
8.1.6-preview-02 226 4/17/2024
8.1.6-preview-01 203 4/15/2024
8.1.5 206 4/15/2024
8.1.5-preview-15 162 4/10/2024
8.1.5-preview-14 160 3/20/2024
8.1.5-preview-13 144 3/18/2024
8.1.5-preview-12 181 3/13/2024
8.1.5-preview-11 154 3/13/2024
8.1.5-preview-10 141 3/13/2024
8.1.5-preview-09 153 3/12/2024
8.1.5-preview-08 156 3/12/2024
8.1.5-preview-07 161 3/8/2024
8.1.5-preview-06 359 3/8/2024
8.1.5-preview-05 139 3/7/2024
8.1.5-preview-04 170 3/7/2024
8.1.5-preview-03 169 3/7/2024
8.1.5-preview-02 255 2/28/2024
8.1.5-preview-01 220 2/19/2024
8.1.4 368 2/15/2024
8.1.3 231 2/13/2024
8.1.3-preview-07 140 2/13/2024
8.1.3-preview-06 167 2/12/2024
8.1.3-preview-05 151 2/9/2024
8.1.3-preview-04 159 2/8/2024
8.1.3-preview-03 167 2/7/2024
8.1.3-preview-02 147 2/2/2024
8.1.3-preview-01 154 2/2/2024
8.1.2 223 2/1/2024
8.1.2-preview-9 155 1/22/2024
8.1.2-preview-8 144 1/19/2024
8.1.2-preview-7 149 1/19/2024
8.1.2-preview-6 124 1/19/2024
8.1.2-preview-5 147 1/19/2024
8.1.2-preview-4 157 1/19/2024
8.1.2-preview-3 134 1/18/2024
8.1.2-preview-2 189 1/18/2024
8.1.2-preview-16 123 1/31/2024
8.1.2-preview-15 140 1/31/2024
8.1.2-preview-14 250 1/25/2024
8.1.2-preview-13 111 1/25/2024
8.1.2-preview-12 126 1/23/2024
8.1.2-preview-11 128 1/23/2024
8.1.2-preview-10 134 1/22/2024
8.1.2-preview-1 120 1/18/2024
8.1.1 229 1/18/2024
8.1.0 201 1/18/2024
8.0.3 250 12/29/2023
8.0.1 223 12/14/2023
8.0.0 241 12/7/2023
6.0.4.3 262 12/29/2023
6.0.4.2 212 12/20/2023
6.0.4.1 260 12/19/2023
6.0.4 243 12/4/2023
6.0.3.20 221 11/27/2023
6.0.3.19 211 11/22/2023