Skip to content

Commit 7ec7157

Browse files
authored
Update README.md
1 parent ab9d725 commit 7ec7157

File tree

1 file changed

+33
-31
lines changed

1 file changed

+33
-31
lines changed

README.md

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,40 @@
33
[![](https://img.shields.io/badge/📖_How_to_use_DevExpress_Examples-e9f6fc?style=flat-square)](https://docs.devexpress.com/GeneralInformation/403183)
44
[![](https://img.shields.io/badge/💬_Leave_Feedback-feecdd?style=flat-square)](#does-this-example-address-your-development-requirementsobjectives)
55
<!-- default badges end -->
6-
# Report Viewer and Grid for Blazor — Integrate an AI Assistant based on Azure OpenAI
6+
# Blazor Grid and Report Viewer — Incorporate an AI Assistant (Azure OpenAI) in your next DevExpress-powered Blazor app
77

8-
This example adds a Copilot-inspired chat window (the [`DxAIChat`](http://docs.devexpress.com/Blazor/DevExpress.AIIntegration.Blazor.Chat.DxAIChat) component) to a Blazor application with DevExpress Report Viewer and Grid components. The chat utilizes an [Azure OpenAI Assistant](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/assistant) to answer user questions based on information displayed in the report and/or data grid.
8+
This example adds a Copilot-inspired chat window (DevExpress [`DxAIChat`](http://docs.devexpress.com/Blazor/DevExpress.AIIntegration.Blazor.Chat.DxAIChat) component) to a DevExpress-powered Blazor application (using both the DevExpress Report Viewer and Blazor Grid component). Our chat implementation utilizes [Azure OpenAI Assistant](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/assistant) to answer user questions based on information displayed in the report and/or data grid.
99

10-
To integrate an AI-powered chat into your application, complete the following key steps:
10+
To integrate AI-powered chat capabilities to your next great Blazor application, please follow the steps below:
1111

12-
1. Register AI Services in the application.
13-
2. Add a `DxAIChat` component.
14-
3. Export component data and pass it to the AI Assistant.
12+
1. Register AI Services within the application.
13+
2. Add the DevExpress Chat component (`DxAIChat`).
14+
3. Export component data and pass it to the AI Assistant.
1515

16-
This example uses the following DevExpress Blazor Components:
16+
The following DevExpress Blazor Components were used in this sample project:
1717

18-
- [Grid](https://www.devexpress.com/blazor/data-grid/)
18+
- [DevExpress Blazor Grid](https://www.devexpress.com/blazor/data-grid/)
19+
20+
Our Blazor Grid component displays project management data. You can use the AI Assistant to:
1921

20-
The Grid component displays project management data. You can use the AI Assistant to:
2122
- Prioritize tasks.
22-
- Count tasks with a specific status.
23-
- Filter tasks by owner or priority.
23+
- Count tasks using status data.
24+
- Filter tasks by owner or priority.
2425

2526
Implementation details: [Use an AI Assistant with the DevExpress Blazor Grid](#use-an-ai-assistant-with-the-devexpress-blazor-grid).
2627

2728
- [Report Viewer](https://www.devexpress.com/subscriptions/reporting/)
2829

29-
The Report Viewer includes several reports bound to different data. Use the AI Assistant to interact with report data:
30+
Our Report Viewer includes several reports bound to different data. Use the AI Assistant to interact with report data as follows:
3031

31-
- *Drill-Down Report*: Analyze invoice totals, delivery statuses, and averages.
32+
- *Drill-Down Report*: Analyze invoice totals, delivery status, and averages.
3233
- *Market Share Report*: Compare market share changes across regions.
33-
- *Restaurant Menu*: Examine price ranges and categorize vegetarian options.
34+
- *Restaurant Menu*: Examine price range and categorize vegetarian options.
3435

35-
Implementation details: [Use an AI Assistant with the DevExpress Blazor Report Viewer](#use-an-ai-assistant-with-the-devexpress-report-viewer).
36+
Implementation details: [Add an AI Assistant to the DevExpress Blazor Report Viewer](#add-an-ai-assistant-to-the-devexpress-report-viewer).
3637

3738
>[!NOTE]
38-
> Open AI Assistant initialization may take some time. `DxAIChat` is ready for use once the Microsoft Azure OpenAI service completes the source document scan. This example uses the following source documents: Excel file exported from the data grid and PDF file exported from the report viewer.
39+
> Open AI Assistant initialization may take time. `DxAIChat` is ready for use once Microsoft Azure OpenAI completes its source document scan.
3940
4041
## Implementation Details
4142

@@ -44,7 +45,7 @@ This example uses the following DevExpress Blazor Components:
4445
> [!NOTE]
4546
> DevExpress AI-powered extensions follow the "bring your own key" principle. DevExpress does not offer a REST API and does not ship any built-in LLMs/SLMs. You need an active Azure/Open AI subscription to obtain the REST API endpoint, key, and model deployment name. These variables must be specified at application startup to register AI clients and enable DevExpress AI-powered Extensions in your application.
4647
47-
Add the following code snippet to the *Program.cs* file to register AI Services and an [OpenAI Assistant](https://platform.openai.com/docs/assistants/overview) in your application:
48+
Add the following code snippet to the *Program.cs* file to register AI Services and incorporate an [OpenAI Assistant](https://platform.openai.com/docs/assistants/overview) in your application:
4849

4950
```cs
5051
using Azure.AI.OpenAI;
@@ -67,21 +68,22 @@ builder.Services.AddDevExpressAI((config) => {
6768
});
6869
```
6970

70-
For more information on the use of AI Assistants with `DxAIChat` and managing messages with custom RAG (Retrieval-Augmented Generation) solutions, refer to the following topic: [AI Service Assistants in the DxAIChat component](https://docs.devexpress.com/Blazor/DevExpress.AIIntegration.Blazor.Chat.DxAIChat#ai-service-assistants).
71+
For additional information on the use of AI Assistants with `DxAIChat` and managing messages with custom RAG (Retrieval-Augmented Generation) solutions, refer to the following topic: [AI Service Assistants in the DxAIChat component](https://docs.devexpress.com/Blazor/DevExpress.AIIntegration.Blazor.Chat.DxAIChat#ai-service-assistants).
7172

72-
Note that the availability of Azure Open AI Assistants depends on the region. For more details, refer to the following article: [Azure OpenAI Service models -- Assistants (Preview)](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models?tabs=global-standard%2Cstandard-chat-completions#assistants-preview).
73+
>[!NOTE]
74+
> The availability of Azure Open AI Assistants depends on region. For additional guidance in this regard, refer to the following document: [Azure OpenAI Service models -- Assistants (Preview)](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models?tabs=global-standard%2Cstandard-chat-completions#assistants-preview).
7375
7476
**Files to Review:**
7577

7678
- [Program.cs](./DevExpress.AI.Samples.Blazor/Program.cs)
7779

7880
### Use an AI Assistant with the DevExpress Blazor Grid
7981

80-
One page in this example displays `DxGrid` and `DxAIChat` components:
82+
This example includes a page with both the DevExpress Blazor Grid (`DxGrid`) and Blazor Chat component (`DxAIChat`):
8183

8284
![Blazor Grid and Integrated AI Assistant](images/data-grid.png)
8385

84-
For `DxGrid` configuration (data binding and customizations), review the following code file: [Grid.razor](./DevExpress.AI.Samples.Blazor/Components/Pages/Grid.razor).
86+
To configure our Blazor Grid (data binding and customizations), review the following code file: [Grid.razor](./DevExpress.AI.Samples.Blazor/Components/Pages/Grid.razor).
8587

8688
#### Add AI Chat to the Grid Page
8789

@@ -117,7 +119,7 @@ Use the [`MessageContentTemplate`](https://docs.devexpress.com/Blazor/DevExpress
117119

118120
#### Set Up the AI Assistant
119121

120-
Handle the `OnAfterRenderAsync` event and call the [`SetupAssistantAsync`](https://docs.devexpress.com/Blazor/DevExpress.AIIntegration.Blazor.Chat.IAIChat.SetupAssistantAsync(DevExpress.AIIntegration.Services.Assistant.AIAssistantOptions)) method to create an AI assistant and provide it with data and instructions. This example calls the grid's [`ExportToXlsxAsync`](https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxGrid.ExportToXlsxAsync.overloads) method to generate data for the AI Assistant.
122+
Handle the `OnAfterRenderAsync` event and call the [`SetupAssistantAsync`](https://docs.devexpress.com/Blazor/DevExpress.AIIntegration.Blazor.Chat.IAIChat.SetupAssistantAsync(DevExpress.AIIntegration.Services.Assistant.AIAssistantOptions)) method to create your AI assistant and provide it with data and instructions. This example calls our Blazor Grid's [`ExportToXlsxAsync`](https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxGrid.ExportToXlsxAsync.overloads) method to generate data for the AI Assistant.
121123

122124
```razor
123125
@using DevExpress.AIIntegration.OpenAI.Services
@@ -145,22 +147,22 @@ Handle the `OnAfterRenderAsync` event and call the [`SetupAssistantAsync`](https
145147
}
146148
```
147149

148-
You can review and tailor assistant instructions according to your needs in the following file: [Instructions.cs](./DevExpress.AI.Samples.Blazor/Instructions.cs).
150+
You can review and tailor AI assistant instructions in the following file: [Instructions.cs](./DevExpress.AI.Samples.Blazor/Instructions.cs).
149151

150-
For information on OpenAI Assistants, refer to the following article: [Assistants API overview](https://platform.openai.com/docs/assistants/overview).
152+
For information on OpenAI Assistants, refer to the following document: [Assistants API overview](https://platform.openai.com/docs/assistants/overview).
151153

152154
**Files to Review:**
153155

154156
- [Grid.razor](./DevExpress.AI.Samples.Blazor/Components/Pages/Grid.razor)
155157
- [Instructions.cs](./DevExpress.AI.Samples.Blazor/Instructions.cs)
156158

157-
### Use an AI Assistant with the DevExpress Blazor Report Viewer
159+
### Add an AI Assistant to the DevExpress Blazor Report Viewer
158160

159-
The following image displays the Blazor Report Viewer UI implemented in this example. The AI Assistant tab uses the `DxAIChat` component to display requests and responses:
161+
As you can see in the following image, this sample uses our Blazor Report Viewer alongside the DevExpress Chat component (the AI Assistant tab uses the `DxAIChat` component to display requests and responses):
160162

161163
![Blazor Report Viewer and Integrated AI Assistant](images/report-viewer.png)
162164

163-
#### Add New Tab for AI Assistant
165+
#### Add New Tab for Your AI Assistant
164166

165167
Use the [`OnCustomizeTabs`](https://docs.devexpress.com/XtraReports/DevExpress.Blazor.DxViewer.OnCustomizeTabs) event to add a new tab:
166168

@@ -192,7 +194,7 @@ Use the [`OnCustomizeTabs`](https://docs.devexpress.com/XtraReports/DevExpress.B
192194

193195
A new [`TabModel`](https://docs.devexpress.com/XtraReports/DevExpress.Blazor.Reporting.Models.TabModel._members) object is added to the tab list. The [`UserAssistantTabContentModel`](https://github.com/DevExpress-Examples/blazor-grid-and-report-viewer-integrate-ai-assistant/blob/24.2.3%2B/CS/DevExpress.AI.Samples.Blazor/Models/UserAssistantTabContentModel.cs#L6) class implements the [`ITabContentModel`](https://docs.devexpress.com/XtraReports/DevExpress.Blazor.Reporting.Models.ITabContentModel) interface that specifies AI Assistant tab visibility. The tab is only visible when the report is initialized and contains at least one page.
194196

195-
The `TabTemplate` property specifies the tab content. It dynamically renders the `DxAIChat` component inside the tab and passes the `ContentModel` as a parameter to control the tab's content.
197+
The `TabTemplate` property specifies tab content. It dynamically renders the `DxAIChat` component inside the tab and passes `ContentModel` as a parameter to control tab content.
196198

197199
The content for the AI Assistant tab is defined in the following file: [AITabRenderer.razor](./DevExpress.AI.Samples.Blazor/Components/Reporting/AITabRenderer.razor).
198200

@@ -213,7 +215,7 @@ The content for the AI Assistant tab is defined in the following file: [AITabRen
213215
@code {
214216
[Parameter] public UserAssistantTabContentModel Model { get; set; }
215217
string ClearAnnotations(string text) {
216-
//To clear out the annotations in a response from assistant.
218+
//To clear out annotations in a response from the assistant.
217219
return Regex.Replace(text, @"\【.*?】", "");
218220
}
219221
@@ -234,7 +236,7 @@ Use the [`MessageContentTemplate`](https://docs.devexpress.com/Blazor/DevExpress
234236

235237
#### Set Up the AI Assistant
236238

237-
Handle the [`Initialized`](https://docs.devexpress.com/Blazor/DevExpress.AIIntegration.Blazor.Chat.DxAIChat.Initialized) event and call the [`SetupAssistantAsync`](https://docs.devexpress.com/Blazor/DevExpress.AIIntegration.Blazor.Chat.IAIChat.SetupAssistantAsync(DevExpress.AIIntegration.Services.Assistant.AIAssistantOptions)) method to create an AI assistant and provide it with data and instructions. This example calls the [`ExportToPdf`](https://docs.devexpress.com/CoreLibraries/DevExpress.XtraPrinting.PrintingSystemBase.ExportToPdf(System.IO.Stream)) method to generate data for the AI Assistant:
239+
Handle the [`Initialized`](https://docs.devexpress.com/Blazor/DevExpress.AIIntegration.Blazor.Chat.DxAIChat.Initialized) event and call the [`SetupAssistantAsync`](https://docs.devexpress.com/Blazor/DevExpress.AIIntegration.Blazor.Chat.IAIChat.SetupAssistantAsync(DevExpress.AIIntegration.Services.Assistant.AIAssistantOptions)) method to create your AI assistant and provide it with data and instructions. This example calls the [`ExportToPdf`](https://docs.devexpress.com/CoreLibraries/DevExpress.XtraPrinting.PrintingSystemBase.ExportToPdf(System.IO.Stream)) method to generate data for the AI Assistant:
238240

239241
```razor
240242
@using DevExpress.AIIntegration.Blazor.Chat
@@ -256,7 +258,7 @@ Handle the [`Initialized`](https://docs.devexpress.com/Blazor/DevExpress.AIInteg
256258
}
257259
```
258260

259-
You can review and tailor instructions to your needs in the following file: [Instructions.cs](./DevExpress.AI.Samples.Blazor/Instructions.cs).
261+
You can review and tailor AI assistant instructions in the following file: [Instructions.cs](./DevExpress.AI.Samples.Blazor/Instructions.cs).
260262

261263
For information on OpenAI Assistants, refer to the following article: [Assistants API overview](https://platform.openai.com/docs/assistants/overview).
262264

0 commit comments

Comments
 (0)