Fix for sentence splitting

UI Scrolling still broken
This commit is contained in:
ebolam
2022-10-07 08:02:46 -04:00
parent 046457fa01
commit b3e0147b5d
2 changed files with 12 additions and 9 deletions

View File

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

View File

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