From 6fc35f0730fec629116a6ca50094c35677a47851 Mon Sep 17 00:00:00 2001 From: saloui Date: Fri, 26 May 2023 12:10:16 +0200 Subject: [PATCH] changed configuration version --- app.py | 32 ++++++++++++++++++++++++++++---- configs/default.yaml | 2 +- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index 2df0c960..f905a536 100644 --- a/app.py +++ b/app.py @@ -840,7 +840,32 @@ class Gpt4AllWebUI(GPT4AllAPI): def extensions(self): return render_template("extensions.html") +def sync_cfg(default_config, config): + """Syncs a configuration with the default configuration + + Args: + default_config (_type_): _description_ + config (_type_): _description_ + + Returns: + _type_: _description_ + """ + added_entries = [] + removed_entries = [] + + # Ensure all fields from default_config exist in config + for key, value in default_config.items(): + if key not in config: + config[key] = value + added_entries.append(key) + + # Remove fields from config that don't exist in default_config + for key in list(config.keys()): + if key not in default_config: + del config[key] + removed_entries.append(key) + return config, added_entries, removed_entries if __name__ == "__main__": parser = argparse.ArgumentParser(description="Start the chatbot Flask app.") @@ -924,13 +949,12 @@ if __name__ == "__main__": config_file_path = f"configs/{args.config}.yaml" config = load_config(config_file_path) + if "version" not in config or int(config["version"])