From 2539398d81e1d1ab52f7d710a4710acc4b8c17df Mon Sep 17 00:00:00 2001 From: ebolam Date: Wed, 7 Sep 2022 09:09:40 -0400 Subject: [PATCH] Saving tweaks on colab --- aiserver.py | 18 +++++++++++++++++- static/koboldai.js | 3 +++ templates/index_new.html | 1 + templates/popups.html | 10 +++++----- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/aiserver.py b/aiserver.py index 74bb498c..dbecd5e3 100644 --- a/aiserver.py +++ b/aiserver.py @@ -6771,7 +6771,7 @@ def new_ui_index(): def ui2_connect(): #Send all variables to client koboldai_vars.send_to_ui() - + UI_2_load_tweaks() pass #==================================================================# @@ -7684,6 +7684,22 @@ def UI_2_sp_list_refresh(data): def UI_2_theme_list_refresh(data): koboldai_vars.theme_list = [".".join(f.split(".")[:-1]) for f in os.listdir("./themes") if os.path.isfile(os.path.join("./themes", f))] +#==================================================================# +# Save Tweaks +#==================================================================# +@socketio.on('save_tweaks') +def UI_2_save_tweaks(data): + with open("./settings/tweaks.settings", "w") as f: + f.write(data) + +#==================================================================# +# Load Tweaks +#==================================================================# +def UI_2_load_tweaks(): + if os.path.exists("./settings/tweaks.settings"): + with open("./settings/tweaks.settings", "r") as f: + socketio.emit('load_tweaks', f.read(), room="UI2") + #==================================================================# # Test #==================================================================# diff --git a/static/koboldai.js b/static/koboldai.js index 7541d118..9c2f5bb8 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -3356,6 +3356,9 @@ $(document).ready(function(){ } setCookie("enabledTweaks", JSON.stringify(out)); + if (document.getElementById("on_colab").textContent == "true") { + socket.emit("save_tweaks", JSON.stringify(out)); + } } diff --git a/templates/index_new.html b/templates/index_new.html index 1af01ab6..f8be2eec 100644 --- a/templates/index_new.html +++ b/templates/index_new.html @@ -19,6 +19,7 @@ +
diff --git a/templates/popups.html b/templates/popups.html index b3d4e86d..7b98378a 100644 --- a/templates/popups.html +++ b/templates/popups.html @@ -65,8 +65,8 @@ The story name you have entered already exists. Would you like to overwrite?
@@ -81,8 +81,8 @@ @@ -95,7 +95,7 @@