mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2025-02-06 10:59:23 +00:00
changed configuration version
This commit is contained in:
parent
14bc73ca08
commit
6fc35f0730
32
app.py
32
app.py
@ -840,7 +840,32 @@ class Gpt4AllWebUI(GPT4AllAPI):
|
|||||||
def extensions(self):
|
def extensions(self):
|
||||||
return render_template("extensions.html")
|
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__":
|
if __name__ == "__main__":
|
||||||
parser = argparse.ArgumentParser(description="Start the chatbot Flask app.")
|
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_file_path = f"configs/{args.config}.yaml"
|
||||||
config = load_config(config_file_path)
|
config = load_config(config_file_path)
|
||||||
|
|
||||||
|
|
||||||
if "version" not in config or int(config["version"])<int(default_config["version"]):
|
if "version" not in config or int(config["version"])<int(default_config["version"]):
|
||||||
#Upgrade old configuration files to new format
|
#Upgrade old configuration files to new format
|
||||||
print("Configuration file is very old. Replacing with default configuration")
|
print("Configuration file is very old. Replacing with default configuration")
|
||||||
for key, value in default_config.items():
|
config, added, removed =sync_cfg(default_config, config)
|
||||||
if key not in config:
|
print(f"Added entries : {added}, removed entries:{removed}")
|
||||||
config[key] = value
|
|
||||||
config["version"]=int(default_config["version"])
|
|
||||||
save_config(config, config_file_path)
|
save_config(config, config_file_path)
|
||||||
|
|
||||||
# Override values in config with command-line arguments
|
# Override values in config with command-line arguments
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
version: 4
|
version: 5
|
||||||
user_name: user
|
user_name: user
|
||||||
config: default
|
config: default
|
||||||
ctx_size: 2048
|
ctx_size: 2048
|
||||||
|
Loading…
x
Reference in New Issue
Block a user