AIDocProcessingService.AskAIAsync(Presentation, String, RagOptions, CancellationToken) Method
Returns a response to a custom question about the presentation content.
Namespace: DevExpress.AIIntegration.Docs
Assembly: DevExpress.AIIntegration.Docs.v25.2.dll
NuGet Package: DevExpress.AIIntegration.Docs
Declaration
public Task<string> AskAIAsync(
Presentation presentation,
string question,
RagOptions options,
CancellationToken cancellationToken = default(CancellationToken)
)
Parameters
| Name | Type | Description |
|---|---|---|
| presentation | Presentation | The |
| question | String | The question about the presentation content. |
| options | RagOptions | An object that contains retrieval-augmented generation (RAG) options. |
Optional Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| cancellationToken | CancellationToken | null | The token that cancels the task. |
Returns
| Type | Description |
|---|---|
| Task<String> | The response that contains an AI-generated answer. |
Example
Example: Ask a Question about Presentation Content
The following code snippet asks a question about the document content, configures RAG options (chunk size, collection name, chunk count), and inserts the AI‑generated answer as content in the first slide:
using DevExpress.AIIntegration;
using DevExpress.AIIntegration.Docs;
using DevExpress.Docs.Presentation;
using Microsoft.Extensions.AI;
// Create a document processing service instance
// from the AI extensions container.
var docProcessingService = new AIDocProcessingService(defaultAIExtensionsContainer);
var options = new RagOptions
{
VectorCollectionName = "document_embeddings",
ChunkSize = 800,
AugmentationChunkCount = 8
};
var presentation = new Presentation(File.ReadAllBytes("Documents/Presentation.pptx"));
string summary = await docProcessingService.AskAIAsync(
presentation,
"Does this document contain any confidential information?",
options);
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);
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);
}
See Also