From a757331b202bf0798b0072aeb606c5d6c229d90b Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Fri, 14 Apr 2023 11:58:07 +0200 Subject: [PATCH] upgraded parameters saving --- app.py | 11 +++++++---- configs/default.yaml | 29 +++++++++++++++-------------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/app.py b/app.py index 1e563d5f..f4e222a0 100644 --- a/app.py +++ b/app.py @@ -32,12 +32,13 @@ from pathlib import Path import gc app = Flask("GPT4All-WebUI", static_url_path="/static", static_folder="static") import time -from config import load_config +from config import load_config, save_config class Gpt4AllWebUI: - def __init__(self, _app, config:dict, personality:dict) -> None: + def __init__(self, _app, config:dict, personality:dict, config_file_path) -> None: self.config = config + self.config_file_path = config_file_path self.personality = personality self.current_discussion = None self.current_message_id = 0 @@ -139,7 +140,7 @@ class Gpt4AllWebUI: def list_personalities(self): personalities_dir = Path('./personalities') # replace with the actual path to the models folder - personalities = [f.name for f in personalities_dir.glob('*.yaml')] + personalities = [f.stem for f in personalities_dir.glob('*.yaml')] return jsonify(personalities) def list_languages(self): @@ -476,6 +477,8 @@ class Gpt4AllWebUI: self.config['repeat_penalty'] = float(data["repeatPenalty"]) self.config['repeat_last_n'] = int(data["repeatLastN"]) + save_config(self.config, self.config_file_path) + print("Parameters changed to:") print(f"\tModel:{self.config['model']}") print(f"\tPersonality:{self.config['personality']}") @@ -587,7 +590,7 @@ if __name__ == "__main__": executor = ThreadPoolExecutor(max_workers=2) app.config['executor'] = executor - bot = Gpt4AllWebUI(app, config, personality) + bot = Gpt4AllWebUI(app, config, personality, config_file_path) if config["debug"]: app.run(debug=True, host=config["host"], port=config["port"]) diff --git a/configs/default.yaml b/configs/default.yaml index d92f9fb4..5cc0c20b 100644 --- a/configs/default.yaml +++ b/configs/default.yaml @@ -1,17 +1,18 @@ -seed: 0 -model: "gpt4all-lora-quantized-ggml.bin" -temp: 0.1 +config: default +ctx_size: 512 +db_path: database.db +debug: false +host: localhost +language: en-US +model: gpt4all-lora-quantized-ggml.bin n_predict: 256 +nb_messages_to_remember: 5 +personality: gpt4all_chatbot +port: 9600 +repeat_last_n: 40 +repeat_penalty: 1.3 +seed: 0 +temp: 0.1 top_k: 40 top_p: 0.95 -repeat_penalty: 1.3 -repeat_last_n: 64 -ctx_size: 512 -debug: false -host: "localhost" -port: 9600 -db_path: "database.db" -nb_messages_to_remember: 5 -personality: "gpt4all_chatbot" -language: "en_XX" -voice: "" \ No newline at end of file +voice: ""