Early stopping if prompt reasoning limit reached

8fc880b69b88667f8120266669369dad2921e73e

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

2 files changed, +15 -0Ignore whitespace
public/script.js+3 -0
@@ -3846,6 +3846,9 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
38463846
3847 const reasoning = new PromptReasoning();3847 const reasoning = new PromptReasoning();
3848 for (let i = coreChat.length - 1; i >= 0; i--) {3848 for (let i = coreChat.length - 1; i >= 0; i--) {
3849 if (reasoning.isLimitReached()) {
3850 break;
3851 }
3849 coreChat[i] = { ...coreChat[i], mes: reasoning.addToMessage(coreChat[i].mes, coreChat[i].extra?.reasoning) };3852 coreChat[i] = { ...coreChat[i], mes: reasoning.addToMessage(coreChat[i].mes, coreChat[i].extra?.reasoning) };
3850 }3853 }
38513854
public/scripts/chats.js+12 -0
@@ -1432,6 +1432,18 @@ export class PromptReasoning {
1432 }1432 }
14331433
1434 /**1434 /**
1435 * Checks if the limit of reasoning additions has been reached.
1436 * @returns {boolean} True if the limit of reasoning additions has been reached, false otherwise.
1437 */
1438 isLimitReached() {
1439 if (!power_user.reasoning.add_to_prompts) {
1440 return true;
1441 }
1442
1443 return this.counter >= power_user.reasoning.max_additions;
1444 }
1445
1446 /**
1435 * Add reasoning to a message according to the power user settings.1447 * Add reasoning to a message according to the power user settings.
1436 * @param {string} content Message content1448 * @param {string} content Message content
1437 * @param {string} reasoning Message reasoning1449 * @param {string} reasoning Message reasoning