Skip to content

TFmxHelpChatAI reference ​

Unit FMX.HelpChatAI · package HelpChatAIFmx · palette group Ethea HelpChat · Delphi 12 and later.

The FireMonkey twin of TVclHelpChatAI: same engine, same page, same events. Only what FireMonkey does differently is different.

Published properties ​

PropertyTypeDefaultDescription
SettingsTHelpChatSettingsSee the Settings reference
ActiveBooleanFalseAcquires the engine of the profile and starts it, starts the transport and the hooks. Raises, and stays False, when the configuration cannot be read or the server cannot start
RegisterHelpViewerBooleanTrueRegister with System.HelpIntfs, for code that calls the help system
HandleF1BooleanTrueF1 on the host form opens the chat (its OnKeyDown is chained)
Captionstring(empty)Title of the window the chat opens in when it is not embedded. Empty = the localized "Help" / "Aiuto"
Profilestring(empty)Which assistant this is: its section under "Profiles" in the configuration and the suffix of its files. Never shown. Empty = the default assistant
AssistantNamestring(empty)What the assistant is called, written in the header of the panel next to its icon. Empty = the localized "Assistant" / "Assistente". "AssistantName" in the configuration prevails
ShowBubbleBooleanTrueThe round button with the assistant icon, in the bottom-right corner of the host form
BubbleDraggableBooleanTrueThe user may drag the bubble to another place of its form: it keeps its distance from the nearest corner, and is found there again (The bubble)
BubbleStayOnTopBooleanFalseMain form only, on Windows: the bubble stays in front of every form of the application, modal ones included, and may be dragged anywhere on the monitor (Keeping the bubble in front)
ImagesTCustomImageListnilImage list holding the bubble icon; nil uses the icons compiled into the component. The same icon is drawn in the header of the chat panel
ImageIndexTImageIndex-1The icon by position. With no image list of your own it picks among the built-in ones
ImageNamestring(empty)The icon by name: with no Images, one of AIAssistant_Male, AIAssistant_Female, Assistant_Male, Assistant_Female, Businessman, Businesswoman, CustomerSupport, Manager, VoicePresentation, PortraitMode (HELPCHAT_ICON_NAMES). The Object Inspector drops them down
ConfigFileNameTFileName(empty)The configuration file. Empty = merge the three standard helpchatai.json on activation; named = that one and nothing else, raising EHelpChatConfigError if it is not there
PanelStyleSheetTFileName(empty)A CSS file of the application, added to the page of the chat after its own (a radius, a spacing, a hidden button: Inside the panel); it reaches OnGetTheme as ATheme.StyleSheet. Read at activation; a named file that is not there raises EHelpChatConfigError
PdfStyleSheetTFileName(empty)The stylesheet a saved PDF is laid out with; empty = the one built into the library. A named file that is not there raises EHelpChatConfigError
PdfHeaderFileTFileName(empty)The template of the band at the top of every sheet, with its placeholders
PdfFooterFileTFileName(empty)The template of the band at the foot
ActionsEnabledBooleanTrueOffer the registered actions to the model
UseSharedActionsBooleanTrueOffer also the actions every assistant shares (HelpChatSharedActions); Settings.AllowedActions narrows both
EnabledCommandsTHelpChatCommandseverything but prompt and runThe slash commands the user may type. From code any command runs
RememberPanelPositionBooleanTrueReopen the own window where the user left it, and show the bubble where it was dragged to
ThemeModeTFmxHelpChatThemeModetmAutotmAuto (page defaults, following the system), tmLight, tmDark
ContainerTFmxObjectnilWhere the chat is embedded; nil = the component's own window
PanelWidthInteger400Size of the own window
PanelHeightInteger600

Published events ​

Identical to the VCL ones, except that OnBeforeShowHelp carries a TFmxObject and that the two voice events (OnVoiceText, OnVoiceConsentNeeded) do not exist: dictation is VCL only.

EventSignature
OnGetContext(Sender; var AContext: THelpChatContext)
OnGetTheme(Sender; var ATheme: THelpChatTheme)
OnBeforeShowHelp(Sender; var AContainer: TFmxObject)
OnAfterShowHelp / OnBeforeHideHelp / OnAfterHideHelp(Sender)
OnModelChanged(Sender)
OnActionConfirm(Sender; const AName; const AArgs; var AAllow)
OnActionExecuted(Sender; const AName; const AOutcome; const AResult)
OnPdfInfo(Sender; var AInfo: THelpChatPdfInfo)
OnDecryptSecret(Sender; const AName, AValue; var AResult; var AHandled)
OnBuildSystemPrompt(Sender; const AContext: THelpChatContext; const ALanguage: THelpChatLanguage; var APrompt: string)
OnLogEvent(Sender; const AEntry: THelpChatLogEntry) - see Logging
OnOpenLink(Sender; const AUrl; var AHandled)

Confirmation on a mobile platform

With no OnActionConfirm, on Windows and macOS the confirmation dialog of the library asks. On a mobile platform a modal form answers later, in a callback, while a worker thread is waiting for the answer now: there an action marked Confirm is refused unless OnActionConfirm is assigned.

Methods ​

Same as the VCL — Open, OpenForCurrentScreen, OpenForHelp, OpenWithQuestion, Close, Toggle, Assign, ResetBubblePosition, IsPanelVisible, OpenDocPage, BuildContext, BuildTheme, ApplyTheme, ResolvedCaption, ResolvedAssistantName, AssistantIconDataUri, ApplyAssistant, IsHelpViewerActive, ResolvedHostForm (a TCommonCustomForm), and what the panel does from code: ExecuteCommand, ExplainCommand, ClearConversation, Models, SelectModel, Languages, ActiveLanguage, SelectLanguage (see Languages), RetryLastQuestion, SaveConversationPdf, CopyLastAnswer, AttachFile (see Slash commands). There is no ActiveControlHasHelp: FireMonkey routes no F1 to a help system. What is its own:

MethodDescription
HandleKeyDown(var AKey: Word; const AShift: TShiftState): BooleanCall it from the OnKeyDown of a form that has no assistant of its own, on any assistant: a plain F1 goes to the current assistant - the one of the active form, else the one whose form was active last. Returns True, with AKey set to 0, when it consumed the key. The host form of a component needs no call: its OnKeyDown is chained at activation
CurrentAssistant: TFmxHelpChatAI (class)The assistant F1 goes to now, nil when none takes it
ResolvedImageName: stringThe name of the icon actually used: ImageName, or - with no image list of yours - the built-in one ImageIndex points at, or the default
AssistantIconPng: TBytesThe icon of the bubble as a PNG; empty when there is none
RunSettings: THelpChatSettingsThe settings in force: the engine's while active - with the model and the language the user picked in the panel applied - else Settings. Read RunSettings.ActiveModelName, RunSettings.Provider and the key of that model here, not on Settings

Public properties ​

Actions, Engine and Transport as in the VCL; ActiveContainer is a TFmxObject, View a TFmxHelpChatAIPanel and OwnForm a TFmxHelpChatAIForm. HostForm (TCommonCustomForm) is public and not published, as in the VCL: set it in code, because at design time there would be nothing to choose from. When that form is destroyed the assistant has no form until another one - or nil - is assigned.

Minimal example ​

pascal
uses
  System.IOUtils, HelpChatAI.Types, FMX.HelpChatAI,
  HelpChatAI.Provider.DocSearch;   // a provider exists only if its unit is linked

procedure TMainForm.FormCreate(Sender: TObject);
begin
  HelpChatAI.Settings.Provider := 'docsearch';
  HelpChatAI.Settings.DocIndexFile := TPath.Combine(
    TPath.GetDirectoryName(ParamStr(0)), 'help-index.json');
  HelpChatAI.ThemeMode := tmAuto;
  HelpChatAI.Active := True;
end;

// a form with no assistant of its own (the host form needs no call)
procedure TOrdersForm.FormKeyDown(Sender: TObject; var Key: Word;
  var KeyChar: WideChar; Shift: TShiftState);
begin
  MainForm.HelpChatAI.HandleKeyDown(Key, Shift);
end;

Platform notes ​

  • Windows: WebView2 (WindowsEngine = EdgeOnly), verified.
  • macOS, iOS, Android: the native web view; the code compiles but has not been tested yet.
  • Delphi 12: a navigation outside the panel cannot be cancelled (OnShouldLoadURL arrived in Delphi 13), so an external link opens in the system browser (or reaches OnOpenLink) and the panel returns to its own page.
  • On mobile, use a remote server: no local HTTP server, no key in the package.

Released under the Apache License 2.0