From a16c129950bc0c47fb1522ae5b459ea7063c1d8f Mon Sep 17 00:00:00 2001 From: GuiAworld Date: Tue, 16 Aug 2022 22:45:40 -0300 Subject: [PATCH] Merge branch 'UI2' of https://github.com/ebolam/KoboldAI into UI2 --- aiserver.py | 12 ++++++-- koboldai_settings.py | 9 +++--- static/koboldai.css | 51 ++++++++-------------------------- static/koboldai.js | 41 ++++++++++++++++----------- templates/settings flyout.html | 28 ++++--------------- templates/settings item.html | 8 +----- 6 files changed, 57 insertions(+), 92 deletions(-) diff --git a/aiserver.py b/aiserver.py index 84b92673..be0d5c0f 100644 --- a/aiserver.py +++ b/aiserver.py @@ -6285,7 +6285,12 @@ def UI_2_var_change(data): #Now let's save except for story changes if classname != "story_settings": - with open("settings/{}.v2_settings".format(classname), "w") as settings_file: + if classname == "model_settings": + filename = "settings/{}.v2_settings".format(koboldai_vars.model.replace("/", "_")) + else: + filename = "settings/{}.v2_settings".format(classname) + + with open(filename, "w") as settings_file: settings_file.write(getattr(koboldai_vars, "_{}".format(classname)).to_json()) return {'id': data['ID'], 'status': "Saved"} @@ -6295,7 +6300,7 @@ def UI_2_var_change(data): #==================================================================# @socketio.on('save_story') def UI_2_save_story(data): - + print("Saving Story") if data is None: #We need to check to see if there is a file already and if it's not the same story so we can ask the client if this is OK save_name = koboldai_vars.story_name if koboldai_vars.story_name != "" else "untitled" @@ -6599,11 +6604,14 @@ def UI_2_phrase_bias_update(biases): # Event triggered to rely a message #==================================================================# def socket_io_relay(queue, socketio): + print("started relay") while True: if not queue.empty(): + print("got relay message") data = queue.get() #socketio.emit(data[0], data[1], **data[2]) socketio.emit(data[0], data[1], broadcast=True, room="UI_2") + print("sent") time.sleep(0) diff --git a/koboldai_settings.py b/koboldai_settings.py index e418b2c9..f6a88442 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -298,7 +298,7 @@ class settings(object): pickle.dump(data, output) output.seek(0) return "base64:{}".format(base64.encodebytes(output.read()).decode()) - return json.dumps(json_data, default=to_base64) + return json.dumps(json_data, default=to_base64, indent="\t") def from_json(self, data): if isinstance(data, str): @@ -337,7 +337,8 @@ class settings(object): class model_settings(settings): local_only_variables = ['badwordsids', 'apikey', 'tqdm', 'socketio', 'default_preset'] - no_save_variables = ['tqdm', 'socketio'] + no_save_variables = ['tqdm', 'tqdm_progress', 'tqdm_rem_time', 'socketio', 'modelconfig', 'custmodpth', 'generated_tkns', + 'loaded_layers', 'total_layers', 'total_download_chunks', 'downloaded_chunks'] settings_name = "model" def __init__(self, socketio): self.socketio = socketio @@ -600,8 +601,8 @@ class story_settings(settings): self.actionmode = 0 class user_settings(settings): - local_only_variables = ['socketio'] - no_save_variables = ['socketio'] + local_only_variables = ['socketio', 'importjs'] + no_save_variables = ['socketio', 'importnum', 'importjs', 'loadselect', 'spselect', 'svowname', 'saveow', 'laststory', 'sid'] settings_name = "user" def __init__(self, socketio): self.socketio = socketio diff --git a/static/koboldai.css b/static/koboldai.css index f26ad12e..1369e75c 100644 --- a/static/koboldai.css +++ b/static/koboldai.css @@ -331,7 +331,7 @@ input[type="range"]::-ms-fill-upper { grid-template-columns: 135px 42px; row-gap: 0.2em; background-color: var(--setting_background); - color: var(--text); + color: var(--setting_text); border-radius: var(--radius_settings_background); padding: 3px; margin: 2px; @@ -376,6 +376,7 @@ input[type="range"]::-ms-fill-upper { } .setting_label { + display: flex; grid-area: label; overflow: hidden; padding: 5px; @@ -407,46 +408,12 @@ input[type="range"]::-ms-fill-upper { } /*-----------------------------------------------*/ .helpicon { - display: inline-block; - font-family: sans-serif; - font-weight: bold; - text-align: center; - width: 2ex; - height: 2ex; - font-size: 1.8ex; - line-height: 1.8ex; - border-radius: 1.2ex; - margin-right: 4px; - padding: 1px; - color: var(--help_icon_text); - background: var(--help_icon); - border: 1px solid var(--help_icon_text); - text-decoration: none; + color: var(--setting_text); cursor: help; -} - -.helpicon .helptext { - display: none; - font-family: sans-serif; - position: absolute; - z-index: 100; - text-shadow: none !important; -} - -.helpicon:hover .helptext { - display: inline-block; - position: fixed; - width: 250px; - background-color: var(--tooltip_background); - color: var(--tooltip_text); - font-size: 11pt; - z-index: 100; - font-weight: normal; - line-height: normal; - border-radius: 6px; - padding: 5px; - margin-left:10px; - border: 1px solid var(--tooltip_text); + font-size: 14px !important; + flex: auto; + width: 15px; + align-self: flex-end; } /*----------------LEFT FLYOUT MENU------------------*/ @@ -1643,3 +1610,7 @@ body.NotConnected { /* Support for IE. */ font-feature-settings: 'liga'; } + +h2 .material-icons-outlined { + font-size: 32px; +} \ No newline at end of file diff --git a/static/koboldai.js b/static/koboldai.js index bf8433cd..b83a06d9 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -1247,10 +1247,10 @@ function world_info_folder(data) { title.addEventListener('drop', drop); collapse_icon = document.createElement("span"); collapse_icon.id = "world_info_folder_collapse_"+folder_name; - collapse_icon.classList.add("oi"); collapse_icon.classList.add("wi_folder_collapser"); - collapse_icon.setAttribute("data-glyph", "chevron-bottom"); + collapse_icon.classList.add("material-icons-outlined"); collapse_icon.setAttribute("folder", folder_name); + collapse_icon.textContent = "expand_more"; collapse_icon.onclick = function () { hide_wi_folder(this.getAttribute("folder")); document.getElementById('world_info_folder_expand_'+this.getAttribute("folder")).classList.remove('hidden'); @@ -1259,10 +1259,10 @@ function world_info_folder(data) { title.append(collapse_icon); expand_icon = document.createElement("span"); expand_icon.id = "world_info_folder_expand_"+folder_name; - expand_icon.classList.add("oi"); expand_icon.classList.add("wi_folder_collapser"); - expand_icon.setAttribute("data-glyph", "chevron-right"); + expand_icon.classList.add("material-icons-outlined"); expand_icon.setAttribute("folder", folder_name); + expand_icon.textContent = "chevron_right"; expand_icon.onclick = function () { unhide_wi_folder(this.getAttribute("folder")); document.getElementById('world_info_folder_collapse_'+this.getAttribute("folder")).classList.remove('hidden'); @@ -1271,8 +1271,9 @@ function world_info_folder(data) { expand_icon.classList.add("hidden"); title.append(expand_icon); icon = document.createElement("span"); - icon.classList.add("oi"); - icon.setAttribute("data-glyph", "folder"); + icon.classList.add("material-icons-outlined"); + icon.setAttribute("folder", folder_name); + icon.textContent = "folder"; title.append(icon); title_text = document.createElement("span"); title_text.setAttribute("contenteditable", true); @@ -1287,16 +1288,20 @@ function world_info_folder(data) { title.append(title_text); folder.append(title); //create add button + new_icon = document.createElement("span"); + new_icon.classList.add("wi_add_button"); add_icon = document.createElement("span"); - add_icon.classList.add("oi"); - add_icon.classList.add("wi_add_button"); - add_icon.setAttribute("data-glyph", "plus"); - add_icon.textContent = "Add World Info Entry"; - add_icon.setAttribute("folder", folder_name); - add_icon.onclick = function() { + add_icon.classList.add("material-icons-outlined"); + add_icon.textContent = "post_add"; + new_icon.append(add_icon); + add_text = document.createElement("span"); + add_text.textContent = "Add World Info Entry"; + add_text.setAttribute("folder", folder_name); + add_text.onclick = function() { create_new_wi_entry(this.getAttribute("folder")); } - folder.append(add_icon); + new_icon.append(add_text); + folder.append(new_icon); //We want to insert this folder before the next folder if (i+1 < folders.length) { @@ -1350,12 +1355,16 @@ function world_info_folder(data) { add_folder.id = "new_world_info_button"; temp = document.createElement("h2"); add_icon = document.createElement("span"); - add_icon.classList.add("oi"); - add_icon.setAttribute("data-glyph", "plus"); - add_icon.textContent = "Add World Info Folder"; + icon = document.createElement("span"); + icon.classList.add("material-icons-outlined"); + icon.textContent = "create_new_folder"; + add_icon.append(icon); + text_span = document.createElement("span"); + text_span.textContent = "Add World Info Folder"; add_icon.onclick = function() { socket.emit("create_world_info_folder", {}); } + add_icon.append(text_span); temp.append(add_icon); add_folder.append(temp); document.getElementById("WI_Area").append(add_folder); diff --git a/templates/settings flyout.html b/templates/settings flyout.html index a835cd7a..87aab06c 100644 --- a/templates/settings flyout.html +++ b/templates/settings flyout.html @@ -63,7 +63,7 @@
description folder_open - save + save cloud_download file_download
@@ -99,18 +99,12 @@
- Sample Order: - - ? - - Sample Order Tooltip - - + Sample Order: help_icon
-
    +
    • Top-k Sampling
    • Top-a Sampling
    • Top-p Sampling
    • @@ -203,13 +197,7 @@ {% endwith %}
      - Maximize Game Text Space: - - ? - - When enabled and both menus are un-pinned, the game screen will take up all avaialable space. When disabled, the game screen will be centered. - - + Maximize Game Text Space:  help_icon @@ -220,13 +208,7 @@
      - Keep options on Right: - - ? - - When enabled and only the story menu is pinned, the generated story options will be shown on the right instead of the left of the game text. - - + Keep options on Right: help_icon diff --git a/templates/settings item.html b/templates/settings item.html index e34e0945..ba6934e1 100644 --- a/templates/settings item.html +++ b/templates/settings item.html @@ -3,13 +3,7 @@
      - {{ item['label'] }}: - - ? - - {{ item['tooltip'] }} - - + {{ item['label'] }}: help_icon {% if (item['unit'] != 'bool') and (item['unit'] != 'text') %}