mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fix min activations not checking recursion
This commit is contained in:
@@ -299,6 +299,14 @@ class WorldInfoBuffer {
|
|||||||
this.#injectBuffer.push(message);
|
this.#injectBuffer.push(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the recursion buffer is not empty.
|
||||||
|
* @returns {boolean} Returns true if the recursion buffer is not empty, otherwise false
|
||||||
|
*/
|
||||||
|
hasRecurse() {
|
||||||
|
return this.#recurseBuffer.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increments skew and sets startDepth to previous depth.
|
* Increments skew and sets startDepth to previous depth.
|
||||||
*/
|
*/
|
||||||
@@ -3847,11 +3855,17 @@ async function checkWorldInfo(chat, maxContext, isDryRun) {
|
|||||||
console.debug(`[WI] Sucessfully activated ${successfulNewEntries.length} new entries to prompt. ${allActivatedEntries.size} total entries activated.`, successfulNewEntries);
|
console.debug(`[WI] Sucessfully activated ${successfulNewEntries.length} new entries to prompt. ${allActivatedEntries.size} total entries activated.`, successfulNewEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
// After processing and rolling entries is done, see if we should continue with recursion
|
// After processing and rolling entries is done, see if we should continue with normal recursion
|
||||||
if (world_info_recursive && !token_budget_overflowed && successfulNewEntriesForRecursion.length) {
|
if (world_info_recursive && !token_budget_overflowed && successfulNewEntriesForRecursion.length) {
|
||||||
nextScanState = scan_state.RECURSION;
|
nextScanState = scan_state.RECURSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we are inside min activations scan, and we have recursive buffer, we should do a recursive scan before increasing the buffer again
|
||||||
|
// There might be recurse-trigger-able entries that match the buffer, so we need to check that
|
||||||
|
if (world_info_recursive && !token_budget_overflowed && scanState === scan_state.MIN_ACTIVATIONS && buffer.hasRecurse()) {
|
||||||
|
nextScanState = scan_state.RECURSION;
|
||||||
|
}
|
||||||
|
|
||||||
// If scanning is planned to stop, but min activations is set and not satisfied, check if we should continue
|
// If scanning is planned to stop, but min activations is set and not satisfied, check if we should continue
|
||||||
const minActivationsNotSatisfied = world_info_min_activations > 0 && (allActivatedEntries.size < world_info_min_activations);
|
const minActivationsNotSatisfied = world_info_min_activations > 0 && (allActivatedEntries.size < world_info_min_activations);
|
||||||
if (!nextScanState && !token_budget_overflowed && minActivationsNotSatisfied) {
|
if (!nextScanState && !token_budget_overflowed && minActivationsNotSatisfied) {
|
||||||
|
Reference in New Issue
Block a user