setModelPath method

  1. @Deprecated('Use FlutterGemma.installInferenceModel().fromNetwork() instead')
  2. @override
Future<void> setModelPath(
  1. String path, {
  2. String? loraPath,
})
override

Sets model path for inference (web: URLs only)

⚠️ DEPRECATED: Use FlutterGemma.installInferenceModel().fromNetwork() instead

This method provides backward compatibility but delegates to Modern API.

Migration:

// OLD:
await manager.setModelPath('https://example.com/model.task');

// NEW:
await FlutterGemma.installInferenceModel()
  .fromNetwork('https://example.com/model.task')
  .install();

Implementation

@Deprecated('Use FlutterGemma.installInferenceModel().fromNetwork() instead')
@override
Future<void> setModelPath(String path, {String? loraPath}) async {
  await _ensureInitialized();

  // Create ModelSource based on path type
  final modelSource = path.startsWith('http')
      ? ModelSource.network(path)
      : ModelSource.file(path);

  final loraSource = loraPath != null
      ? (loraPath.startsWith('http')
          ? ModelSource.network(loraPath)
          : ModelSource.file(loraPath))
      : null;

  // Convert legacy parameters to Modern API ModelSpec
  final spec = InferenceModelSpec(
    name: FileNameUtils.getBaseName(path.split('/').last),
    modelSource: modelSource,
    loraSource: loraSource,
  );

  // Delegate to Modern API
  await ensureModelReadyFromSpec(spec);
}