From 20f50d5632d144dd7a8d43ecb80b8b6b8fbc5ae9 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Fri, 14 Apr 2023 10:48:14 +0200 Subject: [PATCH] upgraded settings saving --- app.py | 7 +++++++ configs/default.yaml | 3 ++- static/js/discussions.js | 2 +- static/js/settings.js | 11 ++++++----- static/js/tabs.js | 3 ++- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/app.py b/app.py index c3d324a4..1e563d5f 100644 --- a/app.py +++ b/app.py @@ -466,6 +466,9 @@ class Gpt4AllWebUI: self.config['n_predict'] = int(data["nPredict"]) self.config['seed'] = int(data["seed"]) + self.config['model'] = str(data["model"]) + self.config['voice'] = str(data["voice"]) + self.config['language'] = str(data["language"]) self.config['temp'] = float(data["temp"]) self.config['top_k'] = int(data["topK"]) @@ -474,6 +477,10 @@ class Gpt4AllWebUI: self.config['repeat_last_n'] = int(data["repeatLastN"]) print("Parameters changed to:") + print(f"\tModel:{self.config['model']}") + print(f"\tPersonality:{self.config['personality']}") + print(f"\tLanguage:{self.config['language']}") + print(f"\tVoice:{self.config['voice']}") print(f"\tTemperature:{self.config['temp']}") print(f"\tNPredict:{self.config['n_predict']}") print(f"\tSeed:{self.config['seed']}") diff --git a/configs/default.yaml b/configs/default.yaml index 24d71d0a..d92f9fb4 100644 --- a/configs/default.yaml +++ b/configs/default.yaml @@ -13,4 +13,5 @@ port: 9600 db_path: "database.db" nb_messages_to_remember: 5 personality: "gpt4all_chatbot" -language: "en_XX" \ No newline at end of file +language: "en_XX" +voice: "" \ No newline at end of file diff --git a/static/js/discussions.js b/static/js/discussions.js index 37b5e657..5444ca77 100644 --- a/static/js/discussions.js +++ b/static/js/discussions.js @@ -65,7 +65,7 @@ function populate_discussions_list() //renameButton.style.backgroundImage = "/rename_discussion.svg"; //.textContent = 'Rename'; renameButton.addEventListener('click', () => { const dialog = document.createElement('dialog'); - dialog.classList.add('bg-white', 'rounded', 'p-4'); + dialog.classList.add('bg-gray-500 text-white', 'rounded', 'p-4'); const inputLabel = document.createElement('label'); inputLabel.textContent = 'New name: '; diff --git a/static/js/settings.js b/static/js/settings.js index aa1001a0..b21219b5 100644 --- a/static/js/settings.js +++ b/static/js/settings.js @@ -7,6 +7,7 @@ fetch('/settings') modelInput = document.getElementById('model'); personalityInput = document.getElementById('personalities'); languageInput = document.getElementById('language'); + voiceInput = document.getElementById('voice'); seedInput = document.getElementById('seed'); tempInput = document.getElementById('temp'); nPredictInput = document.getElementById('n-predict'); @@ -56,6 +57,7 @@ fetch('/settings') modelInput.value = data["model"] personalityInput.value = data["personality"] languageInput.value = data["language"] + voiceInput.value = data["voice"] seedInput.value = data["seed"] tempInput.value = data["temp"] nPredictInput.value = data["n_predict"] @@ -86,8 +88,11 @@ fetch('/settings') // Get form values and put them in an object const formValues = { - model: modelInput.value, seed: seedInput.value, + model: modelInput.value, + personality: personalityInput.value, + language: languageInput.value, + voice: voiceInput.value, temp: tempInput.value, nPredict: nPredictInput.value, topK: topKInput.value, @@ -130,7 +135,6 @@ function populate_models(){ .then(data => { if (Array.isArray(data)) { // data is an array - const selectElement = document.getElementById('model'); data.forEach(filename => { const optionElement = document.createElement('option'); optionElement.value = filename; @@ -197,6 +201,3 @@ function populate_models(){ }); } - -populate_models() - diff --git a/static/js/tabs.js b/static/js/tabs.js index 459cd98c..c1fae21f 100644 --- a/static/js/tabs.js +++ b/static/js/tabs.js @@ -35,7 +35,8 @@ fetch('/main') prepre_audio(); add_audio_in_ui(); populateVoicesList(); - + populate_models() + }) .catch(error => { console.error('Error loading main page:', error);