Always add reasoning for continue

This commit is contained in:
pcpthm 2025-01-31 21:06:15 +09:00
parent dfc2eb32c8
commit 9ecf261a76
2 changed files with 14 additions and 6 deletions

View File

@ -3863,10 +3863,8 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
const reasoning = new PromptReasoning(); const reasoning = new PromptReasoning();
for (let i = coreChat.length - 1; i >= 0; i--) { for (let i = coreChat.length - 1; i >= 0; i--) {
if (reasoning.isLimitReached()) {
break;
}
const depth = coreChat.length - i - 1; const depth = coreChat.length - i - 1;
const isPrefix = isContinue && i === coreChat.length - 1;
coreChat[i] = { coreChat[i] = {
...coreChat[i], ...coreChat[i],
mes: reasoning.addToMessage( mes: reasoning.addToMessage(
@ -3876,8 +3874,12 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
regex_placement.REASONING, regex_placement.REASONING,
{ isPrompt: true, depth: depth }, { isPrompt: true, depth: depth },
), ),
isPrefix,
), ),
}; };
if (reasoning.isLimitReached()) {
break;
}
} }
// Determine token limit // Determine token limit

View File

@ -50,11 +50,12 @@ export class PromptReasoning {
* Add reasoning to a message according to the power user settings. * Add reasoning to a message according to the power user settings.
* @param {string} content Message content * @param {string} content Message content
* @param {string} reasoning Message reasoning * @param {string} reasoning Message reasoning
* @param {boolean} isPrefix Whether this is the last message prefix
* @returns {string} Message content with reasoning * @returns {string} Message content with reasoning
*/ */
addToMessage(content, reasoning) { addToMessage(content, reasoning, isPrefix) {
// Disabled or reached limit of additions // Disabled or reached limit of additions
if (!power_user.reasoning.add_to_prompts || this.counter >= power_user.reasoning.max_additions) { if (!isPrefix && (!power_user.reasoning.add_to_prompts || this.counter >= power_user.reasoning.max_additions)) {
return content; return content;
} }
@ -71,6 +72,11 @@ export class PromptReasoning {
const separator = substituteParams(power_user.reasoning.separator || ''); const separator = substituteParams(power_user.reasoning.separator || '');
const suffix = substituteParams(power_user.reasoning.suffix || ''); const suffix = substituteParams(power_user.reasoning.suffix || '');
// Combine parts with reasoning only
if (isPrefix && !content) {
return `${prefix}${reasoning}`;
}
// Combine parts with reasoning and content // Combine parts with reasoning and content
return `${prefix}${reasoning}${suffix}${separator}${content}`; return `${prefix}${reasoning}${suffix}${separator}${content}`;
} }
@ -218,7 +224,7 @@ function registerReasoningMacros() {
MacrosParser.registerMacro('reasoningSeparator', () => power_user.reasoning.separator, t`Reasoning Separator`); MacrosParser.registerMacro('reasoningSeparator', () => power_user.reasoning.separator, t`Reasoning Separator`);
} }
function setReasoningEventHandlers(){ function setReasoningEventHandlers() {
$(document).on('click', '.mes_reasoning_copy', (e) => { $(document).on('click', '.mes_reasoning_copy', (e) => {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();