mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
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>
This commit is contained in:
@ -3940,7 +3940,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
|||||||
coreChat = await Promise.all(coreChat.map(async (chatItem, index) => {
|
coreChat = await Promise.all(coreChat.map(async (chatItem, index) => {
|
||||||
let message = chatItem.mes;
|
let message = chatItem.mes;
|
||||||
let regexType = chatItem.is_user ? regex_placement.USER_INPUT : regex_placement.AI_OUTPUT;
|
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);
|
let regexedMessage = getRegexedString(message, regexType, options);
|
||||||
regexedMessage = await appendFileContent(chatItem, regexedMessage);
|
regexedMessage = await appendFileContent(chatItem, regexedMessage);
|
||||||
@ -3959,7 +3959,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
|||||||
const promptReasoning = new PromptReasoning();
|
const promptReasoning = new PromptReasoning();
|
||||||
for (let i = coreChat.length - 1; i >= 0; i--) {
|
for (let i = coreChat.length - 1; i >= 0; i--) {
|
||||||
const depth = coreChat.length - i - 1;
|
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] = {
|
||||||
...coreChat[i],
|
...coreChat[i],
|
||||||
mes: promptReasoning.addToMessage(
|
mes: promptReasoning.addToMessage(
|
||||||
|
@ -110,14 +110,14 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex-container wide100p marginTop5">
|
<div class="flex-container wide100p marginTop5">
|
||||||
<div class="flex1 flex-container flexNoGap">
|
<div class="flex1 flex-container flexNoGap">
|
||||||
<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.">
|
<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.">
|
||||||
<span data-i18n="Min Depth">Min Depth</span>
|
<span data-i18n="Min Depth">Min Depth</span>
|
||||||
<span class="fa-solid fa-circle-question note-link-span"></span>
|
<span class="fa-solid fa-circle-question note-link-span"></span>
|
||||||
</small>
|
</small>
|
||||||
<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" />
|
<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" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex1 flex-container flexNoGap">
|
<div class="flex1 flex-container flexNoGap">
|
||||||
<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.">
|
<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.">
|
||||||
<span data-i18n="Max Depth">Max Depth</span>
|
<span data-i18n="Max Depth">Max Depth</span>
|
||||||
<span class="fa-solid fa-circle-question note-link-span"></span>
|
<span class="fa-solid fa-circle-question note-link-span"></span>
|
||||||
</small>
|
</small>
|
||||||
|
@ -103,8 +103,8 @@ function getRegexedString(rawString, placement, { characterOverride, isMarkdown,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if the depth is within the min/max depth
|
// Check if the depth is within the min/max depth
|
||||||
if (typeof depth === 'number' && depth >= 0) {
|
if (typeof depth === 'number') {
|
||||||
if (!isNaN(script.minDepth) && script.minDepth !== null && script.minDepth >= 0 && depth < script.minDepth) {
|
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}`);
|
console.debug(`getRegexedString: Skipping script ${script.scriptName} because depth ${depth} is less than minDepth ${script.minDepth}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -139,7 +139,7 @@ function runRegexScript(regexScript, rawString, { characterOverride } = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getRegexString = () => {
|
const getRegexString = () => {
|
||||||
switch(Number(regexScript.substituteRegex)) {
|
switch (Number(regexScript.substituteRegex)) {
|
||||||
case substitute_find_regex.NONE:
|
case substitute_find_regex.NONE:
|
||||||
return regexScript.findRegex;
|
return regexScript.findRegex;
|
||||||
case substitute_find_regex.RAW:
|
case substitute_find_regex.RAW:
|
||||||
|
Reference in New Issue
Block a user