Encamina.Enmarcha.SemanticKernel.Plugins.Text 8.2.0

dotnet add package Encamina.Enmarcha.SemanticKernel.Plugins.Text --version 8.2.0                
NuGet\Install-Package Encamina.Enmarcha.SemanticKernel.Plugins.Text -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.SemanticKernel.Plugins.Text" 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.SemanticKernel.Plugins.Text --version 8.2.0                
#r "nuget: Encamina.Enmarcha.SemanticKernel.Plugins.Text, 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.SemanticKernel.Plugins.Text as a Cake Addin
#addin nuget:?package=Encamina.Enmarcha.SemanticKernel.Plugins.Text&version=8.2.0

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

Semantic Kernel - Text Plugin

Nuget package

The Text Plugin is a project that provides functionality to obtain various types of information from a text, such as a summary or keywords.

Setup

Nuget package

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

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

.NET CLI:

Install .NET CLI. Next, install Encamina.Enmarcha.SemanticKernel.Plugins.Text from the .NET CLI:

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

How to use

Within the TextPlugin, there are two available functions for text processing. On one hand, the function in Summarize provides the summary of a text. On the other hand, there is the function in KeyPhrases, which extracts keyphrases from a text.

To use TextPlugin, the first step is to import it into Semantic Kernel.

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

// ... 

builder.Services.AddScoped(sp =>
{
    var kernel = new KernelBuilder()
        .WithAzureChatCompletionService("<YOUR DEPLOYMENT NAME>", "<YOUR AZURE ENDPOINT>", "<YOUR API KEY>", alsoAsTextCompletion: true)
        //.WithAzureTextCompletionService("<YOUR DEPLOYMENT NAME>", "<YOUR AZURE ENDPOINT>", "<YOUR API KEY>")
        /// ...
        .Build();

    // ...

    kernel.ImportTextPlugin();

    return kernel;
});

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

public class MyClass
{
    private readonly Kernel kernel;

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

    public async Task TestSummaryAsync()
    {
        var contextVariables = new ContextVariables();
        contextVariables.Set(PluginsInfo.TextPlugin.Functions.Summarize.Parameters.Input, @"Alexandre Dumas born Dumas Davy de la Pailleterie, 24 July 1802 – 5 December 1870), also known as Alexandre Dumas père, was a French novelist and playwright.
        His works have been translated into many languages and he is one of the most widely read French authors. Many of his historical novels of adventure were originally published as serials, including The Count of Monte Cristo, The Three Musketeers, Twenty Years After and The Vicomte of Bragelonne: Ten Years Later. Since the early 20th century, his novels have been adapted into nearly 200 films. Prolific in several genres, Dumas began his career by writing plays, which were successfully produced from the first. He wrote numerous magazine articles and travel books; his published works totalled 100,000 pages. In the 1840s, Dumas founded the Théâtre Historique in Paris.
        His father, General Thomas-Alexandre Dumas Davy de la Pailleterie, was born in the French colony of Saint-Domingue (present-day Haiti) to Alexandre Antoine Davy de la Pailleterie, a French nobleman, and Marie-Cessette Dumas, an African slave. At age 14, Thomas-Alexandre was taken by his father to France, where he was educated in a military academy and entered the military for what became an illustrious career.
        Alexandre acquired work with Louis-Philippe, Duke of Orléans, then as a writer, a career which led to early success. Decades later, after the election of Louis-Napoléon Bonaparte in 1851, Dumas fell from favour and left France for Belgium, where he stayed for several years. He moved to Russia for a few years and then to Italy. In 1861, he founded and published the newspaper L'Indépendent, which supported Italian unification. He returned to Paris in 1864.
        English playwright Watts Phillips, who knew Dumas in his later life, described him as ""the most generous, large-hearted being in the world. He also was the most delightfully amusing and egotistical creature on the face of the earth. His tongue was like a windmill – once set in motion, you never knew when he would stop, especially if the theme was himself.""");
        contextVariables.Set(PluginsInfo.TextPlugin.Functions.Summarize.Parameters.MaxWordsCount, "15");

        var functionSummarize = kernel.Func(PluginsInfo.TextPlugin.Name, PluginsInfo.TextPlugin.Functions.Summarize.Name);

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

    public async Task TextKeyPhrasesAsync()
    {
        var contextVariables = new ContextVariables();
        contextVariables.Set(PluginsInfo.TextPlugin.Functions.KeyPhrases.Parameters.Input, @"Alexandre Dumas born Dumas Davy de la Pailleterie, 24 July 1802 – 5 December 1870), also known as Alexandre Dumas père, was a French novelist and playwright.
        His works have been translated into many languages and he is one of the most widely read French authors. Many of his historical novels of adventure were originally published as serials, including The Count of Monte Cristo, The Three Musketeers, Twenty Years After and The Vicomte of Bragelonne: Ten Years Later. Since the early 20th century, his novels have been adapted into nearly 200 films. Prolific in several genres, Dumas began his career by writing plays, which were successfully produced from the first. He wrote numerous magazine articles and travel books; his published works totalled 100,000 pages. In the 1840s, Dumas founded the Théâtre Historique in Paris.
        His father, General Thomas-Alexandre Dumas Davy de la Pailleterie, was born in the French colony of Saint-Domingue (present-day Haiti) to Alexandre Antoine Davy de la Pailleterie, a French nobleman, and Marie-Cessette Dumas, an African slave. At age 14, Thomas-Alexandre was taken by his father to France, where he was educated in a military academy and entered the military for what became an illustrious career.
        Alexandre acquired work with Louis-Philippe, Duke of Orléans, then as a writer, a career which led to early success. Decades later, after the election of Louis-Napoléon Bonaparte in 1851, Dumas fell from favour and left France for Belgium, where he stayed for several years. He moved to Russia for a few years and then to Italy. In 1861, he founded and published the newspaper L'Indépendent, which supported Italian unification. He returned to Paris in 1864.
        English playwright Watts Phillips, who knew Dumas in his later life, described him as ""the most generous, large-hearted being in the world. He also was the most delightfully amusing and egotistical creature on the face of the earth. His tongue was like a windmill – once set in motion, you never knew when he would stop, especially if the theme was himself.""");
        contextVariables.Set(PluginsInfo.TextPlugin.Functions.KeyPhrases.Parameters.TopKeyphrases, "2");

        var functionSummarize = kernel.Func(PluginsInfo.TextPlugin.Name, PluginsInfo.TextPlugin.Functions.KeyPhrases.Name);

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

In the first method, TestSummaryAsync, a summary of the text with a maximum of 15 words is being requested. Within resultContext, you will find texts that say something like Alexandre Dumas, a French novelist and playwright, wrote famous adventure novels and founded a theater in Paris..

In the second method, TextKeyPhrasesAsync, 2 keyphrases from the text are being requested. Within resultContext, you will find texts that say something like Alexandre Dumas père and French novelist and playwright.

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

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 73 10/22/2024
8.2.0-preview-01-m01 91 9/17/2024
8.1.9-preview-02 54 10/22/2024
8.1.9-preview-01 125 10/4/2024
8.1.8 131 9/23/2024
8.1.8-preview-07 55 9/12/2024
8.1.8-preview-06 155 9/11/2024
8.1.8-preview-05 82 9/10/2024
8.1.8-preview-04 199 8/16/2024
8.1.8-preview-03 124 8/13/2024
8.1.8-preview-02 107 8/13/2024
8.1.8-preview-01 123 8/12/2024
8.1.7 102 8/7/2024
8.1.7-preview-09 110 7/3/2024
8.1.7-preview-08 85 7/2/2024
8.1.7-preview-07 78 6/10/2024
8.1.7-preview-06 78 6/10/2024
8.1.7-preview-05 106 6/6/2024
8.1.7-preview-04 82 6/6/2024
8.1.7-preview-03 98 5/24/2024
8.1.7-preview-02 82 5/10/2024
8.1.7-preview-01 101 5/8/2024
8.1.6 144 5/7/2024
8.1.6-preview-08 55 5/2/2024
8.1.6-preview-07 91 4/29/2024
8.1.6-preview-06 240 4/26/2024
8.1.6-preview-05 81 4/24/2024
8.1.6-preview-04 93 4/22/2024
8.1.6-preview-03 87 4/22/2024
8.1.6-preview-02 102 4/17/2024
8.1.6-preview-01 82 4/15/2024
8.1.5 98 4/15/2024
8.1.5-preview-15 55 4/10/2024
8.1.5-preview-14 126 3/20/2024
8.1.5-preview-13 64 3/18/2024
8.1.5-preview-12 99 3/13/2024
8.1.5-preview-11 86 3/13/2024
8.1.5-preview-10 123 3/13/2024
8.1.5-preview-09 86 3/12/2024
8.1.5-preview-08 93 3/12/2024
8.1.5-preview-07 88 3/8/2024
8.1.5-preview-06 151 3/8/2024
8.1.5-preview-05 83 3/7/2024
8.1.5-preview-04 100 3/7/2024
8.1.5-preview-03 85 3/7/2024
8.1.5-preview-02 132 2/28/2024
8.1.5-preview-01 130 2/19/2024
8.1.4 164 2/15/2024
8.1.3 136 2/13/2024
8.1.3-preview-07 85 2/13/2024
8.1.3-preview-06 104 2/12/2024
8.1.3-preview-05 92 2/9/2024
8.1.3-preview-04 93 2/8/2024
8.1.3-preview-03 87 2/7/2024
8.1.3-preview-02 89 2/2/2024
8.1.3-preview-01 86 2/2/2024
8.1.2 149 2/1/2024
8.1.2-preview-9 96 1/22/2024
8.1.2-preview-8 79 1/19/2024
8.1.2-preview-7 77 1/19/2024
8.1.2-preview-6 88 1/19/2024
8.1.2-preview-5 74 1/19/2024
8.1.2-preview-4 80 1/19/2024
8.1.2-preview-3 73 1/18/2024
8.1.2-preview-2 72 1/18/2024
8.1.2-preview-16 89 1/31/2024
8.1.2-preview-15 86 1/31/2024
8.1.2-preview-14 174 1/25/2024
8.1.2-preview-13 82 1/25/2024
8.1.2-preview-12 70 1/23/2024
8.1.2-preview-11 83 1/23/2024
8.1.2-preview-10 63 1/22/2024
8.1.2-preview-1 88 1/18/2024
8.1.1 154 1/18/2024
8.1.0 95 1/18/2024
8.0.3 141 12/29/2023
8.0.1 140 12/14/2023
8.0.0 128 12/7/2023
6.0.4.3 124 12/29/2023
6.0.4.2 147 12/20/2023
6.0.4.1 97 12/19/2023
6.0.4 141 12/4/2023
6.0.3.20 134 11/27/2023
6.0.3.19 130 11/22/2023