Initialization
modAI is available globally in manager, if you need to init it elsewhere, you can follow the instructions below.
Loading up pre-requisites
The following script will get the modai service (which can be null if it doesn't exist or if user doesn't have appropriate permissions). Then it loads lexicons needed for the modAI's UI and load the main JS file.
Initializing modAI
When the main JS file is loaded, ModAI.init function will be available. It takes single config argument, with following parameters. We recommend using helper function to supply all necessary properties to the config $modAI->getBaseConfig(), you can check the usage in the example at the end of this page.
Properties
name(string, optional): Application nameassetsURL(string): Base URL for application assetsapiURL(string): Base URL for API endpointscssURL(string): URL for application stylesheetstranslateFn(function, optional): Translation function for internationalizationavailableAgents(Record<string, AvailableAgent>): Map of available AI agentspermissions(Record<Permissions, 1 | 0>): Map of user permissions
Returns
An object containing initialized modules:
chatHistory: Chat history managementhistory: History trackingexecutor: Command executionui: User interface componentslng: Language/translation utilitiescheckPermissions: Function to check if user has specific permissioninitOnResource: Resource initializationinitGlobalButton: Global button initialization