mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Early stopping if prompt reasoning limit reached
This commit is contained in:
@@ -3846,6 +3846,9 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
|||||||
|
|
||||||
const reasoning = new PromptReasoning();
|
const reasoning = new PromptReasoning();
|
||||||
for (let i = coreChat.length - 1; i >= 0; i--) {
|
for (let i = coreChat.length - 1; i >= 0; i--) {
|
||||||
|
if (reasoning.isLimitReached()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
coreChat[i] = { ...coreChat[i], mes: reasoning.addToMessage(coreChat[i].mes, coreChat[i].extra?.reasoning) };
|
coreChat[i] = { ...coreChat[i], mes: reasoning.addToMessage(coreChat[i].mes, coreChat[i].extra?.reasoning) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1431,6 +1431,18 @@ export class PromptReasoning {
|
|||||||
this.counter = 0;
|
this.counter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the limit of reasoning additions has been reached.
|
||||||
|
* @returns {boolean} True if the limit of reasoning additions has been reached, false otherwise.
|
||||||
|
*/
|
||||||
|
isLimitReached() {
|
||||||
|
if (!power_user.reasoning.add_to_prompts) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.counter >= power_user.reasoning.max_additions;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add reasoning to a message according to the power user settings.
|
* Add reasoning to a message according to the power user settings.
|
||||||
* @param {string} content Message content
|
* @param {string} content Message content
|
||||||
|
Reference in New Issue
Block a user