From aa29a593772e2ff0c04cb00d0c264cf45eebd7d0 Mon Sep 17 00:00:00 2001 From: Concedo Date: Fri, 9 Feb 2024 14:41:07 +0800 Subject: [PATCH] streaming and timestamp fixes --- index.html | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/index.html b/index.html index 73fe16e..6e295f6 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,7 @@ Just copy this single static HTML file anywhere and open it in a browser, or from a webserver. Please go to https://github.com/LostRuins/lite.koboldai.net for updates on Kobold Lite. Kobold Lite is under the AGPL v3.0 License unless otherwise exempted. Please do not remove this line. -Current version: 109 +Current version: 110 -Concedo --> @@ -3036,12 +3036,14 @@ }) .catch((error) => { console.error('Error:', error); - clear_poll_flags(); - render_gametext(); if(error.name!="AbortError") //aborts are silent { + flush_streaming_text(); msgbox("Error while submitting prompt: " + error); } + clear_poll_flags(); + render_gametext(); + }); } } @@ -3110,28 +3112,26 @@ } }, abort(error) { - console.error('Error:', error); - clear_poll_flags(); - render_gametext(); - if(error.name!="AbortError") //aborts are silent. slightly diff logic { + flush_streaming_text(); msgbox("Error while submitting prompt: " + error); - } + clear_poll_flags(); + render_gametext(); }, })); }) .catch((error) => { console.error('Error:', error); - clear_poll_flags(); - render_gametext(); if(error.name!="AbortError") //aborts are silent. slightly diff logic { + flush_streaming_text(); msgbox("Error while submitting prompt: " + error); - } + clear_poll_flags(); + render_gametext(); }); } @@ -8371,10 +8371,8 @@ } } - function abort_generation() { - let id_to_cancel = pending_response_id; - - //flush any streaming text first + function flush_streaming_text() + { if(is_using_custom_ep() && pending_response_id != "" && (synchro_pending_stream != "" || synchro_polled_response != "")) { //apply a short delay of 1s before button reenables @@ -8391,6 +8389,13 @@ horde_poll_nearly_completed = false; poll_pending_response(); } + } + + function abort_generation() { + let id_to_cancel = pending_response_id; + + //flush any streaming text first + flush_streaming_text(); console.log("Generation " + pending_response_id + " aborted"); clear_poll_flags(); @@ -8908,9 +8913,15 @@ } if (localsettings.opmode == 4) { - if(localsettings.inject_timestamps_instruct) + + if(localsettings.inject_timestamps_instruct && pending_context_preinjection=="" && truncated_context!="") { - pending_context_preinjection += "["+(new Date().toLocaleTimeString([], {year: 'numeric', month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit'}))+"] "; + let endmatcher = (localsettings.placeholder_tags?instructendplaceholder:get_instruct_endtag(false)); + + if(truncated_context.toLowerCase().trim().endsWith(endmatcher.toLowerCase().trim())) + { + pending_context_preinjection += "["+(new Date().toLocaleTimeString([], {year: 'numeric', month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit'}))+"] "; + } } truncated_context += pending_context_preinjection; }