Add GENERATION_ENTERED event

This commit is contained in:
Cohee 2024-09-22 15:19:17 +03:00
parent e814d8c019
commit ba52ceb979
1 changed files with 5 additions and 0 deletions

View File

@ -412,6 +412,7 @@ export const event_types = {
MESSAGE_FILE_EMBEDDED: 'message_file_embedded',
IMPERSONATE_READY: 'impersonate_ready',
CHAT_CHANGED: 'chat_id_changed',
GENERATION_ENTERED: 'generation_entered',
GENERATION_STARTED: 'generation_started',
GENERATION_STOPPED: 'generation_stopped',
GENERATION_ENDED: 'generation_ended',
@ -3339,6 +3340,9 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
setGenerationProgress(0);
generation_started = new Date();
// Occurs every time, even if the generation is aborted due to slash commands execution
await eventSource.emit(event_types.GENERATION_ENTERED, type, { automatic_trigger, force_name2, quiet_prompt, quietToLoud, skipWIAN, force_chid, signal, quietImage }, dryRun);
// Don't recreate abort controller if signal is passed
if (!(abortController && signal)) {
abortController = new AbortController();
@ -3358,6 +3362,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
}
}
// Occurs only if the generation is not aborted due to slash commands execution
await eventSource.emit(event_types.GENERATION_STARTED, type, { automatic_trigger, force_name2, quiet_prompt, quietToLoud, skipWIAN, force_chid, signal, quietImage }, dryRun);
if (main_api == 'kobold' && kai_settings.streaming_kobold && !kai_flags.can_use_streaming) {