corelibraries-devexpress-dot-aiintegration-dot-extensions-02e13e4f.md
A request to generate a brief summary of long text by understanding the context of the original text and rephrasing it in a new, concise form.
Namespace : DevExpress.AIIntegration.Extensions
Assembly : DevExpress.AIIntegration.v25.2.dll
NuGet Package : DevExpress.AIIntegration
public class AbstractiveSummaryRequest :
TextRequest
Public Class AbstractiveSummaryRequest
Inherits TextRequest
The AI-powered Abstractive Summarization extension essentially “writes” a new summary based on its understanding, which may include new sentences that were not present in the original text.
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.AbstractiveSummaryAsync(
new AbstractiveSummaryRequest(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});
}
Note
Requires the DevExpress.AIIntegration.Azure.TextAnalytics package.
If you have access to Azure AI Language services, you can specify additional settings, which include:
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.AbstractiveSummaryAsync(
new AbstractiveSummaryRequest(originalText) { Language = "de", SentenceCount = 3 }
);
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);
}
Object DevExpress.AIIntegration.Extensions.BaseRequest TextRequest AbstractiveSummaryRequest
See Also