deleteLoraWeights method

  1. @override
Future<void> deleteLoraWeights()
override

Deletes the loaded lora weights. Nothing happens if the lora weights are not loaded.

Also, closes the inference if it is initialized.

Implementation

@override
Future<void> deleteLoraWeights() async {
  _loraCompleter = null;
  final prefs = await _prefs;

  if (_userSetLoraPath != null) {
    await onDeleteLora();
    _userSetLoraPath = null;
  } else if (_loraFileName case String name) {
    final directory = await getApplicationDocumentsDirectory();
    final file = File('${directory.path}/$name');
    if (await file.exists()) {
      await onDeleteLora();
      await file.delete();
    }
  }
  await prefs.remove(_prefsLoraKey);
  _loraFileName = null;
}