@@ -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' ;
1314import 'package:runanywhere_llamacpp/runanywhere_llamacpp.dart' ;
14- import 'package:runanywhere_onnx/runanywhere_onnx.dart' ;
1515
1616/// RunAnywhereAIApp (mirroring iOS RunAnywhereAIApp.swift)
1717///
@@ -140,11 +140,8 @@ class _RunAnywhereAIAppState extends State<RunAnywhereAIApp> {
140140 Future <void > _registerModulesAndModels () async {
141141 debugPrint ('📦 Registering modules with their models...' );
142142
143- // LlamaCPP module with LLM models
144- // Using explicit IDs ensures models are recognized after download across app restarts
143+ // --- LLAMACPP MODULE ---
145144 await LlamaCpp .register ();
146-
147- // Yield after heavy backend registration
148145 await Future <void >.delayed (Duration .zero);
149146
150147 LlamaCpp .addModel (
@@ -190,8 +187,6 @@ class _RunAnywhereAIAppState extends State<RunAnywhereAIApp> {
190187 memoryRequirement: 400000000 ,
191188 );
192189
193- // Tool Calling Optimized Models
194- // LFM2-1.2B-Tool - Designed for concise and precise tool calling (Liquid AI)
195190 LlamaCpp .addModel (
196191 id: 'lfm2-1.2b-tool-q4_k_m' ,
197192 name: 'LiquidAI LFM2 1.2B Tool Q4_K_M' ,
@@ -206,16 +201,10 @@ class _RunAnywhereAIAppState extends State<RunAnywhereAIApp> {
206201 'https://huggingface.co/LiquidAI/LFM2-1.2B-Tool-GGUF/resolve/main/LFM2-1.2B-Tool-Q8_0.gguf' ,
207202 memoryRequirement: 1400000000 ,
208203 );
209- debugPrint ('✅ LlamaCPP module registered with LLM models (including tool-calling optimized models)' );
210-
211- // Yield between module registrations
204+ debugPrint ('✅ LlamaCPP module registered' );
212205 await Future <void >.delayed (Duration .zero);
213206
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)
207+ // --- VLM MODULE ---
219208 RunAnywhere .registerModel (
220209 id: 'smolvlm-500m-instruct-q8_0' ,
221210 name: 'SmolVLM 500M Instruct' ,
@@ -229,57 +218,81 @@ class _RunAnywhereAIAppState extends State<RunAnywhereAIApp> {
229218 memoryRequirement: 600000000 ,
230219 );
231220 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
245221 await Future <void >.delayed (Duration .zero);
246222
223+ // --- ONNX MODULE (STT/TTS via Core SDK) ---
247224 // STT Models (Sherpa-ONNX Whisper)
248- Onnx . addModel (
225+ RunAnywhere . registerModel (
249226 id: 'sherpa-onnx-whisper-tiny.en' ,
250227 name: 'Sherpa Whisper Tiny (ONNX)' ,
251- url:
252- 'https://github.com/RunanywhereAI/sherpa- onnx/releases/download/runanywhere-models-v1/sherpa-onnx-whisper-tiny.en.tar.gz' ,
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,
253230 modality: ModelCategory .speechRecognition,
254231 memoryRequirement: 75000000 ,
255232 );
256- Onnx .addModel (
233+
234+ RunAnywhere .registerModel (
257235 id: 'sherpa-onnx-whisper-small.en' ,
258236 name: 'Sherpa Whisper Small (ONNX)' ,
259- url:
260- 'https://github.com/RunanywhereAI/sherpa- onnx/releases/download/runanywhere-models-v1/sherpa-onnx-whisper-small.en.tar.gz' ,
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,
261239 modality: ModelCategory .speechRecognition,
262240 memoryRequirement: 250000000 ,
263241 );
264242
265243 // TTS Models (Piper VITS)
266- Onnx . addModel (
244+ RunAnywhere . registerModel (
267245 id: 'vits-piper-en_US-lessac-medium' ,
268246 name: 'Piper TTS (US English - Medium)' ,
269- url:
270- 'https://github.com/RunanywhereAI/sherpa- onnx/releases/download/runanywhere-models-v1/vits-piper-en_US-lessac-medium.tar.gz' ,
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,
271249 modality: ModelCategory .speechSynthesis,
272250 memoryRequirement: 65000000 ,
273251 );
274- Onnx .addModel (
252+
253+ RunAnywhere .registerModel (
275254 id: 'vits-piper-en_GB-alba-medium' ,
276255 name: 'Piper TTS (British English)' ,
277- url:
278- 'https://github.com/RunanywhereAI/sherpa- onnx/releases/download/runanywhere-models-v1/vits-piper-en_GB-alba-medium.tar.gz' ,
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,
279258 modality: ModelCategory .speechSynthesis,
280259 memoryRequirement: 65000000 ,
281260 );
282- debugPrint ('✅ ONNX module registered with STT/TTS models' );
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+ }
283296
284297 debugPrint ('🎉 All modules and models registered' );
285298 }
0 commit comments