Dont count Continue as message 0 (#3594) * continue works same as swipe continued message isn't depth counted * correct early-out check * update regex depth setting tooltips for accuracy * update max tooltip * remove redundant check * Allow -1 as a min depth value --------- Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>

01ef823da91dac0943742d1df3b0fe220f90420e

Reithan <bo122081@hotmail.com>

Signed
3 files changed, +7 -7Showing whitespace changes
public/script.js+2 -2
@@ -3940,7 +3940,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
3940 coreChat = await Promise.all(coreChat.map(async (chatItem, index) => {3940 coreChat = await Promise.all(coreChat.map(async (chatItem, index) => {
3941 let message = chatItem.mes;3941 let message = chatItem.mes;
3942 let regexType = chatItem.is_user ? regex_placement.USER_INPUT : regex_placement.AI_OUTPUT;3942 let regexType = chatItem.is_user ? regex_placement.USER_INPUT : regex_placement.AI_OUTPUT;
3943 let options = { isPrompt: true, depth: (coreChat.length - index - 1) };3943 let options = { isPrompt: true, depth: (coreChat.length - index - (isContinue ? 2 : 1)) };
39443944
3945 let regexedMessage = getRegexedString(message, regexType, options);3945 let regexedMessage = getRegexedString(message, regexType, options);
3946 regexedMessage = await appendFileContent(chatItem, regexedMessage);3946 regexedMessage = await appendFileContent(chatItem, regexedMessage);
@@ -3959,7 +3959,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
3959 const promptReasoning = new PromptReasoning();3959 const promptReasoning = new PromptReasoning();
3960 for (let i = coreChat.length - 1; i >= 0; i--) {3960 for (let i = coreChat.length - 1; i >= 0; i--) {
3961 const depth = coreChat.length - i - 1;3961 const depth = coreChat.length - i - 1;
3962 const isPrefix = isContinue && i === coreChat.length - 1;3962 const isPrefix = isContinue && i === coreChat.length - (isContinue ? 2 : 1);
3963 coreChat[i] = {3963 coreChat[i] = {
3964 ...coreChat[i],3964 ...coreChat[i],
3965 mes: promptReasoning.addToMessage(3965 mes: promptReasoning.addToMessage(
public/scripts/extensions/regex/editor.html+3 -3
@@ -110,14 +110,14 @@
110 </div>110 </div>
111 <div class="flex-container wide100p marginTop5">111 <div class="flex-container wide100p marginTop5">
112 <div class="flex1 flex-container flexNoGap">112 <div class="flex1 flex-container flexNoGap">
113 <small data-i18n="[title]ext_regex_min_depth_desc" title="When applied to prompts or display, only affect messages that are at least N levels deep. 0 = last message, 1 = penultimate message, etc. Only counts WI entries @Depth and usable messages, i.e. not hidden or system.">113 <small data-i18n="[title]ext_regex_min_depth_desc" title="When applied to prompts or display, only affect messages that are at least N levels deep. 0 = last message, 1 = penultimate message, etc. System prompt and utility prompts are not affected. When blank / 'Unlimited' or -1, also affect message to continue on Continue.">
114 <span data-i18n="Min Depth">Min Depth</span>114 <span data-i18n="Min Depth">Min Depth</span>
115 <span class="fa-solid fa-circle-question note-link-span"></span>115 <span class="fa-solid fa-circle-question note-link-span"></span>
116 </small>116 </small>
117 <input name="min_depth" class="text_pole textarea_compact" type="number" min="0" max="999" data-i18n="[placeholder]ext_regex_min_depth_placeholder" placeholder="Unlimited" />117 <input name="min_depth" class="text_pole textarea_compact" type="number" min="-1" max="999" data-i18n="[placeholder]ext_regex_min_depth_placeholder" placeholder="Unlimited" />
118 </div>118 </div>
119 <div class="flex1 flex-container flexNoGap">119 <div class="flex1 flex-container flexNoGap">
120 <small data-i18n="[title]ext_regex_max_depth_desc" title="When applied to prompts or display, only affect messages no more than N levels deep. 0 = last message, 1 = penultimate message, etc. Only counts WI entries @Depth and usable messages, i.e. not hidden or system.">120 <small data-i18n="[title]ext_regex_max_depth_desc" title="When applied to prompts or display, only affect messages no more than N levels deep. 0 = last message, 1 = penultimate message, etc. System prompt and utility prompts are not affected. Max must be greater than Min for regex to apply.">
121 <span data-i18n="Max Depth">Max Depth</span>121 <span data-i18n="Max Depth">Max Depth</span>
122 <span class="fa-solid fa-circle-question note-link-span"></span>122 <span class="fa-solid fa-circle-question note-link-span"></span>
123 </small>123 </small>
public/scripts/extensions/regex/engine.js+2 -2
@@ -103,8 +103,8 @@ function getRegexedString(rawString, placement, { characterOverride, isMarkdown,
103 }103 }
104104
105 // Check if the depth is within the min/max depth105 // Check if the depth is within the min/max depth
106 if (typeof depth === 'number' && depth >= 0) {106 if (typeof depth === 'number') {
107 if (!isNaN(script.minDepth) && script.minDepth !== null && script.minDepth >= 0 && depth < script.minDepth) {107 if (!isNaN(script.minDepth) && script.minDepth !== null && script.minDepth >= -1 && depth < script.minDepth) {
108 console.debug(`getRegexedString: Skipping script ${script.scriptName} because depth ${depth} is less than minDepth ${script.minDepth}`);108 console.debug(`getRegexedString: Skipping script ${script.scriptName} because depth ${depth} is less than minDepth ${script.minDepth}`);
109 return;109 return;
110 }110 }