diff --git a/public/script.js b/public/script.js index 7f854a6df..b586ff767 100644 --- a/public/script.js +++ b/public/script.js @@ -3940,7 +3940,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro coreChat = await Promise.all(coreChat.map(async (chatItem, index) => { let message = chatItem.mes; let regexType = chatItem.is_user ? regex_placement.USER_INPUT : regex_placement.AI_OUTPUT; - let options = { isPrompt: true, depth: (coreChat.length - index - 1) }; + let options = { isPrompt: true, depth: (coreChat.length - index - (isContinue ? 2 : 1)) }; let regexedMessage = getRegexedString(message, regexType, options); regexedMessage = await appendFileContent(chatItem, regexedMessage); @@ -3959,7 +3959,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro const promptReasoning = new PromptReasoning(); for (let i = coreChat.length - 1; i >= 0; i--) { const depth = coreChat.length - i - 1; - const isPrefix = isContinue && i === coreChat.length - 1; + const isPrefix = isContinue && i === coreChat.length - (isContinue ? 2 : 1); coreChat[i] = { ...coreChat[i], mes: promptReasoning.addToMessage( diff --git a/public/scripts/extensions/regex/editor.html b/public/scripts/extensions/regex/editor.html index c5030656f..483155c08 100644 --- a/public/scripts/extensions/regex/editor.html +++ b/public/scripts/extensions/regex/editor.html @@ -110,14 +110,14 @@
- + Min Depth - +
- + Max Depth diff --git a/public/scripts/extensions/regex/engine.js b/public/scripts/extensions/regex/engine.js index f6e22d249..4c628c843 100644 --- a/public/scripts/extensions/regex/engine.js +++ b/public/scripts/extensions/regex/engine.js @@ -103,8 +103,8 @@ function getRegexedString(rawString, placement, { characterOverride, isMarkdown, } // Check if the depth is within the min/max depth - if (typeof depth === 'number' && depth >= 0) { - if (!isNaN(script.minDepth) && script.minDepth !== null && script.minDepth >= 0 && depth < script.minDepth) { + if (typeof depth === 'number') { + if (!isNaN(script.minDepth) && script.minDepth !== null && script.minDepth >= -1 && depth < script.minDepth) { console.debug(`getRegexedString: Skipping script ${script.scriptName} because depth ${depth} is less than minDepth ${script.minDepth}`); return; } @@ -139,7 +139,7 @@ function runRegexScript(regexScript, rawString, { characterOverride } = {}) { } const getRegexString = () => { - switch(Number(regexScript.substituteRegex)) { + switch (Number(regexScript.substituteRegex)) { case substitute_find_regex.NONE: return regexScript.findRegex; case substitute_find_regex.RAW: