Allow running generate interceptors on quiet prompts

2f5f9a437dffd43f9767a6298eb2d60485580273

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

4 files changed, +22 -7Showing whitespace changes
public/script.js+2 -2
@@ -3764,9 +3764,9 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
37643764 // Determine token limit
37653765 let this_max_context = getMaxContextSize();
37663766
37673767 if (!dryRun && type !== 'quiet') {
37683768 console.debug('Running extension interceptors');
37693769 const aborted = await runGenerationInterceptors(coreChat, this_max_context, type);
37703770
37713771 if (aborted) {
37723772 console.debug('Generation aborted by extension interceptors');
public/scripts/extensions.js+3 -2
@@ -1209,9 +1209,10 @@ async function autoUpdateExtensions(forceAll) {
12091209 * Runs the generate interceptors for all extensions.
12101210 * @param {any[]} chat Chat array
12111211 * @param {number} contextSize Context size
1212+ * @param {string} type Generation type
12121213 * @returns {Promise<boolean>} True if generation should be aborted
12131214 */
12141215export async function runGenerationInterceptors(chat, contextSize, type) {
12151216 let aborted = false;
12161217 let exitImmediately = false;
12171218
@@ -1224,7 +1225,7 @@ export async function runGenerationInterceptors(chat, contextSize) {
12241225 const interceptorKey = manifest.generate_interceptor;
12251226 if (typeof globalThis[interceptorKey] === 'function') {
12261227 try {
12271228 await globalThis[interceptorKey](chat, contextSize, abort, type);
12281229 } catch (e) {
12291230 console.error(`Failed running interceptor for ${manifest.display_name}`, e);
12301231 }
public/scripts/extensions/stable-diffusion/index.js+12 -1
@@ -330,7 +330,18 @@ const defaultSettings = {
330330
331331const writePromptFieldsDebounced = debounce(writePromptFields, debounce_timeout.relaxed);
332332
333-function processTriggers(chat, _, abort) {
333+/**
334+ * Generate interceptor for interactive mode triggers.
335+ * @param {any[]} chat Chat messages
336+ * @param {number} _ Context size (unused)
337+ * @param {function(boolean): void} abort Abort generation function
338+ * @param {string} type Type of the generation
339+ */
340+function processTriggers(chat, _, abort, type) {
341+ if (type === 'quiet') {
342+ return;
343+ }
344+
334345 if (extension_settings.sd.function_tool && ToolManager.isToolCallingSupported()) {
335346 return;
336347 }
public/scripts/extensions/vectors/index.js+5 -2
@@ -594,8 +594,11 @@ async function vectorizeFile(fileText, fileName, collectionId, chunkSize, overla
594594/**
595595 * Removes the most relevant messages from the chat and displays them in the extension prompt
596596 * @param {object[]} chat Array of chat messages
597+ * @param {number} _contextSize Context size (unused)
598+ * @param {function} _abort Abort function (unused)
599+ * @param {string} type Generation type
597600 */
598601async function rearrangeChat(chat, _contextSize, _abort, type) {
599602 try {
600603 // Clear the extension prompt
601604 setExtensionPrompt(EXTENSION_PROMPT_TAG, '', settings.position, settings.depth, settings.include_wi);
@@ -609,7 +612,7 @@ async function rearrangeChat(chat) {
609612 await activateWorldInfo(chat);
610613 }
611614
612615 if (!settings.enabled_chats || type === 'quiet') {
613616 return;
614617 }
615618