Encamina.Enmarcha.SemanticKernel.Plugins.Text 8.1.6-preview-07

This is a prerelease version of Encamina.Enmarcha.SemanticKernel.Plugins.Text.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Encamina.Enmarcha.SemanticKernel.Plugins.Text --version 8.1.6-preview-07                
NuGet\Install-Package Encamina.Enmarcha.SemanticKernel.Plugins.Text -Version 8.1.6-preview-07                
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-preview-07" />                
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-preview-07                
#r "nuget: Encamina.Enmarcha.SemanticKernel.Plugins.Text, 8.1.6-preview-07"                
#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-preview-07&prerelease

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

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 58 10/22/2024
8.2.0-preview-01-m01 90 9/17/2024
8.1.9-preview-02 52 10/22/2024
8.1.9-preview-01 124 10/4/2024
8.1.8 130 9/23/2024
8.1.8-preview-07 52 9/12/2024
8.1.8-preview-06 152 9/11/2024
8.1.8-preview-05 78 9/10/2024
8.1.8-preview-04 198 8/16/2024
8.1.8-preview-03 123 8/13/2024
8.1.8-preview-02 106 8/13/2024
8.1.8-preview-01 122 8/12/2024
8.1.7 101 8/7/2024
8.1.7-preview-09 109 7/3/2024
8.1.7-preview-08 84 7/2/2024
8.1.7-preview-07 77 6/10/2024
8.1.7-preview-06 77 6/10/2024
8.1.7-preview-05 105 6/6/2024
8.1.7-preview-04 81 6/6/2024
8.1.7-preview-03 97 5/24/2024
8.1.7-preview-02 81 5/10/2024
8.1.7-preview-01 100 5/8/2024
8.1.6 142 5/7/2024
8.1.6-preview-08 54 5/2/2024
8.1.6-preview-07 90 4/29/2024
8.1.6-preview-06 239 4/26/2024
8.1.6-preview-05 80 4/24/2024
8.1.6-preview-04 92 4/22/2024
8.1.6-preview-03 86 4/22/2024
8.1.6-preview-02 101 4/17/2024
8.1.6-preview-01 81 4/15/2024
8.1.5 97 4/15/2024
8.1.5-preview-15 54 4/10/2024
8.1.5-preview-14 125 3/20/2024
8.1.5-preview-13 63 3/18/2024
8.1.5-preview-12 98 3/13/2024
8.1.5-preview-11 85 3/13/2024
8.1.5-preview-10 122 3/13/2024
8.1.5-preview-09 85 3/12/2024
8.1.5-preview-08 92 3/12/2024
8.1.5-preview-07 87 3/8/2024
8.1.5-preview-06 150 3/8/2024
8.1.5-preview-05 82 3/7/2024
8.1.5-preview-04 99 3/7/2024
8.1.5-preview-03 84 3/7/2024
8.1.5-preview-02 131 2/28/2024
8.1.5-preview-01 129 2/19/2024
8.1.4 163 2/15/2024
8.1.3 135 2/13/2024
8.1.3-preview-07 80 2/13/2024
8.1.3-preview-06 103 2/12/2024
8.1.3-preview-05 91 2/9/2024
8.1.3-preview-04 92 2/8/2024
8.1.3-preview-03 86 2/7/2024
8.1.3-preview-02 88 2/2/2024
8.1.3-preview-01 85 2/2/2024
8.1.2 148 2/1/2024
8.1.2-preview-9 95 1/22/2024
8.1.2-preview-8 78 1/19/2024
8.1.2-preview-7 76 1/19/2024
8.1.2-preview-6 87 1/19/2024
8.1.2-preview-5 73 1/19/2024
8.1.2-preview-4 79 1/19/2024
8.1.2-preview-3 72 1/18/2024
8.1.2-preview-2 69 1/18/2024
8.1.2-preview-16 88 1/31/2024
8.1.2-preview-15 85 1/31/2024
8.1.2-preview-14 173 1/25/2024
8.1.2-preview-13 81 1/25/2024
8.1.2-preview-12 69 1/23/2024
8.1.2-preview-11 82 1/23/2024
8.1.2-preview-10 62 1/22/2024
8.1.2-preview-1 87 1/18/2024
8.1.1 153 1/18/2024
8.1.0 92 1/18/2024
8.0.3 134 12/29/2023
8.0.1 139 12/14/2023
8.0.0 127 12/7/2023
6.0.4.3 123 12/29/2023
6.0.4.2 146 12/20/2023
6.0.4.1 96 12/19/2023
6.0.4 140 12/4/2023
6.0.3.20 133 11/27/2023
6.0.3.19 129 11/22/2023