resolveActiveInferenceModel method
Resolves the active inference model. Returns the source plus the
installed LoRA path if any (only meaningful for MediaPipe; LiteRT-LM
throws on loraPath).
Implementation
Future<({WebModelSource model, String? loraPath})>
resolveActiveInferenceModel() async {
final active = _modelManager.activeInferenceModel;
if (active == null) {
throw StateError(
'No active inference model set. Use FlutterGemma.installModel() first.',
);
}
final paths = await _modelManager.getModelFilePaths(active);
if (paths == null || paths.isEmpty) {
throw StateError('Model file paths not found for active model.');
}
final raw = paths[PreferencesKeys.installedModelFileName];
if (raw == null) {
throw StateError('Model path not found in file paths.');
}
final lora = paths[PreferencesKeys.installedLoraFileName];
final source = await _toSource(raw);
return (model: source, loraPath: lora);
}