Streaming: Fix bad streamingwindow sync

sometimes the good solution is the best solution
This commit is contained in:
somebody
2023-07-23 17:50:53 -05:00
parent 8de610df8c
commit f4593ed04b
2 changed files with 10 additions and 4 deletions

View File

@@ -3278,7 +3278,10 @@ def actionsubmit(data, actionmode=0, force_submit=False, force_prompt_gen=False,
# Ignore new submissions if the AI is currently busy # Ignore new submissions if the AI is currently busy
if(koboldai_vars.aibusy): if(koboldai_vars.aibusy):
return return
# Open up token stream
emit("stream_tokens", True, broadcast=True, room="UI_2")
while(True): while(True):
set_aibusy(1) set_aibusy(1)
koboldai_vars.actions.clear_unused_options() koboldai_vars.actions.clear_unused_options()

View File

@@ -529,8 +529,6 @@ function process_actions_data(data) {
game_text_scroll_timeout = setTimeout(run_infinite_scroll_update.bind(null, action_type, actions, first_action), 200); game_text_scroll_timeout = setTimeout(run_infinite_scroll_update.bind(null, action_type, actions, first_action), 200);
clearTimeout(auto_loader_timeout); clearTimeout(auto_loader_timeout);
streaming.windowOpen = true;
hide_show_prompt(); hide_show_prompt();
//console.log("Took "+((Date.now()-start_time)/1000)+"s to process"); //console.log("Took "+((Date.now()-start_time)/1000)+"s to process");
@@ -3357,7 +3355,6 @@ function update_game_text(id, new_text) {
socket.emit("Set Selected Text", {"id": id, "text": ""}); socket.emit("Set Selected Text", {"id": id, "text": ""});
} }
} }
} }
function stream_tokens(tokens) { function stream_tokens(tokens) {
@@ -3366,6 +3363,11 @@ function stream_tokens(tokens) {
let streamBuffer = $el("#token-stream-buffer"); let streamBuffer = $el("#token-stream-buffer");
if (tokens === true) {
streaming.windowOpen = true;
return;
}
if (!streaming.windowOpen) { if (!streaming.windowOpen) {
// Reject tokens sent after the streaming window is closed // Reject tokens sent after the streaming window is closed
return; return;
@@ -3402,6 +3404,7 @@ function stream_tokens(tokens) {
// Get the average time (ms) it took the last 5 tokens to generate // Get the average time (ms) it took the last 5 tokens to generate
if (!streaming.typeyTimeout) return; if (!streaming.typeyTimeout) return;
if (!streaming.windowOpen) return;
if (!smoothStreamingEnabled) return; if (!smoothStreamingEnabled) return;
streaming.typeyTimeout = setTimeout(_char, avg); streaming.typeyTimeout = setTimeout(_char, avg);