From aefefeaf8897997823799aac6633ac7ec00ae0b3 Mon Sep 17 00:00:00 2001 From: ebolam Date: Sat, 27 Aug 2022 18:56:09 -0400 Subject: [PATCH] Fix for random spaces being added Added try at better error handling. --- aiserver.py | 15 ++++++++++++++- static/koboldai.js | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/aiserver.py b/aiserver.py index 4ba9524d..2525da37 100644 --- a/aiserver.py +++ b/aiserver.py @@ -6168,7 +6168,7 @@ def load_story_v1(js): if "actions_metadata" in js: if type(js["actions_metadata"]) == dict: for key in js["actions_metadata"]: - if js["actions_metadata"][key]["Alternative Text"] != [] and js["actions_metadata"][key]["Alternative Text"] != {}: + if js["actions_metadata"][key]["Alternative Text"] != []: data = js["actions_metadata"][key]["Alternative Text"] data["text"] = data.pop("Text") koboldai_vars.actions.set_options(self, data, key) @@ -7305,6 +7305,19 @@ def my_except_hook(exctype, value, traceback): sys.__excepthook__(exctype, value, traceback) sys.excepthook = my_except_hook +from werkzeug.exceptions import HTTPException + +@app.errorhandler(Exception) +def handle_exception(e): + # pass through HTTP errors + if isinstance(e, HTTPException): + return e + + # now you're handling non-HTTP exceptions only + print("sending error to clients") + socketio.emit("error", "{}: {}".format(e.message, e.args), broadcast=True, room="UI_2") + return render_template("500_generic.html", e=e), 500 + #==================================================================# # Event triggered when Softprompt is clicked diff --git a/static/koboldai.js b/static/koboldai.js index 52eef5b4..15a4708b 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -2417,7 +2417,7 @@ function assign_world_info_to_action(action_item, uid) { if (end_word-passed_words <= span_text.length) { highlight_text += " "; } - var after_highlight_text = span_text.slice((end_word-passed_words)).join(" ")+" "; + var after_highlight_text = span_text.slice((end_word-passed_words)).join(" "); //console.log(span.textContent); //console.log(keyword); //console.log(before_highlight_text);