WI delay until recursion levels
This commit is contained in:
parent
d08f964c2d
commit
609439def1
|
@ -3696,6 +3696,7 @@ export async function checkWorldInfo(chat, maxContext, isDryRun) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @type {scan_state} */
|
||||||
let scanState = scan_state.INITIAL;
|
let scanState = scan_state.INITIAL;
|
||||||
let token_budget_overflowed = false;
|
let token_budget_overflowed = false;
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
@ -3720,6 +3721,14 @@ export async function checkWorldInfo(chat, maxContext, isDryRun) {
|
||||||
return { worldInfoBefore: '', worldInfoAfter: '', WIDepthEntries: [], EMEntries: [], allActivatedEntries: new Set() };
|
return { worldInfoBefore: '', worldInfoAfter: '', WIDepthEntries: [], EMEntries: [], allActivatedEntries: new Set() };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @type {number[]} Represents the delay levels for entries that are delayed until recursion */
|
||||||
|
const availableRecursionDelayLevels = [...new Set(sortedEntries
|
||||||
|
.filter(entry => entry.delayUntilRecursion)
|
||||||
|
.map(entry => entry.delayUntilRecursion === true ? 1 : entry.delayUntilRecursion)
|
||||||
|
)].sort((a, b) => a - b);
|
||||||
|
// Already preset with the first level
|
||||||
|
let currentRecursionDelayLevel = availableRecursionDelayLevels.shift() ?? 0;
|
||||||
|
|
||||||
console.debug(`[WI] --- SEARCHING ENTRIES (on ${sortedEntries.length} entries) ---`);
|
console.debug(`[WI] --- SEARCHING ENTRIES (on ${sortedEntries.length} entries) ---`);
|
||||||
|
|
||||||
while (scanState) {
|
while (scanState) {
|
||||||
|
@ -3811,6 +3820,11 @@ export async function checkWorldInfo(chat, maxContext, isDryRun) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (scanState === scan_state.RECURSION && entry.delayUntilRecursion && entry.delayUntilRecursion > currentRecursionDelayLevel && !isSticky) {
|
||||||
|
log('suppressed by delay until recursion and having a higher recursion level');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (scanState === scan_state.RECURSION && world_info_recursive && entry.excludeRecursion && !isSticky) {
|
if (scanState === scan_state.RECURSION && world_info_recursive && entry.excludeRecursion && !isSticky) {
|
||||||
log('suppressed by exclude recursion');
|
log('suppressed by exclude recursion');
|
||||||
continue;
|
continue;
|
||||||
|
@ -4039,6 +4053,11 @@ export async function checkWorldInfo(chat, maxContext, isDryRun) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the scan is done, but we still have open "delay until recursion" levels, we should continue with the next one
|
||||||
|
if (nextScanState === scan_state.NONE && availableRecursionDelayLevels.length) {
|
||||||
|
currentRecursionDelayLevel = availableRecursionDelayLevels.shift();
|
||||||
|
}
|
||||||
|
|
||||||
// Final check if we should really continue scan, and extend the current WI recurse buffer
|
// Final check if we should really continue scan, and extend the current WI recurse buffer
|
||||||
scanState = nextScanState;
|
scanState = nextScanState;
|
||||||
if (scanState) {
|
if (scanState) {
|
||||||
|
|
Loading…
Reference in New Issue