You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-23Lines changed: 23 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -5,37 +5,37 @@
5
5
<!-- default badges end -->
6
6
# Report Viewer and Grid for Blazor — Integrate an AI Assistant based on Azure OpenAI
7
7
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.
9
9
10
-
Key implementation steps of integrating `DxAIChat` include:
10
+
To integrate an AI-powered chat into your application, complete the following key steps:
11
11
12
12
1. Register AI Services in the application.
13
-
2. Add `DxAIChat`to the application.
13
+
2. Add a `DxAIChat`component.
14
14
3. Export component data and pass it to the AI Assistant.
15
15
16
-
This example showcases the following DevExpress Blazor Components:
16
+
This example uses the following DevExpress Blazor Components:
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:
30
30
31
31
-*Drill-Down Report*: Analyze invoice totals, delivery statuses, and averages.
32
32
-*Market Share Report*: Compare market share changes across regions.
33
33
-*Restaurant Menu*: Examine price ranges and categorize vegetarian options.
34
34
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).
36
36
37
37
>[!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.
39
39
40
40
## Implementation Details
41
41
@@ -44,7 +44,7 @@ This example showcases the following DevExpress Blazor Components:
44
44
> [!NOTE]
45
45
> 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.
46
46
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:
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).
71
71
72
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).
### Use an AI Assistant with the DevExpress Blazor Grid
79
79
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:
81
81
82
82

83
83
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).
85
85
86
86
#### Add AI Chat to the Grid Page
87
87
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:
89
89
90
90
```razor
91
91
@using DevExpress.AIIntegration.Blazor.Chat
@@ -109,15 +109,15 @@ The following code snippet adds the [`DxAIChat`](https://docs.devexpress.com/Bla
109
109
}
110
110
```
111
111
112
-
Use the [`MessageContentTemplate`](https://docs.devexpress.com/Blazor/DevExpress.AIIntegration.Blazor.Chat.DxAIChat.MessageContentTemplate) property to display richformatted 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.
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.
121
121
122
122
```razor
123
123
@using DevExpress.AIIntegration.OpenAI.Services
@@ -160,7 +160,7 @@ The following image displays Blazor Report Viewer UI implemented in this example
160
160
161
161

162
162
163
-
#### Add AI Assistant New Tab
163
+
#### Add a New Tab for the AI Assistant
164
164
165
165
Use the [`OnCustomizeTabs`](https://docs.devexpress.com/XtraReports/DevExpress.Blazor.DxViewer.OnCustomizeTabs) event to add a new tab:
166
166
@@ -190,11 +190,11 @@ Use the [`OnCustomizeTabs`](https://docs.devexpress.com/XtraReports/DevExpress.B
190
190
}
191
191
```
192
192
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.
194
194
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.
196
196
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).
198
198
199
199
```razor
200
200
@using DevExpress.AI.Samples.Blazor.Models
@@ -224,7 +224,7 @@ The content fot the AI Assistant tab is defined in the [AITabRenderer.razor](./D
224
224
}
225
225
```
226
226
227
-
Use the [`MessageContentTemplate`](https://docs.devexpress.com/Blazor/DevExpress.AIIntegration.Blazor.Chat.DxAIChat.MessageContentTemplate) property to display richformatted 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.
228
228
229
229
**Files to Review:**
230
230
@@ -234,7 +234,7 @@ Use the [`MessageContentTemplate`](https://docs.devexpress.com/Blazor/DevExpress
234
234
235
235
#### Set Up the AI Assistant
236
236
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:
0 commit comments