Encamina.Enmarcha.SemanticKernel.Plugins.Memory 8.1.6

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Encamina.Enmarcha.SemanticKernel.Plugins.Memory --version 8.1.6
NuGet\Install-Package Encamina.Enmarcha.SemanticKernel.Plugins.Memory -Version 8.1.6
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.SemanticKernel.Plugins.Memory" Version="8.1.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Encamina.Enmarcha.SemanticKernel.Plugins.Memory --version 8.1.6
#r "nuget: Encamina.Enmarcha.SemanticKernel.Plugins.Memory, 8.1.6"
#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.SemanticKernel.Plugins.Memory as a Cake Addin
#addin nuget:?package=Encamina.Enmarcha.SemanticKernel.Plugins.Memory&version=8.1.6

// Install Encamina.Enmarcha.SemanticKernel.Plugins.Memory as a Cake Tool
#tool nuget:?package=Encamina.Enmarcha.SemanticKernel.Plugins.Memory&version=8.1.6

Semantic Kernel - Memory Plugin

Nuget package

Memory Plugin is a project that offers functionality as a plugin for searching the memory of the Semantic Kernel. When text is stored in memory within the Semantic Kernel, it is saved in the form of embeddings that can be queried through the Memory Plugin.

Setup

Nuget package

First, install NuGet. Then, install Encamina.Enmarcha.SemanticKernel.Plugins.Memory from the package manager console:

PM> Install-Package Encamina.Enmarcha.SemanticKernel.Plugins.Memory

.NET CLI:

First, install .NET CLI. Then, install Encamina.Enmarcha.SemanticKernel.Plugins.Memory from the .NET CLI:

dotnet add package Encamina.Enmarcha.SemanticKernel.Plugins.Memory

How to use

To use MemoryQueryPlugin, the usual approach is to import it as a plugin within Semantic Kernel. The simplest way to do this is by using the extension method ImportMemoryPlugin, which handles the import of the Plugin into Semantic Kernel.

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

// ... 

builder.Services.AddScoped(sp =>
{
      var kernel = new KernelBuilder()
        .WithAzureTextEmbeddingGenerationService("<YOUR DEPLOYMENT NAME>", "<YOUR AZURE ENDPOINT>", "<YOUR API KEY>")
        //.WithOpenAITextEmbeddingGenerationService("<YOUR MODEL ID>", "<YOUR API KEY>")
        /// ...
        .Build();

    // ...

    kernel.ImportMemoryPlugin(ILengthFunctions.LengthByTokenCount);

    return kernel;
});

Now you can inject the kernel via constructor, and the memory capabilities are already available.

public class MyClass
{
    private readonly Kernel kernel;

    public MyClass(Kernel kernel)
    {
        this.kernel = kernel;
    }

    public async Task TestMemoryQueryAsync()
    {
        var contextVariables = new ContextVariables();
        contextVariables.Set(PluginsInfo.MemoryQueryPlugin.Functions.QueryMemory.Parameters.Query, "What is the weather like in Madrid?");
        contextVariables.Set(PluginsInfo.MemoryQueryPlugin.Functions.QueryMemory.Parameters.CollectionsStr, "collection-1:collection-2");
        contextVariables.Set(PluginsInfo.MemoryQueryPlugin.Functions.QueryMemory.Parameters.CollectionSeparator, ":");
        contextVariables.Set(PluginsInfo.MemoryQueryPlugin.Functions.QueryMemory.Parameters.MinRelevance, "0.8");
        contextVariables.Set(PluginsInfo.MemoryQueryPlugin.Functions.QueryMemory.Parameters.ResponseTokenLimit, "1500");
        contextVariables.Set(PluginsInfo.MemoryQueryPlugin.Functions.QueryMemory.Parameters.ResultsLimit, "2");

        var functionMemoryQuery = kernel.Func(PluginsInfo.MemoryQueryPlugin.Name, PluginsInfo.MemoryQueryPlugin.Functions.QueryMemory.Name);

        var resultContext = await kernel.RunAsync(contextVariables, functionMemoryQuery);
    }
}

Within resultContext, you will find texts that meet the conditions.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Encamina.Enmarcha.SemanticKernel.Plugins.Memory:

Package Downloads
Encamina.Enmarcha.SemanticKernel.Plugins.QuestionAnswering

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.1.7-preview-03 22 5/24/2024
8.1.7-preview-02 75 5/10/2024
8.1.7-preview-01 70 5/8/2024
8.1.6 92 5/7/2024
8.1.6-preview-08 35 5/2/2024
8.1.6-preview-07 67 4/29/2024
8.1.6-preview-06 100 4/26/2024
8.1.6-preview-05 75 4/24/2024
8.1.6-preview-04 73 4/22/2024
8.1.6-preview-03 65 4/22/2024
8.1.6-preview-02 96 4/17/2024
8.1.6-preview-01 58 4/15/2024
8.1.5 99 4/15/2024
8.1.5-preview-15 61 4/10/2024
8.1.5-preview-14 95 3/20/2024
8.1.5-preview-13 51 3/18/2024
8.1.5-preview-12 78 3/13/2024
8.1.5-preview-11 62 3/13/2024
8.1.5-preview-10 77 3/13/2024
8.1.5-preview-09 70 3/12/2024
8.1.5-preview-08 60 3/12/2024
8.1.5-preview-07 69 3/8/2024
8.1.5-preview-06 178 3/8/2024
8.1.5-preview-05 64 3/7/2024
8.1.5-preview-04 63 3/7/2024
8.1.5-preview-03 71 3/7/2024
8.1.5-preview-02 125 2/28/2024
8.1.5-preview-01 106 2/19/2024
8.1.4 164 2/15/2024
8.1.3 105 2/13/2024
8.1.3-preview-07 60 2/13/2024
8.1.3-preview-06 78 2/12/2024
8.1.3-preview-05 71 2/9/2024
8.1.3-preview-04 59 2/8/2024
8.1.3-preview-03 65 2/7/2024
8.1.3-preview-02 70 2/2/2024
8.1.3-preview-01 67 2/2/2024
8.1.2 121 2/1/2024
8.1.2-preview-9 80 1/22/2024
8.1.2-preview-8 63 1/19/2024
8.1.2-preview-7 58 1/19/2024
8.1.2-preview-6 66 1/19/2024
8.1.2-preview-5 66 1/19/2024
8.1.2-preview-4 64 1/19/2024
8.1.2-preview-3 68 1/18/2024
8.1.2-preview-2 73 1/18/2024
8.1.2-preview-16 65 1/31/2024
8.1.2-preview-15 68 1/31/2024
8.1.2-preview-14 168 1/25/2024
8.1.2-preview-13 67 1/25/2024
8.1.2-preview-12 66 1/23/2024
8.1.2-preview-11 63 1/23/2024
8.1.2-preview-10 65 1/22/2024
8.1.2-preview-1 59 1/18/2024
8.1.1 110 1/18/2024
8.1.0 83 1/18/2024
8.0.3 147 12/29/2023
8.0.1 133 12/14/2023
8.0.0 142 12/7/2023
6.0.4.3 145 12/29/2023
6.0.4.2 139 12/20/2023
6.0.4.1 87 12/19/2023
6.0.4 159 12/4/2023
6.0.3.20 138 11/27/2023
6.0.3.19 134 11/22/2023