From 8ecd51486e806b4d4aecd1a5c4de47d2710f3b45 Mon Sep 17 00:00:00 2001 From: ebolam Date: Wed, 10 Aug 2022 13:09:55 -0400 Subject: [PATCH 1/4] Added option to keep generation options on the right --- aiserver.py | 7 +++++++ koboldai_settings.py | 2 +- static/koboldai.css | 9 ++++++--- static/koboldai.js | 37 ++++++++++++++++++++++++++++++++++ templates/settings flyout.html | 18 +++++++++++++++++ 5 files changed, 69 insertions(+), 4 deletions(-) diff --git a/aiserver.py b/aiserver.py index 8f54677a..77032708 100644 --- a/aiserver.py +++ b/aiserver.py @@ -6495,6 +6495,13 @@ def UI_2_load_story(file): print("loading {}".format(file)) loadRequest(file) +#==================================================================# +# Event triggered on load story +#==================================================================# +@socketio.on('new_story') +def UI_2_new_story(data): + koboldai_vars.create_story("") + #==================================================================# # Event triggered when user moves world info diff --git a/koboldai_settings.py b/koboldai_settings.py index d40805c1..eba3b26f 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -316,7 +316,7 @@ class story_settings(settings): def __init__(self, socketio, tokenizer=None): self.socketio = socketio self.tokenizer = tokenizer - self.story_name = "" # Title of the story + self.story_name = "New Game" # Title of the story self.lastact = "" # The last action received from the user self.submission = "" # Same as above, but after applying input formatting self.lastctx = "" # The last context submitted to the generator diff --git a/static/koboldai.css b/static/koboldai.css index 5a207094..b14bd5a6 100644 --- a/static/koboldai.css +++ b/static/koboldai.css @@ -43,6 +43,10 @@ --wi_card_bg_color: #262626; --wi_card_tag_bg_color: #404040; --wi_tag_color: #337ab7; + + --story_pinned_areas: "menuicon options gamescreen lefticon" + "menuicon inputrow inputrow lefticon"; + --story_pinned_area_widths: 30px 30% auto 30px; } /*----------------Folder Tabs--------------------*/ @@ -603,9 +607,8 @@ body { .main-grid.story_pinned { margin-left: var(--flyout_menu_closed_width); margin-right: var(--flyout_menu_width); - grid-template-areas: "menuicon gamescreen options lefticon" - "menuicon inputrow inputrow lefticon"; - grid-template-columns: 30px auto 30% 30px; + grid-template-areas: var(--story_pinned_areas); + grid-template-columns: var(--story_pinned_area_widths); } .main-grid.settings_pinned.story_pinned { margin-left: var(--flyout_menu_width); diff --git a/static/koboldai.js b/static/koboldai.js index de16236e..1c16e9aa 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -1255,6 +1255,18 @@ function show_error_message(data) { error_message_box.querySelector("#popup_list_area").textContent = data; } //--------------------------------------------UI to Server Functions---------------------------------- +function new_story() { + //check if the story is saved + if (document.getElementById('save_story').getAttribute('story_gamesaved') == "false") { + //ask the user if they want to continue + if (window.confirm("You asked for a new story but your current story has not been saved. If you continue you will loose your changes.")) { + socket.emit('new_story', ''); + } + } else { + socket.emit('new_story', ''); + } +} + function save_as_story(response) { if (response == "overwrite?") { document.getElementById('save-confirm').classList.remove('hidden') @@ -1346,10 +1358,34 @@ function preserve_game_space(preserve) { if (preserve) { setCookie("preserve_game_space", "true"); r.style.setProperty('--setting_menu_closed_width_no_pins_width', '0px'); + if (!(document.getElementById('preserve_game_space_setting').checked)) { + //not sure why the bootstrap-toggle won't respect a standard item.checked = true/false, so.... + document.getElementById('preserve_game_space_setting').parentNode.click(); + } document.getElementById('preserve_game_space_setting').checked = true; } else { setCookie("preserve_game_space", "false"); r.style.setProperty('--setting_menu_closed_width_no_pins_width', '450px'); + if (document.getElementById('preserve_game_space_setting').checked) { + //not sure why the bootstrap-toggle won't respect a standard item.checked = true/false, so.... + document.getElementById('preserve_game_space_setting').parentNode.click(); + } + document.getElementById('preserve_game_space_setting').checked = false; + } +} + +function options_on_right(data) { + var r = document.querySelector(':root'); + console.log("Setting cookie to: "+data); + if (data) { + setCookie("options_on_right", "true"); + r.style.setProperty('--story_pinned_areas', '"menuicon gamescreen options lefticon"\n"menuicon inputrow inputrow lefticon"'); + r.style.setProperty('--story_pinned_area_widths', '30px auto 30% 30px'); + document.getElementById('preserve_game_space_setting').checked = true; + } else { + setCookie("options_on_right", "false"); + r.style.setProperty('--story_pinned_areas', '"menuicon options gamescreen lefticon"\n"menuicon inputrow inputrow lefticon"'); + r.style.setProperty('--story_pinned_area_widths', '30px 30% auto 30px'); document.getElementById('preserve_game_space_setting').checked = false; } } @@ -2071,4 +2107,5 @@ $(document).ready(function(){ } console.log("cookie: "+getCookie("preserve_game_space")); preserve_game_space((getCookie("preserve_game_space") == "true")); + options_on_right((getCookie("options_on_right") == "true")); }); \ No newline at end of file diff --git a/templates/settings flyout.html b/templates/settings flyout.html index a1a2b96e..c9bcd988 100644 --- a/templates/settings flyout.html +++ b/templates/settings flyout.html @@ -53,6 +53,7 @@
Story Name:
+ @@ -106,6 +107,23 @@
+
+ + 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. + + + + + + + + + +
\ No newline at end of file From 1f50c4bd91ea94a1e09ce5e59644f4c156609d50 Mon Sep 17 00:00:00 2001 From: ebolam Date: Wed, 10 Aug 2022 16:04:34 -0400 Subject: [PATCH 2/4] Added code to set option width to 0 if not used (gen amount=1 and no options to show). --- static/koboldai.css | 8 ++++---- static/koboldai.js | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/static/koboldai.css b/static/koboldai.css index b14bd5a6..061de311 100644 --- a/static/koboldai.css +++ b/static/koboldai.css @@ -43,10 +43,10 @@ --wi_card_bg_color: #262626; --wi_card_tag_bg_color: #404040; --wi_tag_color: #337ab7; - + --story_options_size: 30%; --story_pinned_areas: "menuicon options gamescreen lefticon" "menuicon inputrow inputrow lefticon"; - --story_pinned_area_widths: 30px 30% auto 30px; + --story_pinned_area_widths: 30px var(--story_options_size) auto 30px; } /*----------------Folder Tabs--------------------*/ @@ -598,7 +598,7 @@ body { margin-right: var(--flyout_menu_closed_width); grid-template-areas: "menuicon gamescreen options lefticon" "menuicon inputrow inputrow lefticon"; - grid-template-columns: 30px auto 30% 30px; + grid-template-columns: 30px auto var(--story_options_size) 30px; grid-template-rows: auto 100px; } .main-grid.settings_pinned { @@ -615,7 +615,7 @@ body { margin-right: var(--flyout_menu_width); grid-template-areas: "menuicon gamescreen options lefticon" "menuicon inputrow inputrow lefticon"; - grid-template-columns: 30px auto 30% 30px; + grid-template-columns: 30px auto var(--story_options_size) 30px; } } diff --git a/static/koboldai.js b/static/koboldai.js index 1c16e9aa..5de3107e 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -401,6 +401,17 @@ function var_changed(data) { } } + //if we changed the gen amount, make sure our option area is set/not set + if ((data.classname == 'model') && (data.name == 'numseqs')) { + if (data.value == 1) { + var r = document.querySelector(':root'); + r.style.setProperty('--story_options_size', 'fit-content(30%)'); + } else { + var r = document.querySelector(':root'); + r.style.setProperty('--story_options_size', '30%'); + } + } + //if we're updating generated tokens, let's show that in our status bar if ((data.classname == 'model') && (data.name == 'tqdm_progress')) { update_status_bar(data); @@ -1380,12 +1391,12 @@ function options_on_right(data) { if (data) { setCookie("options_on_right", "true"); r.style.setProperty('--story_pinned_areas', '"menuicon gamescreen options lefticon"\n"menuicon inputrow inputrow lefticon"'); - r.style.setProperty('--story_pinned_area_widths', '30px auto 30% 30px'); + r.style.setProperty('--story_pinned_area_widths', '30px auto var(--story_options_size) 30px'); document.getElementById('preserve_game_space_setting').checked = true; } else { setCookie("options_on_right", "false"); r.style.setProperty('--story_pinned_areas', '"menuicon options gamescreen lefticon"\n"menuicon inputrow inputrow lefticon"'); - r.style.setProperty('--story_pinned_area_widths', '30px 30% auto 30px'); + r.style.setProperty('--story_pinned_area_widths', '30px var(--story_options_size) auto 30px'); document.getElementById('preserve_game_space_setting').checked = false; } } From 6e9c6e5535a2e33b69dcb2baf60d1918d4865e84 Mon Sep 17 00:00:00 2001 From: ebolam Date: Wed, 10 Aug 2022 16:58:54 -0400 Subject: [PATCH 3/4] Turning on relay debuging to troubleshoot on colab --- koboldai_settings.py | 2 +- static/koboldai.js | 2 ++ templates/index_new.html | 59 +--------------------------------------- 3 files changed, 4 insertions(+), 59 deletions(-) diff --git a/koboldai_settings.py b/koboldai_settings.py index eba3b26f..730a69ba 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -38,7 +38,7 @@ def process_variable_changes(socketio, classname, name, value, old_value, debug_ if threading.get_ident() in rely_clients: sio = rely_clients[threading.get_ident()] else: - sio = socketio_client.Client() + sio = socketio_client.Client(logger=True, engineio_logger=True) @sio.event def connect(): pass diff --git a/static/koboldai.js b/static/koboldai.js index 5de3107e..85a96c65 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -404,9 +404,11 @@ function var_changed(data) { //if we changed the gen amount, make sure our option area is set/not set if ((data.classname == 'model') && (data.name == 'numseqs')) { if (data.value == 1) { + //allow our options to collapse to 0%, but no more than 30% (in case there is a redo or the like) var r = document.querySelector(':root'); r.style.setProperty('--story_options_size', 'fit-content(30%)'); } else { + //static 30% var r = document.querySelector(':root'); r.style.setProperty('--story_options_size', '30%'); } diff --git a/templates/index_new.html b/templates/index_new.html index b709736c..f25b7fa8 100644 --- a/templates/index_new.html +++ b/templates/index_new.html @@ -77,64 +77,7 @@ From 6e661232e34fc3ee689a3b4bda11a123f4601533 Mon Sep 17 00:00:00 2001 From: ebolam Date: Wed, 10 Aug 2022 17:17:02 -0400 Subject: [PATCH 4/4] Missed File --- templates/templates.html | 58 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 templates/templates.html diff --git a/templates/templates.html b/templates/templates.html new file mode 100644 index 00000000..6d8ff14e --- /dev/null +++ b/templates/templates.html @@ -0,0 +1,58 @@ +
+
+

+ X +
+
+ Always Include +
+
+
Requires one of:
+
+
+
And (if present):
+
+
+ Text: + +
+ +
+ Comment: + +
+
+
+
+ +
+
+
+
+ +
+
-12
+
0
+
12
+
+
+
+
+
+ +
+
0
+
10
+
10
+
+
+
\ No newline at end of file