Skip to content

Summarize and translate a report content in the Blazor Native Report Viewer with AI-powered functionality.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/blazor-reporting-ai-summarize-and-translate

Repository files navigation

Reporting for Blazor - Summarize and Translate DevExpress Reports Using Azure OpenAI

This example adds AI-powered summarize/translate capabilities to the DevExpress Blazor Report Viewer. These capabilities are available within the user interface via two buttons designed to access the report document and process content as follows:

  • Summarize: Uses generative AI to summarize report content and displays core insights associated with this report.
  • Translate: Uses AI services to translate report content to another language.

The following is an image of the application interface. As you can see, users can process the entire document, individual pages, or selected content.

AI-Powered Summarize and Translate Buttons

Implementation Details

Add NuGet Packages

Add the following NuGet packages:

  • DevExpress.AIIntegration.Blazor.Reporting.Viewer
  • DevExpress.AIIntegration.Azure.OpenAI or DevExpress.AIIntegration.OpenAI based on your AI service preferences. This project uses Azure OpenAI. The remainder of this document describes steps related to this package.

Add Personal Keys

To use AI-based Summarize and Translate functionality in your application, you must create an Azure OpenAI resource in the Azure portal. Refer to the following help topic for additional information/guidance: Microsoft - Create and deploy an Azure OpenAI Service resource.

Once you obtain a private endpoint and an API key, open appsettings.json and specify DeploymentName, AzureOpenAIKey, and AzureOpenAIEndpoint values. Note that DeploymentName is set to GPT4o, but you can specify a different model:

"AISettings": {
    "DeploymentName": "GPT4o",
    "AzureOpenAIKey": "",
    "AzureOpenAIEndpoint": ""
}

Create a class to read these settings:

public class AISettings {
    public string AzureOpenAIKey { get; set; }
    public string DeploymentName { get; set; }
    public string AzureOpenAIEndpoint { get; set; }
}

Register AI Services

Call the AddDevExpressAI method at the application startup to register AI services in your application:

using DevExpress.AIIntegration;
using DevExpress.AIIntegration.Reporting;
using DevExpress.AIIntegration.Blazor.Reporting.Viewer.Models;
using Azure.AI.OpenAI;
using Azure;
// ...
var builder = WebApplication.CreateBuilder(args);

var settings = builder.Configuration.GetSection("AISettings").Get<AISettings>();
builder.Services.AddDevExpressAI((config) => {
    config.RegisterChatClientOpenAIService(new AzureOpenAIClient(
        new Uri(settings.AzureOpenAIEndpoint),
        new AzureKeyCredential(settings.AzureOpenAIKey)
        ),settings.DeploymentName);
    config.AddBlazorReportingAIIntegration(config => {
        config.SummarizeBehavior = SummarizeBehavior.Abstractive;
        config.AvailabelLanguages = new List<LanguageItem>() {
            new LanguageItem() { Key = "de", Text = "German" },
            new LanguageItem() { Key = "es", Text = "Spanish" },
            new LanguageItem() { Key = "en", Text = "English" }
        };
    });
});

var app = builder.Build();

Files to Review

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Summarize and translate a report content in the Blazor Native Report Viewer with AI-powered functionality.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •