AI
Feature
Experimental
This feature provides an AI agent for Grid. It provides a chat panel that allows the user to send messages to the agent and see the responses. Which allows the user to use natural language to interact with the Grid in different ways. For example, the user can ask the agent to filter the data, sort it, or select specific records. The agent can also perform data manipulation operations such as adding, updating, deleting records.
To use this feature, you need to provide a promptUrl to which the agent will send the prompts. On the other end of this URL, there should be a service that adds credentials to the request and forwards the prompt to the LLM API of your choice.
You also need to configure a apiPlugin which ensures the prompt format matches the API you are using.
new Grid({
features : {
ai : {
promptUrl : '/ai/prompt',
apiPlugin : OpenAIPlugin,
}
}
})
This is the minimum configuration required to get started, but you may also want to configure the following:
- model - Adds a model property to the prompt sent to the LLM API which is often required
- chatButton - Change the appearance of the chat button and the chat panel
- tools - Add custom tools to the agent's tool list, or remove existing unwanted tools
- userSettings - Provide the current user's settings
- userSettingsUpdate - To listen for changes to the user's settings and save them
And for voice input/output, check out:
- textToSpeechUrl - To enable read aloud responses
- transcribeUrl - To enable voice input
- voiceActivation - Listens for voice commands which start a voice conversation with the agent
But these are not all configurations available. Check out the demo linked in the right panel for a full configuration example. And make sure to read this documentation to learn more about all available configurations.
This feature is disabled by default
See also
- AIFilter - AI-powered data filtering
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
Shows an AI model selector in the SettingsPanel where the user can select between the available API:s
-
Set this to
trueor a config object to add a ChatButton -
Set to
trueto automatically console.log things that happen internally. AI responses and audio processing for example. -
An array of strings which will be circulated as waiting status texts when awaiting long AI responses Defaults to
['Waiting', 'Waiting ...', 'Still waiting', 'Still waiting ...'] -
The URL to send feedback (thumbs up/thumbs down) to
-
Additional options to pass to fetch requests
-
By default, data item which are targeted in an AI action will be highlighted in the UI. Set this to
falseto prevent this behavior. -
Set to
falseto not manage chat history on the client -
Max tokens setting (if applicable)
-
Set to
trueto enable @ mention support in the chat input field. When enabled, typing@followed by at least one character will search configured models and show a dropdown of matching records. Selecting a record inserts a mention tag that is sent as a structured token to the LLM. -
Minimum time in milliseconds that each async status message must be displayed before the next one replaces it. This ensures each status is visible long enough for the user to read.
-
AI model name (if applicable)
-
Set to
trueto enable the AI's planning tools (createPlan/completePlanSteps). When enabled, the AI is encouraged to lay out a plan before executing multi-step requests, which improves accuracy with smaller / less capable models. -
An array of previously submitted prompts, used for ArrowUp/ArrowDown history navigation in the chat panel. When the user sends a message, a promptHistoryUpdate event is fired so the application can persist the updated list (e.g. to localStorage). Set to
trueor an empty array ([]) to activate the history navigationHas a corresponding runtime promptHistory property.
-
The URL to send text prompts to
-
Enables support for redoing data modifying actions performed by the AI. Shows a redo icon under the last redoable message in the ChatPanel. Requires undo to be enabled.
-
Set to
trueto always prompt the user for confirmation before allowing the AI to add records -
Set to
trueto always prompt the user for confirmation before allowing the AI to remove records -
Set to
trueto always prompt the user for confirmation before allowing the AI to update records -
Set to
trueto upon creation, send a test prompt to verify the connection to the AI backend. If the test fails, a warning icon will be shown on the chat panel. -
Temperature setting (if applicable). Overrides the default temperature set by the apiPlugin.
-
A number of milliseconds a prompt is allowed to take before being aborted. Defaults to
60000(1 minute). -
Enables support for undoing data modifying actions performed by the AI. Shows an undo icon under the last undoable message in the ChatPanel.
-
A configuration object containing the user's preferred AI feature settings. If there is a matching AI feature class config, the user setting will take precedence JSON.
-
Experimental configuration of the AI verbosity. Valid values are
"1","2"and"3", where"1"is lowest. -
Set to
trueto always read aloud received messages. Set tofalseto not read aloud responses to recorded messages. Defaults toaudio-inputwhich reads received messages aloud if they are a response to a local audio message. -
Set to
trueto automatically start recording again after a voice response finishes playing. Only applies when the previous message was sent via voice input. -
Set to
trueto automatically stop any ongoing recording and audio playback when the chat panel is hidden. -
The URL to send text for speech synthesizing
-
The URL to send audio for transcribing
-
Configuration settings for voice activation
Properties
- conversationTimeout : Number600000
The time in milliseconds a voice conversation is allowed to be active. Defaults to 10 minutes.
- replyOnActivation : Booleantrue
Set to
trueto have the AI reply immediately when the phrase is recognized, without waiting for further user input. - language : String'en-US'
The language code for the native speech recognition
- autoStartDialogConfig : Object
Configuration object for the dialog asking the user to enable voice activation on page load
- phrase : String
The phrase to listen for to activate voice control
- autoStart : Booleanfalse
Set to
trueto start voice activation on page load - useNativeSpeechRecognition : Booleantrue
Set to
trueto use the browser's native speech recognition (if available). At this time, this is required to be set totrueto get voice activation to work.
- conversationTimeout : Number600000
-
Forces voice only mode, which hides the chat panel and only shows a record chat button.
-
Internal listeners, that cannot be removed by the user.
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of AI class, or subclass thereof.
-
A class property getter for the default values of internal properties for this class.
-
An array of previously submitted prompts, used for ArrowUp/ArrowDown history navigation in the chat panel. When the user sends a message, a promptHistoryUpdate event is fired so the application can persist the updated list (e.g. to localStorage). Set to
trueor an empty array ([]) to activate the history navigationHas a corresponding promptHistory config.
-
An empty array that can be used as a default value.
-
An empty object that can be used as a default value.
-
Identifies an object as an instance of AI class, or subclass thereof.
-
Identifies an object as an instance of AIBase class, or subclass thereof.
-
Identifies an object as an instance of InstancePlugin class, or subclass thereof.
-
Returns a copy of the full configuration which was used to configure this object.
-
This property is set to
truebefore theconstructorreturns. -
This property is set to
trueon entry to the destroy method. It remains on the objects after returning fromdestroy(). If isDestroyed istrue, this property will also betrue, so there is no need to test for both (for example,comp.isDestroying || comp.isDestroyed). -
The Widget which was passed into the constructor, which is the Widget we are providing extra services for.
Functions
Functions are methods available for calling on the class-
This optional class method is called when a class is mixed in using the mixin() method.
-
Internal function used to hook destroy() calls when using thisObj
-
Internal function used restore hooked destroy() calls when using thisObj
-
Internal function used to run a callback function after an event is triggered
-
Removes all listeners registered to this object by the application.
-
This will merge a feature's (subclass of InstancePlugin) keyMap with it's client's keyMap.