Skip to content

Commit

Permalink
fix name getting wiped
Browse files Browse the repository at this point in the history
  • Loading branch information
danemadsen committed Aug 4, 2024
1 parent cbb06af commit b4cb278
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 33 deletions.
1 change: 0 additions & 1 deletion lib/classes/providers/large_language_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class LargeLanguageModel extends ChangeNotifier {
}

set uri(String value) {
_name = '';
_uri = value;
notifyListeners();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class ClaudeModel extends LargeLanguageModel {
@override
Future<void> resetUri() async {
uri = defaultUrl;
name = '';
notifyListeners();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class GoogleGeminiModel extends LargeLanguageModel {
@override
Future<void> resetUri() async {
uri = ''; // No URI to reset
name = '';
notifyListeners();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ class LlamaCppModel extends LargeLanguageModel {
@override
Future<void> resetUri() async {
uri = '';
name = '';
notifyListeners();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class MistralAiModel extends LargeLanguageModel {
@override
Future<void> resetUri() async {
uri = defaultUrl;
name = '';
notifyListeners();
}

Expand Down
2 changes: 2 additions & 0 deletions lib/classes/providers/large_language_models/ollama_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ class OllamaModel extends LargeLanguageModel {

@override
Future<void> resetUri() async {
name = "";

// Check Localhost
if ((await _checkIpForOllama('127.0.0.1')).isNotEmpty) {
uri = 'http://127.0.0.1:11434';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ class OpenAiModel extends LargeLanguageModel {
@override
Future<void> resetUri() async {
uri = defaultUrl;
name = "";
notifyListeners();
}

Expand Down
62 changes: 30 additions & 32 deletions lib/ui/shared/dialogs/load_model_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,37 +102,6 @@ class _LoadModelDialogState extends State<LoadModelDialog> {
);
}

List<Widget> get importedOptions {
return [
FilledButton(
onPressed: () {
LlamaCppModel.of(context).name = selected!;
LlamaCppModel.of(context).uri = importedModels![selected!]!;
Navigator.of(context).pop();
},
child: Text(
"Select",
style: Theme.of(context).textTheme.labelLarge,
),
),
const SizedBox(width: 8),
FilledButton(
onPressed: () {
File(importedModels![selected!]!).delete();
setState(() {
importedModels!.remove(selected);
selected = null;
});
saveImportedModels();
},
child: Text(
"Delete",
style: Theme.of(context).textTheme.labelLarge,
),
),
];
}

Widget buildDropdown() {
return Column(
mainAxisSize: MainAxisSize.min,
Expand All @@ -159,7 +128,36 @@ class _LoadModelDialogState extends State<LoadModelDialog> {
if (selected != null)
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: importedOptions,
children: [
FilledButton(
onPressed: () {
print("Selected: $selected");
LlamaCppModel.of(context).name = selected!;
print("Selected: ${importedModels![selected!]}");
LlamaCppModel.of(context).uri = importedModels![selected!]!;
Navigator.of(context).pop();
},
child: Text(
"Select",
style: Theme.of(context).textTheme.labelLarge,
),
),
const SizedBox(width: 8),
FilledButton(
onPressed: () {
File(importedModels![selected!]!).delete();
setState(() {
importedModels!.remove(selected);
selected = null;
});
saveImportedModels();
},
child: Text(
"Delete",
style: Theme.of(context).textTheme.labelLarge,
),
),
],
),
],
);
Expand Down

0 comments on commit b4cb278

Please sign in to comment.