Package com.smartgwt.client.ai
Class AI
java.lang.Object
com.smartgwt.client.ai.AI
Provides class methods for enabling and disabling the use of AI technology, registering and unregistering
AI engines, and performing high-level operations using installed AI engines.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplyAIFilter(ApplyAIFilterRequest applyRequest, ApplyAIFilterResponseCallback callback) Requests that available AI engine(s) be used to evaluate an "aiFilter"AdvancedCriteriaon a list of records.static voidaskDataQuestion(String question, DataSource[] dataSources, DataQuestionSettings settings, AskDataQuestionResultCallback callback) Asks AI to answer a question about the data of the application.static voidbuildAIFieldRequest(BuildAIFieldRequestRequest buildRequest, BuildAIFieldRequestResponseCallback callback) Requests that available AI engine(s) be used to build anAIFieldRequestfrom a natural language description of the per-record values to generate for a new AI-generated field.static voidbuildCriterion(BuildCriterionRequest buildRequest, BuildCriterionResponseCallback callback) Requests that available AI engine(s) be used to build anAdvancedCriteriaobject according to the user's natural language description of a filter.static voidbuildDataBoundUI(BuildDataBoundUIViaAIRequest buildRequest, BuildUIViaAIResponseCallback callback) Requests that available AI engine(s) be used to build data-bound UI component(s) according to a user's description of what they would like to build.static voidbuildHilites(BuildHilitesRequest buildRequest, BuildHilitesResponseCallback callback) Requests that available AI engine(s) be used to build one or moreHiliteobjects according to the user's natural language description of hilite criteria and styling to apply.static voidcancelDataQuestion(String questionId) Cancels a data question if not already canceled.static voidclearAIFilterCaches(AdvancedCriteria aiCriterion) Removes information for all records to which an "aiFilter"AdvancedCriteriahas been applied.static StringThe ID of the defaultAIEngineto use.static intThe defualt maximum number of retries for any one particular request to AI.static BooleanWhether AI is disabled.static AIEngineReturns theAIEnginehaving the given engine ID.static AIEngineReturns theAIEnginehaving the given engine ID.static BooleanisAIFieldRequestNumerical(AIFieldRequest aiFieldRequest) Returnstrueif the givenAIFieldRequestis numerical (itsvalueClassis ORDINAL, INTERVAL, or RATIO);falseotherwise.static booleanDetermines whether AI support is enabled.static voidpauseDataQuestion(String questionId) Pauses a data question if not already paused or canceled.static booleanregisterEngine(AIEngine engine) Registers the givenAIEngine.static voidremoveFromAIFilterCaches(AdvancedCriteria aiCriterion, Record... records) Removes information for the given records from an "aiFilter"AdvancedCriteria.static voidresumeDataQuestion(String questionId) Resumes a data question if paused.static voidsetDefaultEngineId(String defaultEngineId) The ID of the defaultAIEngineto use.static voidsetDefaultMaxRetries(int defaultMaxRetries) The defualt maximum number of retries for any one particular request to AI.static voidsetDisabled(Boolean disabled) Whether AI is disabled.static voidsuggestRecordSummaryTitle(SuggestRecordSummaryTitleRequest request, SuggestRecordSummaryTitleCallback callback) Requests that availableAIEngine(s) be used to suggest an appropriate title for a new field that will contain AI-generated record summaries.static voidsummarizeRecords(SummarizeRecordsRequest request, SummarizeRecordsPartialResultCallback partialResultCallback, SummarizeRecordsResultCallback callback) Requests that available AI engine(s) be used to generate summaries of records according to the user's natural language description of how to summarize each record.static voidsummarizeValue(SummarizeValueRequest request, SummarizeValueResultCallback callback) Requests that available AI engine(s) be used to generate a summary of a value according to a natural language description of how to summarize the value.static booleanunregisterEngine(String engineId) Unregisters anAIEnginespecified by its ID.
-
Constructor Details
-
AI
public AI()
-
-
Method Details
-
setDefaultEngineId
The ID of the defaultAIEngineto use.- Parameters:
defaultEngineId- new defaultEngineId. Default value is "gpt-4o".
-
getDefaultEngineId
The ID of the defaultAIEngineto use.- Returns:
- current value of defaultEngineId
-
setDefaultMaxRetries
public static void setDefaultMaxRetries(int defaultMaxRetries) The defualt maximum number of retries for any one particular request to AI.- Parameters:
defaultMaxRetries- new defaultMaxRetries. Default value is 2.
-
getDefaultMaxRetries
public static int getDefaultMaxRetries()The defualt maximum number of retries for any one particular request to AI.- Returns:
- current value of defaultMaxRetries
-
setDisabled
Whether AI is disabled.By default, AI is disabled. This static property must be set to
falseand thedefaultAIEnginemust be registered in order to enable the use of AI in the application.- Parameters:
disabled- new disabled. Default value is true.
-
getDisabled
Whether AI is disabled.By default, AI is disabled. This static property must be set to
falseand thedefaultAIEnginemust be registered in order to enable the use of AI in the application.- Returns:
- current value of disabled
-
applyAIFilter
public static void applyAIFilter(ApplyAIFilterRequest applyRequest, ApplyAIFilterResponseCallback callback) Requests that available AI engine(s) be used to evaluate an "aiFilter"AdvancedCriteriaon a list of records.- Parameters:
applyRequest- The request to AI to evaluate an "aiFilter"AdvancedCriteria.callback- The callback to call with the result.
-
askDataQuestion
public static void askDataQuestion(String question, DataSource[] dataSources, DataQuestionSettings settings, AskDataQuestionResultCallback callback) Asks AI to answer a question about the data of the application.- Parameters:
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. Ifnull, 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.
-
buildAIFieldRequest
public static void buildAIFieldRequest(BuildAIFieldRequestRequest buildRequest, BuildAIFieldRequestResponseCallback callback) Requests that available AI engine(s) be used to build anAIFieldRequestfrom a natural language description of the per-record values to generate for a new AI-generated field.- Parameters:
buildRequest- The request.callback- The callback to fire with the result.
-
buildCriterion
public static void buildCriterion(BuildCriterionRequest buildRequest, BuildCriterionResponseCallback callback) Requests that available AI engine(s) be used to build anAdvancedCriteriaobject according to the user's natural language description of a filter.- Parameters:
buildRequest- The request.callback- The callback to fire with the result.
-
buildDataBoundUI
public static void buildDataBoundUI(BuildDataBoundUIViaAIRequest buildRequest, BuildUIViaAIResponseCallback callback) Requests that available AI engine(s) be used to build data-bound UI component(s) according to a user's description of what they would like to build.- Parameters:
buildRequest- The request to AI to build data-bound UI.callback- The callback to call with the result.
-
buildHilites
public static void buildHilites(BuildHilitesRequest buildRequest, BuildHilitesResponseCallback callback) Requests that available AI engine(s) be used to build one or moreHiliteobjects according to the user's natural language description of hilite criteria and styling to apply.- Parameters:
buildRequest- The request to AI to buildHiliteobject(s).callback- The callback to call with the result.
-
cancelDataQuestion
Cancels a data question if not already canceled.- Parameters:
questionId- The ID of the data question to cancel.
-
clearAIFilterCaches
Removes information for all records to which an "aiFilter"AdvancedCriteriahas been applied.- Parameters:
aiCriterion- The "aiFilter"AdvancedCriteriato update.
-
getEngine
Returns theAIEnginehaving the given engine ID.- Returns:
- the
AIEngine, ornullif theAIEnginecould not be found.
-
getEngine
Returns theAIEnginehaving the given engine ID.- Parameters:
engineId- the engineId of theAIEngineto get. If not specified,defaultEngineIdis used.- Returns:
- the
AIEngine, ornullif theAIEnginecould not be found.
-
isAIFieldRequestNumerical
Returnstrueif the givenAIFieldRequestis numerical (itsvalueClassis ORDINAL, INTERVAL, or RATIO);falseotherwise.- Parameters:
aiFieldRequest- TheAIFieldRequestto test.- Returns:
trueif and only if the givenAIFieldRequestis numerical.
-
isEnabled
public static boolean isEnabled()Determines whether AI support is enabled.disabledmust be set tofalseand the defaultAIEnginemust be registered in order to enable the use of AI.- Returns:
trueif the use of AI is enabled;falseotherwise.- See Also:
-
com.smartgwt.client.ai.AI#disabledcom.smartgwt.client.ai.AI#defaultEngineId
-
pauseDataQuestion
Pauses a data question if not already paused or canceled.- Parameters:
questionId- The ID of the data question to pause.
-
registerEngine
Registers the givenAIEngine.- Parameters:
engine- TheAIEngineto register.- Returns:
trueif theAIEnginewas successfully registered;falseotherwise.- See Also:
-
removeFromAIFilterCaches
Removes information for the given records from an "aiFilter"AdvancedCriteria.- Parameters:
aiCriterion- The "aiFilter"AdvancedCriteriato update.records- The records, about which any information held inaiCriterionwill be removed.
-
resumeDataQuestion
Resumes a data question if paused.- Parameters:
questionId- The ID of the data question to resume.
-
suggestRecordSummaryTitle
public static void suggestRecordSummaryTitle(SuggestRecordSummaryTitleRequest request, SuggestRecordSummaryTitleCallback callback) Requests that availableAIEngine(s) be used to suggest an appropriate title for a new field that will contain AI-generated record summaries.- Parameters:
request- The request.callback- The callback to fire with the result.
-
summarizeRecords
public static void summarizeRecords(SummarizeRecordsRequest request, SummarizeRecordsPartialResultCallback partialResultCallback, SummarizeRecordsResultCallback callback) Requests that available AI engine(s) be used to generate summaries of records according to the user's natural language description of how to summarize each record.- Parameters:
request- The request.partialResultCallback- The callback to fire with each partial result.callback- The callback to fire with the result.
-
summarizeValue
public static void summarizeValue(SummarizeValueRequest request, SummarizeValueResultCallback callback) Requests that available AI engine(s) be used to generate a summary of a value according to a natural language description of how to summarize the value.- Parameters:
request- The request.callback- The callback to fire with theSummarizeValueResult.
-
unregisterEngine
Unregisters anAIEnginespecified by its ID.- Parameters:
engineId- the ID of theAIEngineto unregister.- Returns:
trueif theAIEnginewas successfully unregistered;falseotherwise.- See Also:
-