deleteModel method

Future<void> deleteModel(
  1. String modelId
)

Uninstall the GGUF file. No-op if not installed. If modelId is the currently-loaded engine's model, the engine is disposed too.

Implementation

Future<void> deleteModel(String modelId) async {
  final spec = _modelSpecs[modelId];
  if (spec == null) return;
  final file = File(await _modelPath(spec));
  if (await file.exists()) {
    await file.delete();
    dev.log('Uninstalled $modelId', name: 'LocalLlm');
  }
  if (_engineModelId == modelId) {
    await dispose();
  }
  if (_activeModelId == modelId) {
    _activeModelId = null;
  }
}