Allow running generate interceptors on quiet prompts
| @@ -3764,9 +3764,9 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | ||
| 3764 | 3764 | // Determine token limit |
| 3765 | 3765 | let this_max_context = getMaxContextSize(); |
| 3766 | 3766 | |
| 3767 | 3767 | if (!dryRun && type !== 'quiet') { |
| 3768 | 3768 | console.debug('Running extension interceptors'); |
| 3769 | 3769 | const aborted = await runGenerationInterceptors(coreChat, this_max_context, type); |
| 3770 | 3770 | |
| 3771 | 3771 | if (aborted) { |
| 3772 | 3772 | console.debug('Generation aborted by extension interceptors'); |
| @@ -1209,9 +1209,10 @@ async function autoUpdateExtensions(forceAll) { | ||
| 1209 | 1209 | * Runs the generate interceptors for all extensions. |
| 1210 | 1210 | * @param {any[]} chat Chat array |
| 1211 | 1211 | * @param {number} contextSize Context size |
| 1212 | + * @param {string} type Generation type | |
| 1212 | 1213 | * @returns {Promise<boolean>} True if generation should be aborted |
| 1213 | 1214 | */ |
| 1214 | 1215 | export async function runGenerationInterceptors(chat, contextSize, type) { |
| 1215 | 1216 | let aborted = false; |
| 1216 | 1217 | let exitImmediately = false; |
| 1217 | 1218 | |
| @@ -1224,7 +1225,7 @@ export async function runGenerationInterceptors(chat, contextSize) { | ||
| 1224 | 1225 | const interceptorKey = manifest.generate_interceptor; |
| 1225 | 1226 | if (typeof globalThis[interceptorKey] === 'function') { |
| 1226 | 1227 | try { |
| 1227 | 1228 | await globalThis[interceptorKey](chat, contextSize, abort, type); |
| 1228 | 1229 | } catch (e) { |
| 1229 | 1230 | console.error(`Failed running interceptor for ${manifest.display_name}`, e); |
| 1230 | 1231 | } |
| @@ -330,7 +330,18 @@ const defaultSettings = { | ||
| 330 | 330 | |
| 331 | 331 | const writePromptFieldsDebounced = debounce(writePromptFields, debounce_timeout.relaxed); |
| 332 | 332 | |
| 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 | + | |
| 334 | 345 | if (extension_settings.sd.function_tool && ToolManager.isToolCallingSupported()) { |
| 335 | 346 | return; |
| 336 | 347 | } |
| @@ -594,8 +594,11 @@ async function vectorizeFile(fileText, fileName, collectionId, chunkSize, overla | ||
| 594 | 594 | /** |
| 595 | 595 | * Removes the most relevant messages from the chat and displays them in the extension prompt |
| 596 | 596 | * @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 | |
| 597 | 600 | */ |
| 598 | 601 | async function rearrangeChat(chat, _contextSize, _abort, type) { |
| 599 | 602 | try { |
| 600 | 603 | // Clear the extension prompt |
| 601 | 604 | setExtensionPrompt(EXTENSION_PROMPT_TAG, '', settings.position, settings.depth, settings.include_wi); |
| @@ -609,7 +612,7 @@ async function rearrangeChat(chat) { | ||
| 609 | 612 | await activateWorldInfo(chat); |
| 610 | 613 | } |
| 611 | 614 | |
| 612 | 615 | if (!settings.enabled_chats || type === 'quiet') { |
| 613 | 616 | return; |
| 614 | 617 | } |
| 615 | 618 | |