From ad330b27d56e6ae39af624579d03ef3fe5e311b0 Mon Sep 17 00:00:00 2001 From: ebolam Date: Mon, 24 Oct 2022 10:59:07 -0400 Subject: [PATCH 1/6] Fix for pulse not being removed from saved world info entry fields. --- static/koboldai.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/static/koboldai.js b/static/koboldai.js index debacad1..2e2af335 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -1723,6 +1723,7 @@ function world_info_entry(data) { title.setAttribute("uid", data.uid); title.setAttribute("original_text", data.title); title.setAttribute("contenteditable", true); + title.classList.remove("pulse"); title.ondragstart=function() {event.preventDefault();event.stopPropagation();}; title.onblur = function () { this.parentElement.parentElement.setAttribute('draggable', 'true'); @@ -1790,6 +1791,7 @@ function world_info_entry(data) { wpp_toggle_area.append(wpp_toggle); } wpp_toggle.checked = data.use_wpp; + wpp_toggle.classList.remove("pulse"); //w++ data let last_new_value = null @@ -1923,6 +1925,7 @@ function world_info_entry(data) { send_world_info(this.getAttribute('uid')); this.classList.add("pulse"); } + manual_text.classList.remove("pulse"); comment = world_info_card.querySelector('.world_info_comment'); comment.id = "world_info_comment_"+data.uid; comment.setAttribute("uid", data.uid); @@ -1932,6 +1935,7 @@ function world_info_entry(data) { send_world_info(this.getAttribute('uid')); this.classList.add("pulse"); } + comment.classList.remove("pulse"); constant_area = world_info_card.querySelector('.world_info_always_include'); constant_area.id = "world_info_toggle_area_"+data.uid; if (document.getElementById("world_info_constant_"+data.uid)) { @@ -1952,6 +1956,7 @@ function world_info_entry(data) { constant_area.append(constant); } constant.checked = data.constant; + constant.classList.remove("pulse"); if (!(document.getElementById("world_info_folder_"+data.folder))) { folder = document.createElement("div"); From c0fb992091a4300e584d22af8272a23dcb6a3a2c Mon Sep 17 00:00:00 2001 From: ebolam Date: Mon, 24 Oct 2022 12:16:40 -0400 Subject: [PATCH 2/6] Fix for world info key tabbing --- aiserver.py | 2 ++ static/koboldai.js | 16 ++++++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/aiserver.py b/aiserver.py index 78d30eea..8217bbb4 100644 --- a/aiserver.py +++ b/aiserver.py @@ -8483,12 +8483,14 @@ def UI_2_edit_world_info(data): print(data) if data['uid'] < 0: + logger.debug("Creating WI: {}".format(data)) koboldai_vars.worldinfo_v2.add_item(data['title'], data['key'], data['keysecondary'], data['folder'], data['constant'], data['manual_text'], data['comment'], wpp=data['wpp'], use_wpp=data['use_wpp']) emit("delete_new_world_info_entry", {}) else: + logger.debug("Editting WI: {}".format(data)) koboldai_vars.worldinfo_v2.edit_item(data['uid'], data['title'], data['key'], data['keysecondary'], data['folder'], data['constant'], data['manual_text'], diff --git a/static/koboldai.js b/static/koboldai.js index 2e2af335..e9b1a5a1 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -1697,14 +1697,10 @@ function process_world_info_entry(data) { function world_info_entry(data) { world_info_data[data.uid] = data; - //delete the existing world info and recreate - var original_focus = null; + //First let's get the id of the element we're on so we can restore it after removing the object + var original_focus = document.activeElement.id; + if (document.getElementById("world_info_"+data.uid)) { - //First let's get the id of the element we're on so we can restore it after removing the object - original_focus = document.activeElement.id; - //console.log("Active ID: "+original_focus); - //console.log(document.activeElement); - //document.getElementById("world_info_"+data.uid).remove(); world_info_card = document.getElementById("world_info_"+data.uid); } else { world_info_card_template = document.getElementById("world_info_"); @@ -2025,7 +2021,7 @@ function world_info_entry(data) { } on_new_wi_item = null; //for some reason we have to wrap this in a timmer - setTimeout(function() {document.getElementById(original_focus).click();document.getElementById(original_focus).focus()}, 0); + setTimeout(function() {document.getElementById(original_focus.replace("-1", data.uid)).click();document.getElementById(original_focus.replace("-1", data.uid)).focus()}, 0); } } @@ -3268,7 +3264,7 @@ function add_tags(tags, data) { text.onblur = function () { this.parentElement.parentElement.parentElement.setAttribute('draggable', 'true'); this.setAttribute('draggable', 'true'); - if (this.textContent != "") { + if (this.textContent.trim() != "") { //console.log(this.textContent); on_new_wi_item = this.id; world_info_data[this.getAttribute('uid')]['key'].push(this.textContent); @@ -3346,7 +3342,7 @@ function add_secondary_tags(tags, data) { text.onblur = function () { this.parentElement.parentElement.parentElement.setAttribute('draggable', 'true'); this.setAttribute('draggable', 'true'); - if (this.textContent != "") { + if (this.textContent.trim() != "") { on_new_wi_item = this.id; world_info_data[this.getAttribute('uid')]['keysecondary'].push(this.textContent); send_world_info(this.getAttribute('uid')); From b6c0caaeae428fa526b3e8f9de5b99469fed2c20 Mon Sep 17 00:00:00 2001 From: ebolam Date: Mon, 24 Oct 2022 13:51:46 -0400 Subject: [PATCH 3/6] Added javascript errors to debug download and aiserver log to debug download --- aiserver.py | 4 ++++ static/koboldai.css | 2 +- static/koboldai.js | 28 +++++++++++++++++++++++++++- templates/index_new.html | 2 +- templates/popups.html | 1 + 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/aiserver.py b/aiserver.py index 8217bbb4..1bada559 100644 --- a/aiserver.py +++ b/aiserver.py @@ -9269,6 +9269,10 @@ def UI_2_update_tokens(data): @socketio.on("get_log") def UI_2_get_log(data): emit("log_message", web_log_history) + +@app.route("/get_log") +def UI_2_get_log_get(): + return {'aiserver_log': web_log_history} @app.route("/test_match") @logger.catch diff --git a/static/koboldai.css b/static/koboldai.css index e22ce861..5661650a 100644 --- a/static/koboldai.css +++ b/static/koboldai.css @@ -1141,7 +1141,7 @@ body { grid-template-areas: "menuicon gamescreen options lefticon" "menuicon theme theme lefticon" "menuicon inputrow inputrow lefticon"; - grid-template-columns: 30px auto fit-content(30%) 30px; + grid-template-columns: 30px auto 30% 30px; grid-template-rows: auto min-content 100px; } .main-grid[option_length="0"][model_numseqs="1"] { diff --git a/static/koboldai.js b/static/koboldai.js index e9b1a5a1..e009a3a8 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -2310,6 +2310,7 @@ function load_cookies(data) { } function process_log_message(full_data) { + debug_info['aiserver errors'] = [] for (data of full_data) { let level = data['record']['level']['name']; let message = data['record']['message']; @@ -2320,6 +2321,10 @@ function process_log_message(full_data) { show_error_message(data['html']); } + + let temp = JSON.parse(JSON.stringify(data.record)); + debug_info['aiserver errors'].push(temp); + //put log message in log popup const log_popup = document.getElementById('log-popup'); const log_popup_data = log_popup.querySelector("#popup_list_area") @@ -3877,6 +3882,18 @@ function getRedactedValue(value) { async function downloadDebugFile(redact=true) { let r = await fetch("/vars"); let varsData = await r.json(); + + r = await fetch("/get_log"); + let aiserver_log = await r.json(); + console.log(aiserver_log); + + debug_info['aiserver errors'] = [] + for (data of aiserver_log.aiserver_log) { + let temp = JSON.parse(JSON.stringify(data.record)); + temp = {"level": temp.level.name, 'message': temp.message, 'record': temp}; + delete temp.record.message; + debug_info['aiserver errors'].push(temp); + } // Redact sensitive user info @@ -3892,7 +3909,7 @@ async function downloadDebugFile(redact=true) { "system_settings.savedir", // Can reveal username "story_settings.last_story_load", ]; - + if (redact) { // TODO: genseqs, splist(?) redactables = redactables.concat([ @@ -3912,6 +3929,7 @@ async function downloadDebugFile(redact=true) { "system_settings.spfilename", "system_settings.spname", ]); + // Redact more complex things @@ -3973,6 +3991,14 @@ async function downloadDebugFile(redact=true) { } debug_info.currentVars = varsData; + + //redact aiserver log messages + for (log_item of debug_info['aiserver errors']) { + if (['PROMPT', 'GENERATION'].includes(log_item.level)) { + log_item.message = getRedactedValue(log_item.message); + } + } + console.log(debug_info); downloadString(JSON.stringify(debug_info, null, 4), "kobold_debug.json"); diff --git a/templates/index_new.html b/templates/index_new.html index 62de267b..bcc93d61 100644 --- a/templates/index_new.html +++ b/templates/index_new.html @@ -6,7 +6,7 @@ var debug_info = {errors: []}; window.addEventListener('error', function(event) { - // debug_info.push({msg: message, url: url, line: line}); + debug_info.errors.push({msg: message, url: url, line: line}); }); diff --git a/templates/popups.html b/templates/popups.html index 7ed4e952..585098ba 100644 --- a/templates/popups.html +++ b/templates/popups.html @@ -152,6 +152,7 @@ From 712844afcd4eb8e8b5ddfc1602774da504ac1c63 Mon Sep 17 00:00:00 2001 From: ebolam Date: Mon, 24 Oct 2022 13:54:52 -0400 Subject: [PATCH 4/6] Fix for error popup --- static/koboldai.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/static/koboldai.js b/static/koboldai.js index e009a3a8..835fa8f2 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -2259,6 +2259,7 @@ function show_error_message(data) { while (error_box_data.firstChild) { error_box_data.removeChild(error_box_data.firstChild); } + console.log(data); if (Array.isArray(data)) { for (item of data) { $e("div", error_box_data, {'innerHTML': item, 'classes': ['console_text']}) @@ -2266,7 +2267,7 @@ function show_error_message(data) { } } else { //console.log(item); - $e("div", error_box_data, {'innerHTML': item, 'classes': ['console_text']}) + $e("div", error_box_data, {'innerHTML': data, 'classes': ['console_text']}) } openPopup("error-popup"); } From 7579137433ee7141488ba00e3ea71fb465e92dd9 Mon Sep 17 00:00:00 2001 From: ebolam Date: Mon, 24 Oct 2022 14:22:18 -0400 Subject: [PATCH 5/6] Add automatic hide of the World Info Depth setting when using the alternative text generation method (alt gen ignores World Info Depth) --- gensettings.py | 3 ++- static/koboldai.css | 4 ++++ templates/settings item.html | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gensettings.py b/gensettings.py index c7277638..d97ca42f 100644 --- a/gensettings.py +++ b/gensettings.py @@ -193,7 +193,8 @@ gensettingstf = [ "menu_path": "World Info", "sub_path": "", "classname": "user", - "name": "widepth" + "name": "widepth", + "extra_classes": "var_sync_alt_system_alt_gen" }, { "uitype": "toggle", diff --git a/static/koboldai.css b/static/koboldai.css index 5661650a..3ca0d79a 100644 --- a/static/koboldai.css +++ b/static/koboldai.css @@ -199,6 +199,10 @@ border-top-right-radius: var(--tabs_rounding); margin: 2px; } +.setting_container.var_sync_alt_system_alt_gen[system_alt_gen="true"] { + display: none; +} + .chat_mode[story_chatmode="false"] { display: none; } diff --git a/templates/settings item.html b/templates/settings item.html index ac22d9ea..c429f1ca 100644 --- a/templates/settings item.html +++ b/templates/settings item.html @@ -1,6 +1,10 @@ {% for item in settings %} {% if item["menu_path"] == menu and item['sub_path'] == sub_path %} +{% if 'extra_classes' in item %} +
+{% else %}
+{% endif %} {{ item['label'] }}: help_icon From d312553d7872599462850603c99821b34bfa77af Mon Sep 17 00:00:00 2001 From: ebolam Date: Mon, 24 Oct 2022 17:18:44 -0400 Subject: [PATCH 6/6] Added text to help users understand the debug text and started UI work on soft prompt tunner (hidden) --- koboldai_settings.py | 4 +++- templates/popups.html | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/koboldai_settings.py b/koboldai_settings.py index 23fdd82b..27b6f366 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -594,7 +594,9 @@ class model_settings(settings): self.oaiapikey = "" # API key to use for OpenAI API calls self.configname = None self.online_model = '' - self.welcome_default = "
Please load a model from the left." # Custom Welcome Text + self.welcome_default = """
Please load a model from the left.
+ If you encounter any issues, please click the Download debug dump link in the Home tab on the left flyout and attach the downloaded file to your error report on Github, Reddit, or Discord. + A redacted version (without story text) is available.""" # Custom Welcome Text self.welcome = self.welcome_default self.koboldai_vars = koboldai_vars diff --git a/templates/popups.html b/templates/popups.html index 585098ba..375dc2aa 100644 --- a/templates/popups.html +++ b/templates/popups.html @@ -249,4 +249,22 @@
+ + \ No newline at end of file