@@ -10,8 +10,8 @@ import 'package:runanywhere_ai/core/design_system/app_spacing.dart';
1010import 'package:runanywhere_ai/core/services/model_manager.dart' ;
1111import 'package:runanywhere_ai/core/utilities/constants.dart' ;
1212import 'package:runanywhere_ai/core/utilities/keychain_helper.dart' ;
13- import 'package:runanywhere/public/extensions/rag_module.dart' ;
1413import 'package:runanywhere_llamacpp/runanywhere_llamacpp.dart' ;
14+ import 'package:runanywhere_onnx/runanywhere_onnx.dart' ;
1515
1616/// RunAnywhereAIApp (mirroring iOS RunAnywhereAIApp.swift)
1717///
@@ -140,8 +140,11 @@ class _RunAnywhereAIAppState extends State<RunAnywhereAIApp> {
140140 Future <void > _registerModulesAndModels () async {
141141 debugPrint ('📦 Registering modules with their models...' );
142142
143- // --- LLAMACPP MODULE ---
143+ // LlamaCPP module with LLM models
144+ // Using explicit IDs ensures models are recognized after download across app restarts
144145 await LlamaCpp .register ();
146+
147+ // Yield after heavy backend registration
145148 await Future <void >.delayed (Duration .zero);
146149
147150 LlamaCpp .addModel (
@@ -187,6 +190,8 @@ class _RunAnywhereAIAppState extends State<RunAnywhereAIApp> {
187190 memoryRequirement: 400000000 ,
188191 );
189192
193+ // Tool Calling Optimized Models
194+ // LFM2-1.2B-Tool - Designed for concise and precise tool calling (Liquid AI)
190195 LlamaCpp .addModel (
191196 id: 'lfm2-1.2b-tool-q4_k_m' ,
192197 name: 'LiquidAI LFM2 1.2B Tool Q4_K_M' ,
@@ -201,10 +206,16 @@ class _RunAnywhereAIAppState extends State<RunAnywhereAIApp> {
201206 'https://huggingface.co/LiquidAI/LFM2-1.2B-Tool-GGUF/resolve/main/LFM2-1.2B-Tool-Q8_0.gguf' ,
202207 memoryRequirement: 1400000000 ,
203208 );
204- debugPrint ('✅ LlamaCPP module registered' );
209+ debugPrint ('✅ LlamaCPP module registered with LLM models (including tool-calling optimized models)' );
210+
211+ // Yield between module registrations
205212 await Future <void >.delayed (Duration .zero);
206213
207- // --- VLM MODULE ---
214+ // Register VLM (Vision Language) models
215+ // VLM models require 2 files: main model + mmproj (vision projector)
216+ // Bundled as tar.gz archives for easy download/extraction
217+
218+ // SmolVLM 500M - Ultra-lightweight VLM for mobile (~500MB total)
208219 RunAnywhere .registerModel (
209220 id: 'smolvlm-500m-instruct-q8_0' ,
210221 name: 'SmolVLM 500M Instruct' ,
@@ -218,81 +229,57 @@ class _RunAnywhereAIAppState extends State<RunAnywhereAIApp> {
218229 memoryRequirement: 600000000 ,
219230 );
220231 debugPrint ('✅ VLM models registered' );
232+
233+ // Yield between module registrations
234+ await Future <void >.delayed (Duration .zero);
235+
236+ // Diffusion (image generation) is not registered here. CoreML diffusion is supported
237+ // only in the Swift SDK and Swift example app; Flutter/RN do not register diffusion.
238+
239+ // ONNX module with STT and TTS models
240+ // Using tar.gz format hosted on RunanywhereAI/sherpa-onnx for fast native extraction
241+ // Using explicit IDs ensures models are recognized after download across app restarts
242+ await Onnx .register ();
243+
244+ // Yield after heavy backend registration
221245 await Future <void >.delayed (Duration .zero);
222246
223- // --- ONNX MODULE (STT/TTS via Core SDK) ---
224247 // STT Models (Sherpa-ONNX Whisper)
225- RunAnywhere . registerModel (
248+ Onnx . addModel (
226249 id: 'sherpa-onnx-whisper-tiny.en' ,
227250 name: 'Sherpa Whisper Tiny (ONNX)' ,
228- url: Uri . parse ( 'https://github.com/RunanywhereAI/sherpa-onnx/releases/download/runanywhere-models-v1/sherpa-onnx-whisper-tiny.en.tar.gz' ),
229- framework : InferenceFramework . onnx,
251+ url:
252+ 'https://github.com/RunanywhereAI/sherpa- onnx/releases/download/runanywhere-models-v1/sherpa-onnx-whisper-tiny.en.tar.gz' ,
230253 modality: ModelCategory .speechRecognition,
231254 memoryRequirement: 75000000 ,
232255 );
233-
234- RunAnywhere .registerModel (
256+ Onnx .addModel (
235257 id: 'sherpa-onnx-whisper-small.en' ,
236258 name: 'Sherpa Whisper Small (ONNX)' ,
237- url: Uri . parse ( 'https://github.com/RunanywhereAI/sherpa-onnx/releases/download/runanywhere-models-v1/sherpa-onnx-whisper-small.en.tar.gz' ),
238- framework : InferenceFramework . onnx,
259+ url:
260+ 'https://github.com/RunanywhereAI/sherpa- onnx/releases/download/runanywhere-models-v1/sherpa-onnx-whisper-small.en.tar.gz' ,
239261 modality: ModelCategory .speechRecognition,
240262 memoryRequirement: 250000000 ,
241263 );
242264
243265 // TTS Models (Piper VITS)
244- RunAnywhere . registerModel (
266+ Onnx . addModel (
245267 id: 'vits-piper-en_US-lessac-medium' ,
246268 name: 'Piper TTS (US English - Medium)' ,
247- url: Uri . parse ( 'https://github.com/RunanywhereAI/sherpa-onnx/releases/download/runanywhere-models-v1/vits-piper-en_US-lessac-medium.tar.gz' ),
248- framework : InferenceFramework . onnx,
269+ url:
270+ 'https://github.com/RunanywhereAI/sherpa- onnx/releases/download/runanywhere-models-v1/vits-piper-en_US-lessac-medium.tar.gz' ,
249271 modality: ModelCategory .speechSynthesis,
250272 memoryRequirement: 65000000 ,
251273 );
252-
253- RunAnywhere .registerModel (
274+ Onnx .addModel (
254275 id: 'vits-piper-en_GB-alba-medium' ,
255276 name: 'Piper TTS (British English)' ,
256- url: Uri . parse ( 'https://github.com/RunanywhereAI/sherpa-onnx/releases/download/runanywhere-models-v1/vits-piper-en_GB-alba-medium.tar.gz' ),
257- framework : InferenceFramework . onnx,
277+ url:
278+ 'https://github.com/RunanywhereAI/sherpa- onnx/releases/download/runanywhere-models-v1/vits-piper-en_GB-alba-medium.tar.gz' ,
258279 modality: ModelCategory .speechSynthesis,
259280 memoryRequirement: 65000000 ,
260281 );
261- debugPrint ('✅ STT/TTS models registered via Core SDK' );
262- await Future <void >.delayed (Duration .zero);
263-
264- // --- RAG EMBEDDINGS ---
265- RunAnywhere .registerMultiFileModel (
266- id: 'all-minilm-l6-v2' ,
267- name: 'All MiniLM L6 v2 (Embedding)' ,
268- files: [
269- ModelFileDescriptor (
270- relativePath: 'model.onnx' ,
271- destinationPath: 'model.onnx' ,
272- url: Uri .parse (
273- 'https://huggingface.co/Xenova/all-MiniLM-L6-v2/resolve/main/onnx/model.onnx' ),
274- ),
275- ModelFileDescriptor (
276- relativePath: 'vocab.txt' ,
277- destinationPath: 'vocab.txt' ,
278- url: Uri .parse (
279- 'https://huggingface.co/Xenova/all-MiniLM-L6-v2/resolve/main/vocab.txt' ),
280- ),
281- ],
282- framework: InferenceFramework .onnx,
283- modality: ModelCategory .embedding,
284- memoryRequirement: 25500000 ,
285- );
286- debugPrint ('✅ ONNX Embedding models registered' );
287- await Future <void >.delayed (Duration .zero);
288-
289- // --- RAG BACKEND ---
290- try {
291- await RAGModule .register ();
292- debugPrint ('✅ RAG backend registered' );
293- } catch (e) {
294- debugPrint ('⚠️ RAG backend not available (RAG features disabled): $e ' );
295- }
282+ debugPrint ('✅ ONNX module registered with STT/TTS models' );
296283
297284 debugPrint ('🎉 All modules and models registered' );
298285 }
0 commit comments