Always add reasoning for continue

9ecf261a76f989cfaaa4a79590f0162c7f3194d3

pcpthm <pcpthm@gmail.com>

2 files changed, +13 -5Showing whitespace changes
public/script.js+5 -3
@@ -3863,10 +3863,8 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
38633863
38643864 const reasoning = new PromptReasoning();
38653865 for (let i = coreChat.length - 1; i >= 0; i--) {
3866- if (reasoning.isLimitReached()) {
3867- break;
3868- }
38693866 const depth = coreChat.length - i - 1;
3867+ const isPrefix = isContinue && i === coreChat.length - 1;
38703868 coreChat[i] = {
38713869 ...coreChat[i],
38723870 mes: reasoning.addToMessage(
@@ -3876,8 +3874,12 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
38763874 regex_placement.REASONING,
38773875 { isPrompt: true, depth: depth },
38783876 ),
3877+ isPrefix,
38793878 ),
38803879 };
3880+ if (reasoning.isLimitReached()) {
3881+ break;
3882+ }
38813883 }
38823884
38833885 // Determine token limit
public/scripts/reasoning.js+8 -2
@@ -50,11 +50,12 @@ export class PromptReasoning {
5050 * Add reasoning to a message according to the power user settings.
5151 * @param {string} content Message content
5252 * @param {string} reasoning Message reasoning
53+ * @param {boolean} isPrefix Whether this is the last message prefix
5354 * @returns {string} Message content with reasoning
5455 */
5556 addToMessage(content, reasoning, isPrefix) {
5657 // Disabled or reached limit of additions
5758 if (!isPrefix && (!power_user.reasoning.add_to_prompts || this.counter >= power_user.reasoning.max_additions)) {
5859 return content;
5960 }
6061
@@ -71,6 +72,11 @@ export class PromptReasoning {
7172 const separator = substituteParams(power_user.reasoning.separator || '');
7273 const suffix = substituteParams(power_user.reasoning.suffix || '');
7374
75+ // Combine parts with reasoning only
76+ if (isPrefix && !content) {
77+ return `${prefix}${reasoning}`;
78+ }
79+
7480 // Combine parts with reasoning and content
7581 return `${prefix}${reasoning}${suffix}${separator}${content}`;
7682 }