Move stop strings post-processing up

This commit is contained in:
Cohee
2023-11-06 19:19:34 +02:00
parent 0effbebae7
commit 1a3f100018

View File

@ -4068,6 +4068,19 @@ function cleanUpMessage(getMessage, isImpersonate, isContinue, displayIncomplete
getMessage = substituteParams(power_user.user_prompt_bias) + getMessage; getMessage = substituteParams(power_user.user_prompt_bias) + getMessage;
} }
const stoppingStrings = getStoppingStrings(isImpersonate);
for (const stoppingString of stoppingStrings) {
if (stoppingString.length) {
for (let j = stoppingString.length - 1; j > 0; j--) {
if (getMessage.slice(-j) === stoppingString.slice(0, j)) {
getMessage = getMessage.slice(0, -j);
break;
}
}
}
}
// Regex uses vars, so add before formatting // Regex uses vars, so add before formatting
getMessage = getRegexedString(getMessage, isImpersonate ? regex_placement.USER_INPUT : regex_placement.AI_OUTPUT); getMessage = getRegexedString(getMessage, isImpersonate ? regex_placement.USER_INPUT : regex_placement.AI_OUTPUT);
@ -4155,18 +4168,6 @@ function cleanUpMessage(getMessage, isImpersonate, isContinue, displayIncomplete
getMessage = getMessage.trim(); getMessage = getMessage.trim();
} }
const stoppingStrings = getStoppingStrings(isImpersonate);
for (const stoppingString of stoppingStrings) {
if (stoppingString.length) {
for (let j = stoppingString.length - 1; j > 0; j--) {
if (getMessage.slice(-j) === stoppingString.slice(0, j)) {
getMessage = getMessage.slice(0, -j);
break;
}
}
}
}
if (power_user.auto_fix_generated_markdown) { if (power_user.auto_fix_generated_markdown) {
getMessage = fixMarkdown(getMessage, false); getMessage = fixMarkdown(getMessage, false);
} }