Skip to content

Commit 35bf208

Browse files
Grids AI Assistant: Add API Descriptions Part 2 (#8767)
1 parent 25678f0 commit 35bf208

40 files changed

Lines changed: 1116 additions & 181 deletions

File tree

api-reference/10 UI Components/GridBase/1 Configuration/aiIntegration.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,27 @@ default: undefined
88
Binds the {WidgetName} to an AI service.
99

1010
---
11-
To activate AI functionality in {WidgetName}, configure this object and assign *"ai"* to a column's [type](/api-reference/_hidden/dxDataGridColumn/type.md '{basewidgetpath}/Configuration/columns/#type') property.
11+
The DevExtreme {WidgetName} ships with the following AI features:
1212

13-
This object configures options for all AI columns within the component. To configure AI options specific to a column, define **columns[]**.**ai**.[aiIntegration](/api-reference/40%20Common%20Types/15%20grids/ColumnAIOptions/aiIntegration.md '{basewidgetpath}/Configuration/columns/ai/#aiIntegration').
13+
- AI Columns
14+
- AI Assistant
15+
16+
To activate these AI features, configure **aiIntegration** and specify {WidgetName} properties as follows:
17+
18+
- Assign *"ai"* to a column's [type](/api-reference/_hidden/dxDataGridColumn/type.md '{basewidgetpath}/Configuration/columns/#type') property to implement an AI Column.
19+
- Set **aiAssistant**.[enabled]({basewidgetpath}/Configuration/aiAssistant/#enabled) to `true` to activate the AI Assistant.
20+
21+
This object stores shared AI options for the {WidgetName} AI Assistant and all AI columns within the component. To configure AI options specific to a column, define **columns[]**.**ai**.[aiIntegration](/api-reference/40%20Common%20Types/15%20grids/ColumnAIOptions/aiIntegration.md '{basewidgetpath}/Configuration/columns/ai/#aiIntegration'). To configure AI options specific to the AI Assistant, define **aiAssistant**.[aiIntegration]({basewidgetpath}/Configuration/aiAssistant/#aiIntegration).
1422

1523
#include common-demobutton-named with {
1624
url: "https://js.devexpress.com/Demos/WidgetsGallery/Demo/DataGrid/AIColumns/",
17-
name: "DataGrid"
25+
name: "DataGrid - AI Columns"
1826
}
1927
#include common-demobutton-named with {
2028
url: "https://js.devexpress.com/Demos/WidgetsGallery/Demo/TreeList/AIColumns/",
21-
name: "TreeList"
22-
}
29+
name: "TreeList - AI Columns"
30+
}
31+
#include common-demobutton-named with {
32+
url: "https://js.devexpress.com/Demos/WidgetsGallery/Demo/DataGrid/AIAssistant/",
33+
name: "DataGrid - AI Assistant"
34+
}

api-reference/10 UI Components/GridBase/1 Configuration/onAIAssistantRequestCreating.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The model data. Available only if you use Knockout.
2929
The JSON schema of the AI Assistant response.
3030

3131
##### field(e.additionalInfo): Record
32-
<!-- Description goes here -->
32+
Additional information included in the AI Assistant request.
3333

3434
---
3535
Use this handler to modify the AI Assistant request.

api-reference/10 UI Components/dxDataGrid/1 Configuration/aiAssistant.md renamed to api-reference/10 UI Components/dxDataGrid/1 Configuration/aiAssistant/aiAssistant.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
22
id: dxDataGrid.Options.aiAssistant
33
type: AIAssistant
4+
inheritsType: AIAssistant
45
---
56
---
67
##### shortDescription
7-
<!-- Description goes here -->
8+
Configures the {WidgetName} AI Assistant.
89

910
---
1011
<!-- Description goes here -->
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
---
2+
id: dxDataGrid.Options.aiAssistant.customizeResponseText
3+
type: function(command)
4+
---
5+
---
6+
##### shortDescription
7+
Customizes AI Assistant response messages for each command.
8+
9+
##### param(command): DataGridCommandInfo
10+
Information about the command.
11+
12+
##### return: ResponseStatusTexts
13+
Custom messages for **success** and **failure** responses.
14+
15+
---
16+
**customizeResponseText** is called for each command. Use this function to customize response messages for AI Assistant commands. The chat displays these messages below the response title. If a response includes multiple commands, the chat displays each message on a separate line.
17+
18+
When a command succeeds, the AI Assistant chat displays the response in green and prefixes the text with a checkmark button emoji (✅). When a command fails, the AI Assistant chat displays the response in red and prefixes the text with a cross mark emoji (❌).
19+
20+
The **command** parameter contains the following fields:
21+
22+
- **name**: The command's name ([DataGridPredefinedCommandNames]({basewidgetpath}/Types/DataGridPredefinedCommandNames/)).
23+
- **args**: Command arguments. Refer to [DataGridPredefinedCommands]({basewidgetpath}/Types/DataGridPredefinedCommands/) for information about the arguments of each available command.
24+
25+
Configure **customizeResponseText** to return an object with the following fields:
26+
27+
- **success**: Text to display when the command succeeds.
28+
- **failure**: Text to display when the command fails.
29+
30+
If you do not specify any of these fields, the AI Assistant chat displays the default message.
31+
32+
You can use this function to localize response text. The following code snippet uses the [locale()](/Documentation/ApiReference/Common/Utils/localization/#locale) method to specify text for multiple locales:
33+
34+
---
35+
36+
##### jQuery
37+
38+
<!-- tab: index.js -->
39+
const currentLocale = DevExpress.localization.locale();
40+
41+
$('#{widget-name}-container').dx{WidgetName}({
42+
aiAssistant: {
43+
customizeResponseText(command) {
44+
switch (currentLocale) {
45+
case 'en':
46+
return {
47+
success: `Command succeeded: ${command.name}`,
48+
failure: `Command failed: ${command.name}`,
49+
};
50+
case 'fr':
51+
return { /* Translated texts */ };
52+
}
53+
},
54+
},
55+
});
56+
57+
##### Angular
58+
59+
<!-- tab: app.component.html -->
60+
<dx-{widget-name}>
61+
<dxo-{widget-name}-ai-assistant
62+
[enabled]="true"
63+
[customizeResponseText]="customizeResponseText"
64+
></dxo-{widget-name}-ai-assistant>
65+
</dx-{widget-name}>
66+
67+
<!-- tab: app.component.ts -->
68+
import { Dx{WidgetName}Module, type Dx{WidgetName}Types } from 'devextreme-angular/ui/{widget-name}';
69+
import { locale } from "devextreme/localization";
70+
71+
export class AppComponent {
72+
currentLocale = locale();
73+
customizeResponseText = (command) => {
74+
switch (this.currentLocale) {
75+
case 'en':
76+
return {
77+
success: `Command succeeded: ${command.name}`,
78+
failure: `Command failed: ${command.name}`,
79+
};
80+
case 'fr':
81+
return { /* Translated texts */ };
82+
}
83+
};
84+
}
85+
86+
##### Vue
87+
88+
<!-- tab: App.vue -->
89+
<template>
90+
<Dx{WidgetName}>
91+
<DxAIAssistant
92+
:customize-response-text="customizeResponseText"
93+
/>
94+
</Dx{WidgetName}>
95+
</template>
96+
97+
<script setup lang="ts">
98+
import { Dx{WidgetName}, DxAIAssistant, type Dx{WidgetName}Types } from 'devextreme-vue/{widget-name}';
99+
import { locale } from "devextreme/localization";
100+
101+
const currentLocale = locale();
102+
function customizeResponseText(command) {
103+
switch (currentLocale) {
104+
case 'en':
105+
return {
106+
success: `Command succeeded: ${command.name}`,
107+
failure: `Command failed: ${command.name}`,
108+
};
109+
case 'fr':
110+
return { /* Translated texts */ };
111+
}
112+
};
113+
</script>
114+
115+
##### React
116+
117+
<!-- tab: App.tsx -->
118+
import { {WidgetName}, AIAssistant, type {WidgetName}Types } from 'devextreme-react/{widget-name}';
119+
import { locale } from "devextreme/localization";
120+
121+
const currentLocale = locale();
122+
function customizeResponseText(command) {
123+
switch (currentLocale) {
124+
case 'en':
125+
return {
126+
success: `Command succeeded: ${command.name}`,
127+
failure: `Command failed: ${command.name}`,
128+
};
129+
case 'fr':
130+
return { /* Translated texts */ };
131+
}
132+
};
133+
134+
function App() {
135+
return (
136+
<{WidgetName}>
137+
<AIAssistant
138+
enabled={true}
139+
customizeResponseText={customizeResponseText}
140+
/>
141+
</{WidgetName}>
142+
);
143+
};
144+
145+
---

0 commit comments

Comments
 (0)