-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Grids AI Assistant: Add API Descriptions Part 2 #8767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 26_1
Are you sure you want to change the base?
Changes from all commits
71f8377
6229fdd
6ba4f7e
91938b7
ac898f3
c775071
b13ce10
14575ae
4099ff1
4bd320a
9bab617
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,11 @@ | ||
| --- | ||
| id: dxDataGrid.Options.aiAssistant | ||
| type: AIAssistant | ||
| inheritsType: AIAssistant | ||
| --- | ||
| --- | ||
| ##### shortDescription | ||
| <!-- Description goes here --> | ||
| Configures the {WidgetName} AI Assistant. | ||
|
|
||
| --- | ||
| <!-- Description goes here --> |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,145 @@ | ||||||
| --- | ||||||
| id: dxDataGrid.Options.aiAssistant.customizeResponseText | ||||||
| type: function(command) | ||||||
| --- | ||||||
| --- | ||||||
| ##### shortDescription | ||||||
| Customizes AI Assistant response texts for each requested command. | ||||||
|
|
||||||
| ##### param(command): DataGridCommandInfo | ||||||
| Information about the command. | ||||||
|
|
||||||
| ##### return: ResponseStatusTexts | ||||||
| Custom texts for **success** and **failure** response statuses. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| --- | ||||||
| Use this function to customize response message texts for AI Assistant commands. **customizeResponseText** is called for each requested command. The AI Assistant chat displays these texts below the response title. When a response includes multiple commands, the chat displays each command's text on separate lines. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| When a command succeeds, the AI Assistant chat displays the response text in green and prefixes the text with a checkmark button emoji (✅). When a command fails, the AI Assistant chat displays the text in red and prefixes with a cross mark emoji (❌) instead. | ||||||
|
arman-boyakhchyan marked this conversation as resolved.
arman-boyakhchyan marked this conversation as resolved.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| The **command** parameter contains the following fields: | ||||||
|
|
||||||
| - **name**: The command's name ([DataGridPredefinedCommandNames]({basewidgetpath}/Types/DataGridPredefinedCommandNames/)). | ||||||
| - **args**: Command arguments. Refer to [DataGridPredefinedCommands]({basewidgetpath}/Types/DataGridPredefinedCommands/) for information about the arguments of each available command. | ||||||
|
|
||||||
| Configure **customizeResponseText** to return an object with the following fields: | ||||||
|
|
||||||
| - **success**: Text to display when the command succeeds. | ||||||
| - **failure**: Text to display when the command fails. | ||||||
|
|
||||||
| Omit a field in the return object to use default texts. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| You can use this function to translate response texts. The following code snippet uses the [locale()](/Documentation/ApiReference/Common/Utils/localization/#locale) method to specify texts for multiple locales: | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ##### jQuery | ||||||
|
|
||||||
| <!-- tab: index.js --> | ||||||
| const currentLocale = DevExpress.localization.locale(); | ||||||
|
|
||||||
| $('#{widget-name}-container').dx{WidgetName}({ | ||||||
| aiAssistant: { | ||||||
| customizeResponseText(command) { | ||||||
| switch (currentLocale) { | ||||||
| case 'en': | ||||||
| return { | ||||||
| success: `Command succeeded: ${command.name}`, | ||||||
| failure: `Command failed: ${command.name}`, | ||||||
| }; | ||||||
| case 'fr': | ||||||
| return { /* Translated texts */ }; | ||||||
| } | ||||||
| }, | ||||||
| }, | ||||||
| }); | ||||||
|
|
||||||
| ##### Angular | ||||||
|
|
||||||
| <!-- tab: app.component.html --> | ||||||
| <dx-{widget-name}> | ||||||
| <dxo-{widget-name}-ai-assistant | ||||||
| [enabled]="true" | ||||||
| [customizeResponseText]="customizeResponseText" | ||||||
| ></dxo-{widget-name}-ai-assistant> | ||||||
| </dx-{widget-name}> | ||||||
|
|
||||||
| <!-- tab: app.component.ts --> | ||||||
| import { Dx{WidgetName}Module, type Dx{WidgetName}Types } from 'devextreme-angular/ui/{widget-name}'; | ||||||
| import { locale } from "devextreme/localization"; | ||||||
|
|
||||||
| export class AppComponent { | ||||||
| currentLocale = locale(); | ||||||
| customizeResponseText = (command) => { | ||||||
| switch (this.currentLocale) { | ||||||
| case 'en': | ||||||
| return { | ||||||
| success: `Command succeeded: ${command.name}`, | ||||||
| failure: `Command failed: ${command.name}`, | ||||||
| }; | ||||||
| case 'fr': | ||||||
| return { /* Translated texts */ }; | ||||||
| } | ||||||
| }; | ||||||
| } | ||||||
|
|
||||||
| ##### Vue | ||||||
|
|
||||||
| <!-- tab: App.vue --> | ||||||
| <template> | ||||||
| <Dx{WidgetName}> | ||||||
| <DxAIAssistant | ||||||
| :customize-response-text="customizeResponseText" | ||||||
| /> | ||||||
| </Dx{WidgetName}> | ||||||
| </template> | ||||||
|
|
||||||
| <script setup lang="ts"> | ||||||
| import { Dx{WidgetName}, DxAIAssistant, type Dx{WidgetName}Types } from 'devextreme-vue/{widget-name}'; | ||||||
| import { locale } from "devextreme/localization"; | ||||||
|
|
||||||
| const currentLocale = locale(); | ||||||
| function customizeResponseText(command) { | ||||||
| switch (currentLocale) { | ||||||
| case 'en': | ||||||
| return { | ||||||
| success: `Command succeeded: ${command.name}`, | ||||||
| failure: `Command failed: ${command.name}`, | ||||||
| }; | ||||||
| case 'fr': | ||||||
| return { /* Translated texts */ }; | ||||||
| } | ||||||
| }; | ||||||
| </script> | ||||||
|
|
||||||
| ##### React | ||||||
|
|
||||||
| <!-- tab: App.tsx --> | ||||||
| import { {WidgetName}, AIAssistant, type {WidgetName}Types } from 'devextreme-react/{widget-name}'; | ||||||
| import { locale } from "devextreme/localization"; | ||||||
|
|
||||||
| const currentLocale = locale(); | ||||||
| function customizeResponseText(command) { | ||||||
| switch (currentLocale) { | ||||||
| case 'en': | ||||||
| return { | ||||||
| success: `Command succeeded: ${command.name}`, | ||||||
| failure: `Command failed: ${command.name}`, | ||||||
| }; | ||||||
| case 'fr': | ||||||
| return { /* Translated texts */ }; | ||||||
| } | ||||||
| }; | ||||||
|
|
||||||
| function App() { | ||||||
| return ( | ||||||
| <{WidgetName}> | ||||||
| <AIAssistant | ||||||
| enabled={true} | ||||||
| customizeResponseText={customizeResponseText} | ||||||
| /> | ||||||
| </{WidgetName}> | ||||||
| ); | ||||||
| }; | ||||||
|
|
||||||
| --- | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid "texts" (plural). "Text" is uncountable and if you say "texts" it's closer to something like "manuscripts".
I'm also not sure about the phrase "requested command". You usually "run" or "execute" a command. You don't "request a command". Or a "request" can be a synonym for a "command".