From bd72b05e12ef96061e4b080c7202cf1f60fbc86f Mon Sep 17 00:00:00 2001 From: ebolam Date: Tue, 10 Jan 2023 20:15:26 -0500 Subject: [PATCH 1/2] Fix for editting an action with a matched world info --- koboldai_settings.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/koboldai_settings.py b/koboldai_settings.py index 5031bcea..dba0337b 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -1020,8 +1020,10 @@ class story_settings(settings): logger.debug("Calcing WI Assignment for action_id: {} wuid: {}".format(action_id, wuid)) if action_id != -1 and (action_id is None or action_id not in self.actions.actions): actions_to_check = self.actions.actions - else: + elif action_id == -1: actions_to_check = {} + else: + actions_to_check = {action_id: self.actions.actions[action_id]} if wuid is None or wuid not in self.worldinfo_v2.world_info: wi_to_check = self.worldinfo_v2.world_info else: @@ -1369,6 +1371,7 @@ class KoboldStoryRegister(object): def add_wi_to_action(self, action_id, key, content, uid, no_transmit=False): old = self.story_settings.prompt_wi_highlighted_text.copy() if action_id == -1 else self.actions[action_id].copy() + force_changed = False #First check to see if we have the wi_highlighted_text variable if action_id != -1: if 'wi_highlighted_text' not in self.actions[action_id]: @@ -1399,14 +1402,18 @@ class KoboldStoryRegister(object): if post_text is not None: action.insert(i+adder, {"text": post_text, "WI matches": None, "WI Text": ""}) break; + elif action[i]['WI matches'] == uid: + action[i]['WI Text'] = content + force_changed = True + i+=1 else: i+=1 if action_id != -1: - if old != self.actions[action_id]: + if old != self.actions[action_id] or force_changed: if not no_transmit: process_variable_changes(self.socketio, "story", 'actions', {"id": action_id, 'action': self.actions[action_id]}, old) else: - if old != self.story_settings.prompt_wi_highlighted_text: + if old != self.story_settings.prompt_wi_highlighted_text or force_changed: if not no_transmit: process_variable_changes(self.socketio, "story", 'prompt_wi_highlighted_text', self.story_settings.prompt_wi_highlighted_text, old) @@ -1451,6 +1458,8 @@ class KoboldStoryRegister(object): old_text = self.actions[i]["Selected Text"] if self.actions[i]["Selected Text"] != text: self.actions[i]["Selected Text"] = text + if 'wi_highlighted_text' in self.actions[i]: + del self.actions[i]['wi_highlighted_text'] if self.koboldai_vars.tokenizer is not None: tokens = self.koboldai_vars.tokenizer.encode(text) if 'Probabilities' in self.actions[i]: From 23eac7668156da1de91f6e5c3c98e511d04536e1 Mon Sep 17 00:00:00 2001 From: ebolam Date: Tue, 10 Jan 2023 20:22:52 -0500 Subject: [PATCH 2/2] Reversing commit 70a25ed6db6528409c1387eb1cad241de185f579 as that's in one-some's pull --- static/koboldai.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/static/koboldai.js b/static/koboldai.js index 169225cf..be531ee7 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -556,11 +556,6 @@ function do_story_text_updates(action) { item = document.createElement("span"); item.id = 'Selected Text Chunk '+action.id; item.classList.add("rawtext"); - item.addEventListener("paste", function(e) { - e.preventDefault(); - var text = e.clipboardData.getData("text/plain"); - document.execCommand("insertHTML", false, text); - }); item.setAttribute("chunk", action.id); //need to find the closest element next_id = action.id+1; @@ -6544,11 +6539,6 @@ function addMessage(author, content, actionId, afterMsgEl=null, time=null) { // Insertion location insertionLocation, ); - message.addEventListener("paste", function(e) { - e.preventDefault(); - var text = e.clipboardData.getData("text/plain"); - document.execCommand("insertHTML", false, text); - }); const leftContainer = $e("div", message, {classes: ["chat-left-container"]});