Flutter Intelligence Service
Functions
isModelFilesDownloaded
Future<bool> isModelFilesDownloaded(String name)
Checks whether model files for the given model name are already downloaded.
Parameters:
name: String— Model name (Orchestrator → Managed AI Models → Programmatic name).
loadModel
Future<void> loadModel(
String name,
String key, {
ModelParams? modelParams,
})
Loads the specified model into memory with optional parameters. Use key to identify this loaded session for invoke, unload, and stop operations.
Parameters:
name: String— Model name (Orchestrator → Managed AI Models → Programmatic name).key: String— Session key for this load (used with invokeModel, unload, and stopModelInference).modelParams: ModelParams?— Optional model configuration.
unloadModel
Future<void> unloadModel({String? key})
Unloads the model for the given session key and releases memory. If key is omitted, behavior follows native defaults.
Parameters:
key: String?— Session key returned from loadModel; optional.
stopModelInference
Future<void> stopModelInference(String key)
Requests cancellation of an in-flight generation for the given session key.
Parameters:
key: String— Session key for the loaded model.
downloadModelFiles
Future<void> downloadModelFiles(
String name, {
void Function(double progress)? onProgress,
})
Downloads model files and optionally reports progress.
Parameters:
name: String— Model name (Orchestrator → Managed AI Models → Programmatic name).onProgress: void Function(double)— Optional progress callback, receives a value between 0.0 and 1.0.
deleteModelFiles
Future<void> deleteModelFiles(String name)
Deletes all downloaded local files for the given model.
Parameters:
name: String— Model name (Orchestrator → Managed AI Models → Programmatic name).
getDownloadedModelsList
Future<List<String>> getDownloadedModelsList()
Retrieves the list of model names whose files are downloaded locally.
Parameters: None.
isModelLoaded
Future<bool> isModelLoaded(String key)
Returns whether a model is currently loaded for the given session key.
Parameters:
key: String— Session key.
invokeModel
Future<String> invokeModel(
String key,
List<Prompt> prompts, {
InferenceParams? inferenceParams,
void Function(String chunk)? onStream,
})
Sends prompts to the model and returns the generated output.
Parameters:
key: String— Session key from loadModel (not the catalog model name).prompts: List— Array of messages.inferenceParams: InferenceParams?— Optional inference settings.onStream: void Function(String)?— Optional callback called with streamed partial output chunks.
syncRules
Future<void> syncRules()
Synchronizes rule definitions with the Orchestrator.
Parameters: None.
getRules
Future<List<Rule>> getRules()
Returns all stored rules.
Parameters: None.
getRule
Future<Rule?> getRule(String name)
Retrieves a rule by its name. Returns null if the rule is not found.
Parameters:
name: String— Rule name.
runRule
Future<Rule?> runRule(String name)
Evaluates a rule and returns its updated state. Returns null if the rule is not found.
Parameters:
name: String— Rule name.
runRules
Future<List<Rule>> runRules({bool onlyOnInit = false})
Evaluates multiple rules at once.
Parameters:
onlyOnInit: bool— If true, only initialization rules run.
syncManagedAIModels
Future<void> syncManagedAIModels()
Synchronizes the list of managed AI models with the Orchestrator.
Parameters: None.
getManagedAIModels
Future<List<ManagedAIModel>> getManagedAIModels()
Retrieves all managed AI models stored locally.
Parameters: None.
getManagedAIModel
Future<ManagedAIModel?> getManagedAIModel(String name)
Retrieves a specific managed AI model by name. Returns null if the model is not found.
Parameters:
name: String— Model name (Orchestrator → Managed AI Models → Programmatic name).
Classes
PromptRole
enum PromptRole {
system('system'),
user('user'),
assistant('assistant');
}
Prompt
class Prompt {
final PromptRole role;
final String content;
final String? attachment;
}
LlamaGrammarConfig
class LlamaGrammarConfig {
final String grammar;
final String grammarRoot;
}
InferenceParams
class InferenceParams {
final double temperature;
final int maxTokens;
final int? seed;
final double? topP;
final int? topK;
final LlamaGrammarConfig? grammarConfig;
}
ModelParams
class ModelParams {
final int nCtx;
final int nBatchSize;
final int nThreads;
final int nGpuLayers;
}
Rule
class Rule {
final String id;
final String name;
final String text;
final String? description;
final String trigger;
final String conditionJson;
final String actionJson;
}
ManagedAIModel
class ManagedAIModel {
final String id;
final String name;
final String text;
final String? vendor;
final String? description;
final String downloadUrl;
final String? imageUrl;
final bool multimodal;
final String? mmProjDownloadUrl;
}