Add GENERATION_ENTERED event

ba52ceb979fcda143e069bed0f5828042be2c5e6

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

1 files changed, +5 -0Showing whitespace changes
public/script.js+5 -0
@@ -412,6 +412,7 @@ export const event_types = {
412412 MESSAGE_FILE_EMBEDDED: 'message_file_embedded',
413413 IMPERSONATE_READY: 'impersonate_ready',
414414 CHAT_CHANGED: 'chat_id_changed',
415+ GENERATION_ENTERED: 'generation_entered',
415416 GENERATION_STARTED: 'generation_started',
416417 GENERATION_STOPPED: 'generation_stopped',
417418 GENERATION_ENDED: 'generation_ended',
@@ -3339,6 +3340,9 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
33393340 setGenerationProgress(0);
33403341 generation_started = new Date();
33413342
3343+ // Occurs every time, even if the generation is aborted due to slash commands execution
3344+ await eventSource.emit(event_types.GENERATION_ENTERED, type, { automatic_trigger, force_name2, quiet_prompt, quietToLoud, skipWIAN, force_chid, signal, quietImage }, dryRun);
3345+
33423346 // Don't recreate abort controller if signal is passed
33433347 if (!(abortController && signal)) {
33443348 abortController = new AbortController();
@@ -3358,6 +3362,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
33583362 }
33593363 }
33603364
3365+ // Occurs only if the generation is not aborted due to slash commands execution
33613366 await eventSource.emit(event_types.GENERATION_STARTED, type, { automatic_trigger, force_name2, quiet_prompt, quietToLoud, skipWIAN, force_chid, signal, quietImage }, dryRun);
33623367
33633368 if (main_api == 'kobold' && kai_settings.streaming_kobold && !kai_flags.can_use_streaming) {