TdxAICommandList Class
A collection of AI-powered commands.
Declaration
TdxAICommandList = class sealed(TObject)
Remarks
The TdxAICommandList
class implements a pre-populated list of AI-powered commands available in all supported native VCL controls. You can handle an OnGetAICommands event in any supported control to customize the list of available commands as demonstrated in code examples below.
Pre-Populated Command List
A TdxAICommandList
collection accessible through the AAICommands
parameter within an OnGetAICommands event handler is populated with the following AI-powered command IDs (declared in the dxAI.Commands.Consts
unit):
TdxAICommandIDs.Expand
- Expands original text with additional information or in-depth explanations.
TdxAICommandIDs.Shorten
- Removes redundant details and makes content more concise.
TdxAICommandIDs.Summarize
- Creates a brief summary based on original text.
TdxAICommandIDs.Explain
- Rephrases text in more clear terms and makes complex content more accessible and understandable.
TdxAICommandIDs.Proofread
- Reviews text for spelling, grammar, punctuation, and style errors.
TdxAICommandIDs.ChangeTone
The Change Tone command group is designed to adjust text tone to meet specific audience or context requirements. This group includes the following nested commands:
- Professional (
TdxAICommandIDs.ChangeTone.Professional
) - Casual (
TdxAICommandIDs.ChangeTone.Casual
) - Straightforward (
TdxAICommandIDs.ChangeTone.Straightforward
) - Confident (
TdxAICommandIDs.ChangeTone.Confident
) - Friendly (
TdxAICommandIDs.ChangeTone.Friendly
)
- Professional (
TdxAICommandIDs.ChangeStyle
The Change Style command group is designed to rephrase or paraphrase original text while retaining its original meaning. This group includes the following nested commands:
- Formal (
TdxAICommandIDs.ChangeStyle.Formal
) - Informal (
TdxAICommandIDs.ChangeStyle.Informal
) - Technical (
TdxAICommandIDs.ChangeStyle.Technical
) - Business (
TdxAICommandIDs.ChangeStyle.Business
) - Creative (
TdxAICommandIDs.ChangeStyle.Creative
) - Journalistic (
TdxAICommandIDs.ChangeStyle.Journalistic
) - Academic (
TdxAICommandIDs.ChangeStyle.Academic
) - Persuasive (
TdxAICommandIDs.ChangeStyle.Persuasive
) - Narrative (
TdxAICommandIDs.ChangeStyle.Narrative
) - Expository (
TdxAICommandIDs.ChangeStyle.Expository
) - Descriptive (
TdxAICommandIDs.ChangeStyle.Descriptive
) - Conversational (
TdxAICommandIDs.ChangeStyle.Conversational
)
- Formal (
TdxAICommandIDs.Translate
The Translate command group is designed to translate original text into a different language. Includes the following nested commands that correspond to individual target languages:
- English (
TdxAICommandIDs.Translate.English
) - German (
TdxAICommandIDs.Translate.German
) - French (
TdxAICommandIDs.Translate.French
)
- English (
Main API Members
The list below outlines key members of the TdxAICommandList
class. These members allow you to add/remove/rearrange individual end-user AI commands in the pre-populated list as well as change their status.
AI Command Collection Management
- Add | Delete | Remove
- Add and remove individual commands.
- Clear
- Clears the AI command collection.
- Count
- Returns the number of AI-powered commands in the collection.
- Exchange
- Swaps two individual AI-powered commands.
- Insert
- Inserts a new command at the target position.
- Move
- Moves a command within the collection.
AI Command Availability
- Available
Specifies if an individual AI-powered command is available to users.
Tip
This property allows you to enable or disable UI elements and other options (such as dedicated keystrokes) associated with end-user AI commands.
- Find | IndexOf
- Return the index of the target command in the collection (
-1
if no such command is present in the collection).
Code Examples
Rearrange AI-Powered Commands
The following code example moves Explain and Proofread commands to the second and third positions in a context menu, respectively:
uses
dxRichEdit.Control, // Declares TdxRichEditControl
dxAI; // Declares AI-specific types
// ...
procedure TMyForm.dxRichEditControl1GetAICommands(Sender: TObject;
const AAICommands: TdxAICommandList);
var
ACommandIndex: Integer;
begin
ACommandIndex := AAICommands.IndexOf(TdxAICommandIDs.Explain);
AAICommands.Move(ACommandIndex, 1); // Moves "Explain" to the second position (after "Expand")
ACommandIndex := AAICommands.IndexOf(TdxAICommandIDs.Proofread);
AAICommands.Move(ACommandIndex, 2); // Moves "Proofread" to the third position (after "Explain")
end;
Hide AI-Powered Commands
The following code example hides all AI-powered commands (removes the AI Assistant item) when no content is selected in the document:
uses
dxRichEdit.Control, // Declares TdxRichEditControl
dxAI; // Declares AI-specific types
// ...
procedure TMyForm.dxRichEditControl1GetAICommands(Sender: TObject;
const AAICommands: TdxAICommandList);
begin
if ((Sender as TdxRichEditControl).Document.Selections.Count = 0) or
((Sender as TdxRichEditControl).Document.Selection.Length = 0) then
AAICommands.Clear;
end;
Disable Individual AI-Powered Commands
The following code example disables Expand, Shorten and Summarize commands in the context menu:
uses
dxRichEdit.Control, // Declares TdxRichEditControl
dxAI, // Declares AI-specific types
dxAI.Commands.Consts; // Declares AI command identifiers
// ...
procedure TMyForm.dxRichEditControl1GetAICommands(Sender: TObject;
const AAICommands: TdxAICommandList);
begin
AAICommands.Available[TdxAICommandIDs.Expand] := False;
AAICommands.Available[TdxAICommandIDs.Shorten] := False;
AAICommands.Available[TdxAICommandIDs.Summarize] := False;
end;
Direct TdxAICommandList Class Reference
The TdxOnGetAICommands procedural type references a TdxAICommandList
object as the AAICommands
parameter.