Merge pull request #3395 from pcpthm/reasoning-continue Always add reasoning for continue

9243a68b183c0c796fa09f3adf6948f9dd16f618

Cohee <18619528+Cohee1207@users.noreply.github.com>

Signed
2 files changed, +14 -6Ignore whitespace
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+9 -3
@@ -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 }
@@ -221,7 +227,7 @@ function registerReasoningMacros() {
221227 MacrosParser.registerMacro('reasoningSeparator', () => power_user.reasoning.separator, t`Reasoning Separator`);
222228}
223229
224230function setReasoningEventHandlers() {
225231 $(document).on('click', '.mes_reasoning_copy', (e) => {
226232 e.stopPropagation();
227233 e.preventDefault();