Fix for random spaces being added

Added try at better error handling.
This commit is contained in:
ebolam
2022-08-27 18:56:09 -04:00
parent 86df99ba6a
commit aefefeaf88
2 changed files with 15 additions and 2 deletions

View File

@@ -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

View File

@@ -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);