1
0
mirror of https://github.com/SillyTavern/SillyTavern.git synced 2025-03-13 18:40:11 +01:00

Don't unblock generation if a parallel stream is still running after quiet gens

This commit is contained in:
Cohee 2024-04-14 17:26:58 +03:00
parent 3e60919289
commit fd0c16bf12

@ -3065,14 +3065,14 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu
if (interruptedByCommand) { if (interruptedByCommand) {
//$("#send_textarea").val('').trigger('input'); //$("#send_textarea").val('').trigger('input');
unblockGeneration(); unblockGeneration(type);
return Promise.resolve(); return Promise.resolve();
} }
} }
if (main_api == 'kobold' && kai_settings.streaming_kobold && !kai_flags.can_use_streaming) { if (main_api == 'kobold' && kai_settings.streaming_kobold && !kai_flags.can_use_streaming) {
toastr.error('Streaming is enabled, but the version of Kobold used does not support token streaming.', undefined, { timeOut: 10000, preventDuplicates: true }); toastr.error('Streaming is enabled, but the version of Kobold used does not support token streaming.', undefined, { timeOut: 10000, preventDuplicates: true });
unblockGeneration(); unblockGeneration(type);
return Promise.resolve(); return Promise.resolve();
} }
@ -3081,12 +3081,12 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu
textgen_settings.legacy_api && textgen_settings.legacy_api &&
(textgen_settings.type === OOBA || textgen_settings.type === APHRODITE)) { (textgen_settings.type === OOBA || textgen_settings.type === APHRODITE)) {
toastr.error('Streaming is not supported for the Legacy API. Update Ooba and use new API to enable streaming.', undefined, { timeOut: 10000, preventDuplicates: true }); toastr.error('Streaming is not supported for the Legacy API. Update Ooba and use new API to enable streaming.', undefined, { timeOut: 10000, preventDuplicates: true });
unblockGeneration(); unblockGeneration(type);
return Promise.resolve(); return Promise.resolve();
} }
if (isHordeGenerationNotAllowed()) { if (isHordeGenerationNotAllowed()) {
unblockGeneration(); unblockGeneration(type);
return Promise.resolve(); return Promise.resolve();
} }
@ -3122,7 +3122,7 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu
setCharacterName(''); setCharacterName('');
} else { } else {
console.log('No enabled members found'); console.log('No enabled members found');
unblockGeneration(); unblockGeneration(type);
return Promise.resolve(); return Promise.resolve();
} }
} }
@ -3296,7 +3296,7 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu
if (aborted) { if (aborted) {
console.debug('Generation aborted by extension interceptors'); console.debug('Generation aborted by extension interceptors');
unblockGeneration(); unblockGeneration(type);
return Promise.resolve(); return Promise.resolve();
} }
} else { } else {
@ -3310,7 +3310,7 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu
adjustedParams = await adjustHordeGenerationParams(max_context, amount_gen); adjustedParams = await adjustHordeGenerationParams(max_context, amount_gen);
} }
catch { catch {
unblockGeneration(); unblockGeneration(type);
return Promise.resolve(); return Promise.resolve();
} }
if (horde_settings.auto_adjust_context_length) { if (horde_settings.auto_adjust_context_length) {
@ -4097,7 +4097,7 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu
await eventSource.emit(event_types.IMPERSONATE_READY, getMessage); await eventSource.emit(event_types.IMPERSONATE_READY, getMessage);
} }
else if (type == 'quiet') { else if (type == 'quiet') {
unblockGeneration(); unblockGeneration(type);
return getMessage; return getMessage;
} }
else { else {
@ -4165,7 +4165,7 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu
console.debug('/api/chats/save called by /Generate'); console.debug('/api/chats/save called by /Generate');
await saveChatConditional(); await saveChatConditional();
unblockGeneration(); unblockGeneration(type);
streamingProcessor = null; streamingProcessor = null;
if (type !== 'quiet') { if (type !== 'quiet') {
@ -4183,7 +4183,7 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu
generatedPromptCache = ''; generatedPromptCache = '';
unblockGeneration(); unblockGeneration(type);
console.log(exception); console.log(exception);
streamingProcessor = null; streamingProcessor = null;
throw exception; throw exception;
@ -4253,7 +4253,16 @@ function flushWIDepthInjections() {
} }
} }
function unblockGeneration() { /**
* Unblocks the UI after a generation is complete.
* @param {string} [type] Generation type (optional)
*/
function unblockGeneration(type) {
// Don't unblock if a parallel stream is still running
if (type === 'quiet' && streamingProcessor && !streamingProcessor.isFinished) {
return;
}
is_send_press = false; is_send_press = false;
activateSendButtons(); activateSendButtons();
showSwipeButtons(); showSwipeButtons();