loadModel method

Future<void> loadModel(
  1. ModelInfo model
)

Polymorphic load entry — dispatches on ModelInfo.category so callers do not hand-roll a per-capability switch.

Mirrors Swift RunAnywhere.loadModel(_:) which routes RAModelInfo to the right component lifecycle. Categories without a dedicated capability fall through to the LLM lifecycle as the generic default, matching Swift's behaviour.

Implementation

Future<void> loadModel(ModelInfo model) async {
  if (!DartBridge.isInitialized) {
    throw SDKException.notInitialized();
  }
  await DartBridge.ensureServicesReady();
  switch (model.category) {
    case ModelCategory.MODEL_CATEGORY_LANGUAGE:
      return RunAnywhereLLM.shared.load(model.id);
    case ModelCategory.MODEL_CATEGORY_MULTIMODAL:
    case ModelCategory.MODEL_CATEGORY_VISION:
      return RunAnywhereVLM.shared.load(model.id);
    case ModelCategory.MODEL_CATEGORY_SPEECH_RECOGNITION:
      return RunAnywhereSTT.shared.load(model.id);
    case ModelCategory.MODEL_CATEGORY_SPEECH_SYNTHESIS:
      return RunAnywhereTTS.shared.loadVoice(model.id);
    case ModelCategory.MODEL_CATEGORY_VOICE_ACTIVITY_DETECTION:
      return RunAnywhereVAD.shared.loadModel(model.id);
    default:
      return RunAnywhereLLM.shared.load(model.id);
  }
}