Remove empty message looping

d99a5eba2ab2ac8b58c12442a09aa85a7adf5b2c

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +4 -33Showing whitespace changes
public/script.js+4 -33
@@ -881,7 +881,6 @@ let abortController;
881881
882882//css
883883var css_send_form_display = $('<div id=send_form></div>').css('display');
884-const MAX_GENERATION_LOOPS = 5;
885884
886885var kobold_horde_model = '';
887886
@@ -3342,11 +3341,11 @@ function removeLastMessage() {
33423341 * @param {GenerateOptions} options Generation options
33433342 * @param {boolean} dryRun Whether to actually generate a message or just assemble the prompt
33443343 * @returns {Promise<any>} Returns a promise that resolves when the text is done generating.
33453344 * @typedef {{automatic_trigger?: boolean, force_name2?: boolean, quiet_prompt?: string, quietToLoud?: boolean, skipWIAN?: boolean, force_chid?: number, signal?: AbortSignal, quietImage?: string, maxLoops?: number, quietName?: string }} GenerateOptions
33463345 */
33473346export async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, quietToLoud, skipWIAN, force_chid, signal, quietImage, maxLoops, quietName } = {}, dryRun = false) {
33483347 console.log('Generate entered');
33493348 await eventSource.emit(event_types.GENERATION_STARTED, type, { automatic_trigger, force_name2, quiet_prompt, quietToLoud, skipWIAN, force_chid, signal, quietImage, maxLoops }, dryRun);
33503349 setGenerationProgress(0);
33513350 generation_started = new Date();
33523351
@@ -3408,7 +3407,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
34083407 if (selected_group && !is_group_generating) {
34093408 if (!dryRun) {
34103409 // Returns the promise that generateGroupWrapper returns; resolves when generation is done
34113410 return generateGroupWrapper(false, type, { quiet_prompt, force_chid, signal: abortController.signal, quietImage, maxLoops });
34123411 }
34133412
34143413 const characterIndexMap = new Map(characters.map((char, index) => [char.avatar, index]));
@@ -4440,7 +4439,6 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
44404439 const displayIncomplete = type === 'quiet' && !quietToLoud;
44414440 getMessage = cleanUpMessage(getMessage, isImpersonate, isContinue, displayIncomplete);
44424441
4443- if (getMessage.length > 0 || data.allowEmptyResponse) {
44444442 if (isImpersonate) {
44454443 $('#send_textarea').val(getMessage)[0].dispatchEvent(new Event('input', { bubbles: true }));
44464444 generatedPromptCache = '';
@@ -4466,28 +4464,6 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
44664464 if (type !== 'quiet') {
44674465 playMessageSound();
44684466 }
4469- } else {
4470- // If maxLoops is not passed in (e.g. first time generating), set it to MAX_GENERATION_LOOPS
4471- maxLoops ??= MAX_GENERATION_LOOPS;
4472-
4473- if (maxLoops === 0) {
4474- if (type !== 'quiet') {
4475- throwCircuitBreakerError();
4476- }
4477- throw new Error('Generate circuit breaker interruption');
4478- }
4479-
4480- // regenerate with character speech reenforced
4481- // to make sure we leave on swipe type while also adding the name2 appendage
4482- await delay(1000);
4483- // A message was already deleted on regeneration, so instead treat is as a normal gen
4484- if (type === 'regenerate') {
4485- type = 'normal';
4486- }
4487- // The first await is for waiting for the generate to start. The second one is waiting for it to finish
4488- const result = await await Generate(type, { automatic_trigger, force_name2: true, quiet_prompt, quietToLoud, skipWIAN, force_chid, signal, quietImage, quietName, maxLoops: maxLoops - 1 });
4489- return result;
4490- }
44914467
44924468 if (power_user.auto_swipe) {
44934469 console.debug('checking for autoswipeblacklist on non-streaming message');
@@ -5259,11 +5235,6 @@ function getGenerateUrl(api) {
52595235 }
52605236}
52615237
5262-function throwCircuitBreakerError() {
5263- callPopup(`Could not extract reply in ${MAX_GENERATION_LOOPS} attempts. Try generating again`, 'text');
5264- unblockGeneration();
5265-}
5266-
52675238function extractTitleFromData(data) {
52685239 if (main_api == 'koboldhorde') {
52695240 return data.workerName;