load method

  1. @override
Future<EngineInfo> load(
  1. String modelPath, [
  2. LoadOptions options = const LoadOptions()
])
override

Loads modelPath. Throws StateError while a model is loaded or loading, ModelLoadException when the runtime cannot load it. A model without a chat template loads (EngineInfo.chatTemplate is then null).

Implementation

@override
Future<EngineInfo> load(String modelPath, [LoadOptions options = const LoadOptions()]) {
  // A real engine stays disposed; this one starts a new queue.
  if (_queue.isClosed) _queue = SerialQueue();
  return _queue.run(() async {
    final file = File(modelPath);
    return _info = EngineInfo(
      modelPath: modelPath,
      modelBytes: file.existsSync() ? file.lengthSync() : 0,
      backend: 'scripted',
      gpuLayers: 0,
      contextTokens: options.contextTokens,
      loadMs: 0,
      options: options,
      metadata: {'tokenizer.chat_template': chatTemplate, 'general.architecture': 'qwen35', ..._metadata},
      runtime: runtime,
      addsBos: false,
    );
  });
}