public class AI
extends java.lang.Object
AI engines
, and performing high-level operations using installed AI engines.Constructor and Description |
---|
AI() |
Modifier and Type | Method and Description |
---|---|
static void |
askDataQuestion(java.lang.String question)
Asks AI to answer a question about the data of the application.
|
static void |
askDataQuestion(java.lang.String question,
DataSource... dataSources) |
static void |
askDataQuestion(java.lang.String question,
DataSource[] dataSources,
DataQuestionSettings settings) |
static void |
askDataQuestion(java.lang.String question,
DataSource[] dataSources,
DataQuestionSettings settings,
AskDataQuestionResultCallback callback)
Asks AI to answer a question about the data of the application.
|
static void |
askDataQuestion(UserAIRequest question)
Asks AI to answer a question about the data of the application.
|
static void |
cancelDataQuestion(java.lang.String questionId)
Cancels a data question if not already canceled.
|
static void |
checkModuleLoaded(java.lang.String faultingAction) |
static java.lang.String |
getDefaultEngineId()
The ID of the default
AIEngine to use. |
static int |
getDefaultMaxRetries()
The defualt maximum number of retries for any one particular request to AI.
|
static java.lang.Boolean |
getDisabled()
Whether AI is disabled.
|
static AIEngine |
getEngine()
Returns the
AIEngine having the given engine ID. |
static AIEngine |
getEngine(java.lang.String engineId)
Returns the
AIEngine having the given engine ID. |
static boolean |
isEnabled()
Determines whether AI support is enabled.
|
static boolean |
moduleLoaded()
Reports whether the optional AI module is loaded for the page.
|
static void |
pauseDataQuestion(java.lang.String questionId)
Pauses a data question if not already paused or canceled.
|
static void |
resumeDataQuestion(java.lang.String questionId)
Resumes a data question if paused.
|
static void |
sendPrompt(java.lang.String dynamicString,
java.util.Map context,
AIResponseCallback callback)
Evaluates the given
dynamic string to form a prompt string that is then
sent as the request to the default AI engine. |
static void |
setDefaultEngineId(java.lang.String defaultEngineId)
The ID of the default
AIEngine to use. |
static void |
setDefaultMaxRetries(int defaultMaxRetries)
The defualt maximum number of retries for any one particular request to AI.
|
static void |
setDisabled(java.lang.Boolean disabled)
Whether AI is disabled.
|
public static void setDefaultEngineId(java.lang.String defaultEngineId)
AIEngine
to use.defaultEngineId
- new defaultEngineId. Default value is "gpt-4o".public static java.lang.String getDefaultEngineId()
AIEngine
to use.public static void setDefaultMaxRetries(int defaultMaxRetries)
defaultMaxRetries
- new defaultMaxRetries. Default value is 2.public static int getDefaultMaxRetries()
public static void setDisabled(java.lang.Boolean disabled)
By default, AI is disabled. This static property must be set to false
and the
default
AIEngine
must be registered in
order to enable the use of AI in the application.
disabled
- new disabled. Default value is true.public static java.lang.Boolean getDisabled()
By default, AI is disabled. This static property must be set to false
and the
default
AIEngine
must be registered in
order to enable the use of AI in the application.
public static void askDataQuestion(java.lang.String question)
question
- The text of the end-user's question or their request for an answer to a data question.public static void askDataQuestion(UserAIRequest question)
question
- The text of the end-user's question or their request for an answer to a data question.public static void askDataQuestion(java.lang.String question, DataSource... dataSources)
askDataQuestion(java.lang.String)
public static void askDataQuestion(java.lang.String question, DataSource[] dataSources, DataQuestionSettings settings)
askDataQuestion(java.lang.String)
public static void askDataQuestion(java.lang.String question, DataSource[] dataSources, DataQuestionSettings settings, AskDataQuestionResultCallback callback)
question
- The text of the end-user's question or their request for an answer to a data question.dataSources
- The available data sources. All data sources in the array must have a global ID. If null
, then the array
of all DataSources available to the AI module is used.settings
- Settings to use when answering the data question.callback
- The callback to call with the result.public static void cancelDataQuestion(java.lang.String questionId)
questionId
- The ID of the data question to cancel.public static AIEngine getEngine()
AIEngine
having the given engine ID.AIEngine
, or null
if the AIEngine
could not be found.public static AIEngine getEngine(java.lang.String engineId)
AIEngine
having the given engine ID.engineId
- the engineId of the AIEngine
to get. If not specified, defaultEngineId
is used.AIEngine
, or null
if the AIEngine
could not be found.public static boolean isEnabled()
disabled
must be set to
false
and the default AIEngine
must be registered in order to enable the use
of AI.true
if the use of AI is enabled; false
otherwise.com.smartgwt.client.ai.AI#disabled
,
com.smartgwt.client.ai.AI#defaultEngineId
public static void pauseDataQuestion(java.lang.String questionId)
questionId
- The ID of the data question to pause.public static void resumeDataQuestion(java.lang.String questionId)
questionId
- The ID of the data question to resume.public static void sendPrompt(java.lang.String dynamicString, java.util.Map context, AIResponseCallback callback)
dynamic string
to form a prompt string that is then
sent as the request to the default AI engine. Within dynamicString
, any evaluated JavaScript
expressions have access to all of the values in the context
ValueMap.
dynamicString
- A dynamic string.
See DynamicString
context
- A map from each in-scope Identifier
to its value.callback
- The callback to fire with the response from AI.public static boolean moduleLoaded()
public static void checkModuleLoaded(java.lang.String faultingAction)