Merge pull request #3395 from pcpthm/reasoning-continue Always add reasoning for continue
Signed| @@ -3863,10 +3863,8 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | ||
| 3863 | 3863 | |
| 3864 | 3864 | const reasoning = new PromptReasoning(); |
| 3865 | 3865 | for (let i = coreChat.length - 1; i >= 0; i--) { |
| 3866 | - if (reasoning.isLimitReached()) { | |
| 3867 | - break; | |
| 3868 | - } | |
| 3869 | 3866 | const depth = coreChat.length - i - 1; |
| 3867 | + const isPrefix = isContinue && i === coreChat.length - 1; | |
| 3870 | 3868 | coreChat[i] = { |
| 3871 | 3869 | ...coreChat[i], |
| 3872 | 3870 | mes: reasoning.addToMessage( |
| @@ -3876,8 +3874,12 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | ||
| 3876 | 3874 | regex_placement.REASONING, |
| 3877 | 3875 | { isPrompt: true, depth: depth }, |
| 3878 | 3876 | ), |
| 3877 | + isPrefix, | |
| 3879 | 3878 | ), |
| 3880 | 3879 | }; |
| 3880 | + if (reasoning.isLimitReached()) { | |
| 3881 | + break; | |
| 3882 | + } | |
| 3881 | 3883 | } |
| 3882 | 3884 | |
| 3883 | 3885 | // Determine token limit |
| @@ -50,11 +50,12 @@ export class PromptReasoning { | ||
| 50 | 50 | * Add reasoning to a message according to the power user settings. |
| 51 | 51 | * @param {string} content Message content |
| 52 | 52 | * @param {string} reasoning Message reasoning |
| 53 | + * @param {boolean} isPrefix Whether this is the last message prefix | |
| 53 | 54 | * @returns {string} Message content with reasoning |
| 54 | 55 | */ |
| 55 | 56 | addToMessage(content, reasoning, isPrefix) { |
| 56 | 57 | // Disabled or reached limit of additions |
| 57 | 58 | if (!isPrefix && (!power_user.reasoning.add_to_prompts || this.counter >= power_user.reasoning.max_additions)) { |
| 58 | 59 | return content; |
| 59 | 60 | } |
| 60 | 61 | |
| @@ -71,6 +72,11 @@ export class PromptReasoning { | ||
| 71 | 72 | const separator = substituteParams(power_user.reasoning.separator || ''); |
| 72 | 73 | const suffix = substituteParams(power_user.reasoning.suffix || ''); |
| 73 | 74 | |
| 75 | + // Combine parts with reasoning only | |
| 76 | + if (isPrefix && !content) { | |
| 77 | + return `${prefix}${reasoning}`; | |
| 78 | + } | |
| 79 | + | |
| 74 | 80 | // Combine parts with reasoning and content |
| 75 | 81 | return `${prefix}${reasoning}${suffix}${separator}${content}`; |
| 76 | 82 | } |
| @@ -221,7 +227,7 @@ function registerReasoningMacros() { | ||
| 221 | 227 | MacrosParser.registerMacro('reasoningSeparator', () => power_user.reasoning.separator, t`Reasoning Separator`); |
| 222 | 228 | } |
| 223 | 229 | |
| 224 | 230 | function setReasoningEventHandlers() { |
| 225 | 231 | $(document).on('click', '.mes_reasoning_copy', (e) => { |
| 226 | 232 | e.stopPropagation(); |
| 227 | 233 | e.preventDefault(); |