diff --git a/aiserver.py b/aiserver.py index bea0d662..9e871c6f 100644 --- a/aiserver.py +++ b/aiserver.py @@ -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 if(koboldai_vars.aibusy): return - + + # Open up token stream + emit("stream_tokens", True, broadcast=True, room="UI_2") + while(True): set_aibusy(1) koboldai_vars.actions.clear_unused_options() diff --git a/static/koboldai.js b/static/koboldai.js index 83fba5b7..f775f3f0 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -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); clearTimeout(auto_loader_timeout); - streaming.windowOpen = true; - hide_show_prompt(); //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": ""}); } } - } function stream_tokens(tokens) { @@ -3366,6 +3363,11 @@ function stream_tokens(tokens) { let streamBuffer = $el("#token-stream-buffer"); + if (tokens === true) { + streaming.windowOpen = true; + return; + } + if (!streaming.windowOpen) { // Reject tokens sent after the streaming window is closed return; @@ -3402,6 +3404,7 @@ function stream_tokens(tokens) { // Get the average time (ms) it took the last 5 tokens to generate if (!streaming.typeyTimeout) return; + if (!streaming.windowOpen) return; if (!smoothStreamingEnabled) return; streaming.typeyTimeout = setTimeout(_char, avg);