From b6c0caaeae428fa526b3e8f9de5b99469fed2c20 Mon Sep 17 00:00:00 2001 From: ebolam Date: Mon, 24 Oct 2022 13:51:46 -0400 Subject: [PATCH] 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 @@