Skip to main content
All docs
V24.2

ExtractiveSummaryRequest Class

A request to generate a brief summary of long text by selecting and extracting key sentences or phrases from the original text.

Namespace: DevExpress.AIIntegration.Extensions

Assembly: DevExpress.AIIntegration.v24.2.dll

NuGet Package: DevExpress.AIIntegration

Declaration

public class ExtractiveSummaryRequest :
    TextRequest

Remarks

The AI-powered Extractive Summarization extension identifies the most important parts of the specified long text and combines them into a summary without altering the original wording.

The following example registers an Azure OpenAI client and uses the AI-powered extension to generate a summary for originalText:

using Azure;
using Azure.AI.OpenAI;
using Microsoft.Extensions.AI;
using DevExpress.AIIntegration;
using DevExpress.AIIntegration.Extensions;

SetEnvironmentVariables();

// Register an Azure OpenAI client
AIExtensionsContainerDefault defaultAIExtensionsContainer = RegisterAzureOpenAIClient(
    Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT"),
    Environment.GetEnvironmentVariable("AZURE_OPENAI_APIKEY")
);

string originalText = "This must be a long text...";
var response = await defaultAIExtensionsContainer.ExtractiveSummaryAsync(
    new ExtractiveSummaryRequest(originalText)
);

AIExtensionsContainerDefault RegisterAzureOpenAIClient(string azureOpenAIEndpoint, string azureOpenAIKey) {
    IChatClient client = new AzureOpenAIClient(
        new Uri(azureOpenAIEndpoint),
        new AzureKeyCredential(azureOpenAIKey))
            .AsChatClient("gpt-4o-mini");
    return AIExtensionsContainerConsole.CreateDefaultAIExtensionContainer(client);
}

void SetEnvironmentVariables() {
    Environment.SetEnvironmentVariable("AZURE_OPENAI_ENDPOINT", {SPECIFY_YOUR_AZURE_ENDPOINT});
    Environment.SetEnvironmentVariable("AZURE_OPENAI_APIKEY", {SPECIFY_YOU_AZURE_KEY});
}

Azure AI Language

Note

Requires the DevExpress.AIIntegration.Azure.TextAnalytics package.

If you have access to Azure AI Language services, you can specify additional settings, which include:

  • Language – Specifies the target language of the summary.
  • MaxSentences – Specifies the maximum number of sentences in the summary.

The following example registers an Azure Text Analytics client and uses the AI-powered extension to generate a summary for originalText:

using Azure;
using Azure.AI.TextAnalytics;
using DevExpress.AIIntegration;
using DevExpress.AIIntegration.Extensions;

AIExtensionsContainerDefault defaultAIExtensionsContainer;

RegisterTextAnalyticsService(
    Environment.GetEnvironmentVariable("AZURE_TEXT_ANALYTICS_ENDPOINT"),
    Environment.GetEnvironmentVariable("AZURE_TEXT_ANALYTICS_API_KEY")
);

string originalText = "This must be a long text...";
var response = await defaultAIExtensionsContainer.ExtractiveSummaryAsync(
    new ExtractiveSummaryRequest(originalText) { Language = "de", MaxSentences = 5 }
);

Console.WriteLine(response);

void RegisterTextAnalyticsService(string azureTextAnalyticsEndpoint, string azureTextAnalyticsAIKey)
{
    defaultAIExtensionsContainer = new AIExtensionsContainerDefault();
    var textAnalyticsClient = new TextAnalyticsClient(
        new Uri(azureTextAnalyticsEndpoint),
        new AzureKeyCredential(azureTextAnalyticsAIKey)
    );
    defaultAIExtensionsContainer.RegisterTextAnalyticsAzureAIService(textAnalyticsClient);
}

Inheritance

Object
DevExpress.AIIntegration.Extensions.BaseRequest
TextRequest
ExtractiveSummaryRequest
See Also