IAIDocProcessingService.SummarizeAsync(Presentation, SummarizationMode, CancellationToken) Method
Generates a brief summary of a presentation content.
Namespace: DevExpress.AIIntegration.Docs
Assembly: DevExpress.AIIntegration.Docs.v25.2.dll
NuGet Package: DevExpress.AIIntegration.Docs
Declaration
Task<string> SummarizeAsync(
Presentation presentation,
SummarizationMode mode = SummarizationMode.Abstractive,
CancellationToken cancellationToken = default(CancellationToken)
)
Parameters
| Name | Type | Description |
|---|---|---|
| presentation | Presentation | The |
Optional Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| mode | SummarizationMode | Abstractive | An enumeration value that indicates summarization mode. |
| cancellationToken | CancellationToken | null | The token that cancels the task. |
Returns
| Type | Description |
|---|---|
| Task<String> | The response that contains AI-generated summary. |
Example
How to: Obtain Summary and Add It to a Slide
The following code snippet obtains an AI-generated summary and adds it to the first slide:
using DevExpress.AIIntegration.Docs;
using DevExpress.Docs.Presentation;
using System.Drawing;
// See "Register AI extension service" section for implementation code
var docProcessingService = defaultAIExtensionsContainer.CreateAIDocProcessingService();
var presentation = new Presentation(File.ReadAllBytes("Documents/Presentation.pptx"));
string summary = await docProcessingService.SummarizeAsync(
presentation,
SummarizationMode.Extractive,
CancellationToken.None);
Slide slide = new Slide(new SlideLayout(layoutType: SlideLayoutType.Blank, name: "slide"));
AddTextToSlide(slide, summary);
presentation.Slides.Insert(0, slide);
string targetDir = @"C:\Test Documents";
Directory.CreateDirectory(targetDir); // Safe if already exists
string outputPath = Path.Combine(targetDir, "presentation.pptx");
using (FileStream outputStream = new FileStream(outputPath, FileMode.Create, FileAccess.Write))
{
presentation.SaveDocument(outputStream, DocumentFormat.Pptx);
}
void AddTextToSlide(Slide slide, string text)
{
Shape shape = new Shape(ShapeType.Rectangle);
shape.X = 0; shape.Y = 0;
shape.Width = presentation.SlideSize.Width;
shape.Height = presentation.SlideSize.Height;
shape.TextArea = new TextArea
{
Text = $"Summary by DevExpress AI Extensions:\r\n{text}",
ParagraphProperties = new ParagraphProperties
{
TextProperties = new TextProperties {
Fill = new SolidFill(Color.FromArgb(168, 177, 184)),
FontSize = 24
}
},
Properties = new TextAreaProperties
{
AutoFit = TextAutoSize.Shape
}
};
shape.Fill = new SolidFill(Color.FromArgb(21, 25, 28));
shape.Outline = new LineStyle { Fill = new SolidFill(Color.FromArgb(21, 25, 28)) };
slide.Shapes.Add(shape);
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the SummarizeAsync(Presentation, SummarizationMode, CancellationToken) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.