Skip to content

Commit

Permalink
error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
danemadsen committed Jun 27, 2024
1 parent 4abf284 commit 4dcccb2
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions lib/classes/providers/large_language_models/llama_cpp_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class LlamaCppModel extends LargeLanguageModel {

String _template = '';

bool _downloading = false;

String get template => _template;

set template(String value) {
Expand All @@ -38,6 +40,10 @@ class LlamaCppModel extends LargeLanguageModel {
if (!File(uri).existsSync()) {
missing.add('- The file provided does not exist.\n');
}

if (_downloading) {
missing.add('- The model is currently downloading.\n');
}

return missing;
}
Expand Down Expand Up @@ -206,9 +212,19 @@ class LlamaCppModel extends LargeLanguageModel {
}

void setModelWithFuture(Future<(String, String)> future) async {
final (filePath, tag) = await future;
uri = filePath;
name = tag;
_downloading = true;
notifyListeners();

try {
final (filePath, tag) = await future;
uri = filePath;
name = tag;
}
catch (e) {
Logger.log("Error setting model: $e");
}

_downloading = false;
notifyListeners();
}

Expand Down

0 comments on commit 4dcccb2

Please sign in to comment.