Skip to content

Commit 122d624

Browse files
pollyndosAbadzhev
andauthored
Apply suggestions from code review
Co-authored-by: Abadzhev <[email protected]>
1 parent d59c69c commit 122d624

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

CS/DevExpress.AI.Samples.Blazor/Components/Pages/Index.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<DxGridLayoutItem Area="header" CssClass="title">
1313
<Template>
1414
<div class="title-header-text">AI Assistant + DevExpress Blazor Components</div>
15-
<div class="title-content-text">Select a component to get a hands-on experience with an integrated AI Assistant</div>
15+
<div class="title-content-text">Select a component to open a page with an integrated AI Assistant</div>
1616
</Template>
1717
</DxGridLayoutItem>
1818
<DxGridLayoutItem Area="cards" CssClass="welcome-cards">

README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,37 @@
55
<!-- default badges end -->
66
# Report Viewer and Grid for Blazor — Integrate an AI Assistant based on Azure OpenAI
77

8-
This example integrates a Copilot-inspired chat window (the [`DxAIChat`](http://docs.devexpress.com/Blazor/DevExpress.AIIntegration.Blazor.Chat.DxAIChat) component) to an application DevExpress Blazor Report Viewer and Blazor Grid. With an integrated [Azure OpenAI Assistant](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/assistant), users can ask natural language questions to analyze data and obtain AI-powered insights from the displayed report document and/or data displayed in the grid.
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.
99

10-
Key implementation steps of integrating `DxAIChat` include:
10+
To integrate an AI-powered chat into your application, complete the following key steps:
1111

1212
1. Register AI Services in the application.
13-
2. Add `DxAIChat` to the application.
13+
2. Add a `DxAIChat` component.
1414
3. Export component data and pass it to the AI Assistant.
1515

16-
This example showcases the following DevExpress Blazor Components:
16+
This example uses the following DevExpress Blazor Components:
1717

1818
- [Grid](https://www.devexpress.com/blazor/data-grid/)
1919

2020
The Grid component displays project management data. You can use the AI Assistant to:
21-
- Identify tasks to prioritize.
21+
- Prioritize tasks.
2222
- Count tasks with a specific status.
2323
- Filter tasks by owner or priority.
2424

25-
Implementation details: [Add an AI Assistant to Blazor Grid](#add-an-ai-assistant-to-grid).
25+
Implementation details: [Use an AI Assistant with the DevExpress Blazor Grid](#use-an-ai-assistant-with-the-devexpress-blazor-grid).
2626

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

29-
The Report Viewer includes several reports bound to different data. Use the AI Assistant to interact with report data, for example:
29+
The Report Viewer includes several reports bound to different data. Use the AI Assistant to interact with report data:
3030

3131
- *Drill-Down Report*: Analyze invoice totals, delivery statuses, and averages.
3232
- *Market Share Report*: Compare market share changes across regions.
3333
- *Restaurant Menu*: Examine price ranges and categorize vegetarian options.
3434

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

3737
>[!NOTE]
38-
> The Open AI Assistant initialization may take some time. The `DxAIChat` becomes ready to use once the Microsoft Azure OpenAI service completes the scan of the source document (i.e., grid or report data).
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.
3939
4040
## Implementation Details
4141

@@ -44,7 +44,7 @@ This example showcases the following DevExpress Blazor Components:
4444
> [!NOTE]
4545
> 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.
4646
47-
Add the following code to the *Program.cs* file to register the AI Services and an [OpenAI Assistant](https://platform.openai.com/docs/assistants/overview) in your application:
47+
Add the following code to the *Program.cs* file to register AI Services and an [OpenAI Assistant](https://platform.openai.com/docs/assistants/overview) in your application:
4848

4949
```cs
5050
using Azure.AI.OpenAI;
@@ -67,25 +67,25 @@ builder.Services.AddDevExpressAI((config) => {
6767
});
6868
```
6969

70-
For more information on AI Assistants in `DxAIChat` and managing messages with custom RAG 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).
70+
For more information on the use of AI Assistants with `DxAIChat` and managing messages with custom RAG 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).
7171

7272
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).
7373

7474
**Files to Review:**
7575

7676
- [Program.cs](./DevExpress.AI.Samples.Blazor/Program.cs)
7777

78-
### Add an AI Assistant to Grid
78+
### Use an AI Assistant with the DevExpress Blazor Grid
7979

80-
The following image displays a page with `DxGrid` and `DxAIChat` components implemented in this example:
80+
One page in this example displays `DxGrid` and `DxAIChat` components:
8181

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

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

8686
#### Add AI Chat to the Grid Page
8787

88-
The following code snippet adds the [`DxAIChat`](https://docs.devexpress.com/Blazor/DevExpress.AIIntegration.Blazor.Chat.DxAIChat) to the page:
88+
The following code snippet adds the [`DxAIChat`](https://docs.devexpress.com/Blazor/DevExpress.AIIntegration.Blazor.Chat.DxAIChat) component to the page:
8989

9090
```razor
9191
@using DevExpress.AIIntegration.Blazor.Chat
@@ -109,15 +109,15 @@ The following code snippet adds the [`DxAIChat`](https://docs.devexpress.com/Bla
109109
}
110110
```
111111

112-
Use the [`MessageContentTemplate`](https://docs.devexpress.com/Blazor/DevExpress.AIIntegration.Blazor.Chat.DxAIChat.MessageContentTemplate) property to display rich formatted messages. Use a markdown processor to convert the response content to HTML code.
112+
Use the [`MessageContentTemplate`](https://docs.devexpress.com/Blazor/DevExpress.AIIntegration.Blazor.Chat.DxAIChat.MessageContentTemplate) property to display rich-formatted messages. Use a markdown processor to convert response content to HTML code.
113113

114114
**Files to Review:**
115115

116116
- [Grid.razor](./DevExpress.AI.Samples.Blazor/Components/Pages/Grid.razor)
117117

118118
#### Set Up the AI Assistant
119119

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. In this example, grid data is exported to XLSX using the [`ExportToXlsxAsync`](https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxGrid.ExportToXlsxAsync.overloads) method and is passed to the assistant along with the instructions:
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.
121121

122122
```razor
123123
@using DevExpress.AIIntegration.OpenAI.Services
@@ -160,7 +160,7 @@ The following image displays Blazor Report Viewer UI implemented in this example
160160

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

163-
#### Add AI Assistant New Tab
163+
#### Add a New Tab for the AI Assistant
164164

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

@@ -190,11 +190,11 @@ Use the [`OnCustomizeTabs`](https://docs.devexpress.com/XtraReports/DevExpress.B
190190
}
191191
```
192192

193-
A new [`TabModel`](https://docs.devexpress.com/XtraReports/DevExpress.Blazor.Reporting.Models.TabModel._members) object is added to the list of tabs. 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 which defines the logic used to determine when the AI Assistant tab is displayed. The AI Assistant tab is only displayed when the report is initialized and contains at least one page.
193+
A new [`TabModel`](https://docs.devexpress.com/XtraReports/DevExpress.Blazor.Reporting.Models.TabModel._members) object is added to 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.
194194

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

197-
The content fot the AI Assistant tab is defined in the [AITabRenderer.razor](./DevExpress.AI.Samples.Blazor/Components/Reporting/AITabRenderer.razor) file:
197+
The content for the AI Assistant tab is defined in the following file: [AITabRenderer.razor](./DevExpress.AI.Samples.Blazor/Components/Reporting/AITabRenderer.razor).
198198

199199
```razor
200200
@using DevExpress.AI.Samples.Blazor.Models
@@ -224,7 +224,7 @@ The content fot the AI Assistant tab is defined in the [AITabRenderer.razor](./D
224224
}
225225
```
226226

227-
Use the [`MessageContentTemplate`](https://docs.devexpress.com/Blazor/DevExpress.AIIntegration.Blazor.Chat.DxAIChat.MessageContentTemplate) property to display rich formatted messages. Use a markdown processor to convert the response content to HTML code.
227+
Use the [`MessageContentTemplate`](https://docs.devexpress.com/Blazor/DevExpress.AIIntegration.Blazor.Chat.DxAIChat.MessageContentTemplate) property to display rich-formatted messages. Use a markdown processor to convert response content to HTML code.
228228

229229
**Files to Review:**
230230

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

235235
#### Set Up the AI Assistant
236236

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. In this example, report data is exported to PDF using the [`ExportToPdf`](https://docs.devexpress.com/CoreLibraries/DevExpress.XtraPrinting.PrintingSystemBase.ExportToPdf(System.IO.Stream)) method and is passed to the assistant along with the instructions:
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:
238238

239239
```razor
240240
@using DevExpress.AIIntegration.Blazor.Chat

0 commit comments

Comments
 (0)