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

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

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.1.7-preview-03 72 5/24/2024
8.1.7-preview-02 74 5/10/2024
8.1.7-preview-01 72 5/8/2024
8.1.6 99 5/7/2024
8.1.6-preview-08 36 5/2/2024
8.1.6-preview-07 61 4/29/2024
8.1.6-preview-06 102 4/26/2024
8.1.6-preview-05 68 4/24/2024
8.1.6-preview-04 77 4/22/2024
8.1.6-preview-03 66 4/22/2024
8.1.6-preview-02 83 4/17/2024
8.1.6-preview-01 61 4/15/2024
8.1.5 84 4/15/2024
8.1.5-preview-15 49 4/10/2024
8.1.5-preview-14 98 3/20/2024
8.1.5-preview-13 47 3/18/2024
8.1.5-preview-12 85 3/13/2024
8.1.5-preview-11 64 3/13/2024
8.1.5-preview-10 90 3/13/2024
8.1.5-preview-09 57 3/12/2024
8.1.5-preview-08 71 3/12/2024
8.1.5-preview-07 82 3/8/2024
8.1.5-preview-06 130 3/8/2024
8.1.5-preview-05 69 3/7/2024
8.1.5-preview-04 80 3/7/2024
8.1.5-preview-03 65 3/7/2024
8.1.5-preview-02 110 2/28/2024
8.1.5-preview-01 108 2/19/2024
8.1.4 136 2/15/2024
8.1.3 93 2/13/2024
8.1.3-preview-07 45 2/13/2024
8.1.3-preview-06 76 2/12/2024
8.1.3-preview-05 74 2/9/2024
8.1.3-preview-04 69 2/8/2024
8.1.3-preview-03 69 2/7/2024
8.1.3-preview-02 65 2/2/2024
8.1.3-preview-01 65 2/2/2024
8.1.2 128 2/1/2024
8.1.2-preview-9 67 1/22/2024
8.1.2-preview-8 55 1/19/2024
8.1.2-preview-7 61 1/19/2024
8.1.2-preview-6 54 1/19/2024
8.1.2-preview-5 44 1/19/2024
8.1.2-preview-4 63 1/19/2024
8.1.2-preview-3 53 1/18/2024
8.1.2-preview-2 54 1/18/2024
8.1.2-preview-16 65 1/31/2024
8.1.2-preview-15 65 1/31/2024
8.1.2-preview-14 147 1/25/2024
8.1.2-preview-13 65 1/25/2024
8.1.2-preview-12 51 1/23/2024
8.1.2-preview-11 56 1/23/2024
8.1.2-preview-10 54 1/22/2024
8.1.2-preview-1 53 1/18/2024
8.1.1 92 1/18/2024
8.1.0 69 1/18/2024
8.0.3 115 12/29/2023
8.0.1 114 12/14/2023
8.0.0 105 12/7/2023
6.0.4.3 89 12/29/2023
6.0.4.2 109 12/20/2023
6.0.4.1 81 12/19/2023
6.0.4 118 12/4/2023
6.0.3.20 108 11/27/2023
6.0.3.19 104 11/22/2023