From b3e0147b5d2c9b51acb6869eaf56ff2b28050e35 Mon Sep 17 00:00:00 2001 From: ebolam Date: Fri, 7 Oct 2022 08:02:46 -0400 Subject: [PATCH] Fix for sentence splitting UI Scrolling still broken --- koboldai_settings.py | 5 ++++- static/koboldai.js | 16 ++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/koboldai_settings.py b/koboldai_settings.py index 5c62ea1e..ef792293 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -1465,7 +1465,10 @@ class KoboldStoryRegister(object): action_text = self.__str__() action_text = "{}{}".format("" if self.story_settings is None else self.story_settings.prompt, action_text) ###########action_text_split = [sentence, actions used in sentence, token length, included in AI context]################ - action_text_split = [[x+" ", [], 0, False] for x in re.findall(".*?[.!?]\s+", action_text)] + action_text_split = [[x, [], 0, False] for x in re.findall(".*?[.!?]\s+", action_text)] + #The above line can trim out the last sentence if it's incomplete. Let's check for that and add it back in + if len("".join([x[0] for x in action_text_split])) < len(action_text): + action_text_split.append([action_text[len("".join([x[0] for x in action_text_split])):], [], 0, False]) #The last action shouldn't have the extra space from the sentence splitting, so let's remove it if len(action_text_split) == 0: return [] diff --git a/static/koboldai.js b/static/koboldai.js index fc722c36..eee51721 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -60,9 +60,9 @@ var finder_waiting_id = null; var control_held = false; var actions_data = {}; var setup_wi_toggles = []; -var scroll_trigger_element = undefined; +var scroll_trigger_element = undefined; //undefined means not currently set. If set to null, it's disabled. var first_scroll_occurred = false; -var temp_counter = 0; +//var temp_counter = 0; const on_colab = $el("#on_colab").textContent == "true"; // name, desc, icon, func @@ -548,10 +548,10 @@ function var_changed(data) { //Special Case for Actions if ((data.classname == "story") && (data.name == "actions")) { start_time = Date.now(); - temp_counter += 1; - if (temp_counter > 10) { - return; - } + //temp_counter += 1; + //if (temp_counter > 10) { + // return; + //} if (document.getElementById("Selected Text").firstElementChild.id == "story_prompt") { first_story_element = document.getElementById("Selected Text").firstElementChild.nextElementSibling; } else { @@ -616,7 +616,7 @@ function var_changed(data) { first_scroll_occurred = true; }, 20); //If this is the first add, then we need to set our scroll trigger up - if ((document.getElementsByClassName("rawtext").length == actions.length+1) && (scroll_trigger_element != null)) { + if (scroll_trigger_element == undefined) { console.log("Setting scroll trigger to Selected Text Chunk "+actions[0].id); scroll_trigger_element = document.getElementById('Selected Text Chunk '+actions[0].id); } @@ -4836,7 +4836,7 @@ document.getElementById("Selected Text").onscroll = function(){ console.log("Scrolling action: "+scroll_trigger_element.getAttribute("chunk")); console.log("sending emit"); socket.emit("get_next_100_actions", parseInt(scroll_trigger_element.getAttribute("chunk"))); - scroll_trigger_element == null; + scroll_trigger_element == undefined; } } } \ No newline at end of file