Always add reasoning for continue

9ecf261a76f989cfaaa4a79590f0162c7f3194d3

pcpthm <pcpthm@gmail.com>

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
3864 const reasoning = new PromptReasoning();3864 const reasoning = new PromptReasoning();
3865 for (let i = coreChat.length - 1; i >= 0; i--) {3865 for (let i = coreChat.length - 1; i >= 0; i--) {
3866 if (reasoning.isLimitReached()) {
3867 break;
3868 }
3869 const depth = coreChat.length - i - 1;3866 const depth = coreChat.length - i - 1;
3867 const isPrefix = isContinue && i === coreChat.length - 1;
3870 coreChat[i] = {3868 coreChat[i] = {
3871 ...coreChat[i],3869 ...coreChat[i],
3872 mes: reasoning.addToMessage(3870 mes: reasoning.addToMessage(
@@ -3876,8 +3874,12 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
3876 regex_placement.REASONING,3874 regex_placement.REASONING,
3877 { isPrompt: true, depth: depth },3875 { isPrompt: true, depth: depth },
3878 ),3876 ),
3877 isPrefix,
3879 ),3878 ),
3880 };3879 };
3880 if (reasoning.isLimitReached()) {
3881 break;
3882 }
3881 }3883 }
38823884
3883 // Determine token limit3885 // Determine token limit
public/scripts/reasoning.js+9 -3
@@ -50,11 +50,12 @@ export class PromptReasoning {
50 * Add reasoning to a message according to the power user settings.50 * Add reasoning to a message according to the power user settings.
51 * @param {string} content Message content51 * @param {string} content Message content
52 * @param {string} reasoning Message reasoning52 * @param {string} reasoning Message reasoning
53 * @param {boolean} isPrefix Whether this is the last message prefix
53 * @returns {string} Message content with reasoning54 * @returns {string} Message content with reasoning
54 */55 */
55 addToMessage(content, reasoning) {56 addToMessage(content, reasoning, isPrefix) {
56 // Disabled or reached limit of additions57 // Disabled or reached limit of additions
57 if (!power_user.reasoning.add_to_prompts || this.counter >= power_user.reasoning.max_additions) {58 if (!isPrefix && (!power_user.reasoning.add_to_prompts || this.counter >= power_user.reasoning.max_additions)) {
58 return content;59 return content;
59 }60 }
6061
@@ -71,6 +72,11 @@ export class PromptReasoning {
71 const separator = substituteParams(power_user.reasoning.separator || '');72 const separator = substituteParams(power_user.reasoning.separator || '');
72 const suffix = substituteParams(power_user.reasoning.suffix || '');73 const suffix = substituteParams(power_user.reasoning.suffix || '');
7374
75 // Combine parts with reasoning only
76 if (isPrefix && !content) {
77 return `${prefix}${reasoning}`;
78 }
79
74 // Combine parts with reasoning and content80 // Combine parts with reasoning and content
75 return `${prefix}${reasoning}${suffix}${separator}${content}`;81 return `${prefix}${reasoning}${suffix}${separator}${content}`;
76 }82 }
@@ -218,7 +224,7 @@ function registerReasoningMacros() {
218 MacrosParser.registerMacro('reasoningSeparator', () => power_user.reasoning.separator, t`Reasoning Separator`);224 MacrosParser.registerMacro('reasoningSeparator', () => power_user.reasoning.separator, t`Reasoning Separator`);
219}225}
220226
221function setReasoningEventHandlers(){227function setReasoningEventHandlers() {
222 $(document).on('click', '.mes_reasoning_copy', (e) => {228 $(document).on('click', '.mes_reasoning_copy', (e) => {
223 e.stopPropagation();229 e.stopPropagation();
224 e.preventDefault();230 e.preventDefault();