mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-10 09:00:14 +01:00
Implements max recursion depth for lorebooks (#2698)
* Include slider for Max Recursion Depth * Implement Behavior for Max Recursion Depth * Title message correction * Disabling min activations when max recursion depth is disabled and vice versa * Feature renamed to Max Recursion Steps * Added warnings that min activations and max recursion steps disable each other * Revert "Added warnings that min activations and max recursion steps disable each other" This reverts commit 8c7efd09c5d126372edd529f9537611fec4b59df. * Revert "Feature renamed to Max Recursion Steps" This reverts commit f043fe6b60693339a8270f148a7cb98f252ea592. * Revert "Disabling min activations when max recursion depth is disabled and vice versa" This reverts commit a3a28874bf16a8ee4162c2036efbdae736b076b5. * Renames the feature to Max Recursion Steps and disables it when Min Activations are enabled * Combine info-warnings, log stop condition --------- Co-authored-by: Your Name <you@example.com> Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
This commit is contained in:
parent
3f026aea15
commit
a276dbdd44
@ -3622,6 +3622,7 @@
|
||||
<div class="alignitemscenter flex-container flexFlowColumn flexGrow flexShrink gap0 flexBasis48p" title="Scan chronologically until reached min entries or token budget." data-i18n="[title]Scan chronologically until reached min entries or token budget.">
|
||||
<small>
|
||||
<span data-i18n="Min Activations">Min Activations</span>
|
||||
<div class="fa-solid fa-triangle-exclamation opacity50p" data-i18n="[title](disabled when max recursion steps are used)" title="(disabled when max recursion steps are used)"></div>
|
||||
</small>
|
||||
<input class="neo-range-slider" type="range" id="world_info_min_activations" name="world_info_min_activations" min="0" max="100" step="1">
|
||||
<input class="neo-range-input" type="number" min="0" max="100" step="1" data-for="world_info_min_activations" id="world_info_min_activations_counter">
|
||||
@ -3635,6 +3636,14 @@
|
||||
<input class="neo-range-slider" type="range" id="world_info_min_activations_depth_max" name="volume" min="0" max="100" step="1">
|
||||
<input class="neo-range-input" type="number" min="0" max="100" step="1" data-for="world_info_min_activations_depth_max" id="world_info_min_activations_depth_max_counter">
|
||||
</div>
|
||||
<div class="alignitemscenter flex-container flexFlowColumn flexGrow flexShrink gap0 flexBasis48p" title="Cap the number of entry activation recursions" data-i18n="[title]Cap the number of entry activation recursions">
|
||||
<small>
|
||||
<span data-i18n="Max Recursion Steps">Max Recursion Steps</span>
|
||||
<div class="fa-solid fa-triangle-exclamation opacity50p" data-i18n="[title]0 = unlimited, 1 = scans once and doesn't recurse, 2 = scans once and recurses once, etc\n(disabled when min activations are used)" title="0 = unlimited, 1 = scans once and doesn't recurse, 2 = scans once and recurses once, etc (disabled when min activations are used)"></div>
|
||||
</small>
|
||||
<input class="neo-range-slider" type="range" id="world_info_max_recursion_steps" name="world_info_max_recursion_steps" min="0" max="10" step="1">
|
||||
<input class="neo-range-input" type="number" min="0" max="10" step="1" data-for="world_info_max_recursion_steps" id="world_info_max_recursion_steps_counter">
|
||||
</div>
|
||||
|
||||
<div class="alignitemscenter flex-container flexFlowColumn flexGrow flexShrink flexBasis48p">
|
||||
<small data-i18n="Insertion Strategy">
|
||||
|
@ -73,6 +73,7 @@ export let world_info_match_whole_words = false;
|
||||
export let world_info_use_group_scoring = false;
|
||||
export let world_info_character_strategy = world_info_insertion_strategy.character_first;
|
||||
export let world_info_budget_cap = 0;
|
||||
export let world_info_max_recursion_steps = 0;
|
||||
const saveWorldDebounced = debounce(async (name, data) => await _save(name, data), debounce_timeout.relaxed);
|
||||
const saveSettingsDebounced = debounce(() => {
|
||||
Object.assign(world_info, { globalSelect: selected_world_info });
|
||||
@ -710,6 +711,7 @@ export function getWorldInfoSettings() {
|
||||
world_info_character_strategy,
|
||||
world_info_budget_cap,
|
||||
world_info_use_group_scoring,
|
||||
world_info_max_recursion_steps,
|
||||
};
|
||||
}
|
||||
|
||||
@ -796,6 +798,8 @@ export function setWorldInfoSettings(settings, data) {
|
||||
world_info_budget_cap = Number(settings.world_info_budget_cap);
|
||||
if (settings.world_info_use_group_scoring !== undefined)
|
||||
world_info_use_group_scoring = Boolean(settings.world_info_use_group_scoring);
|
||||
if (settings.world_info_max_recursion_steps !== undefined)
|
||||
world_info_max_recursion_steps = Number(settings.world_info_max_recursion_steps);
|
||||
|
||||
// Migrate old settings
|
||||
if (world_info_budget > 100) {
|
||||
@ -844,6 +848,9 @@ export function setWorldInfoSettings(settings, data) {
|
||||
$('#world_info_budget_cap').val(world_info_budget_cap);
|
||||
$('#world_info_budget_cap_counter').val(world_info_budget_cap);
|
||||
|
||||
$('#world_info_max_recursion_steps').val(world_info_max_recursion_steps);
|
||||
$('#world_info_max_recursion_steps_counter').val(world_info_max_recursion_steps);
|
||||
|
||||
world_names = data.world_names?.length ? data.world_names : [];
|
||||
|
||||
// Add to existing selected WI if it exists
|
||||
@ -3723,6 +3730,12 @@ export async function checkWorldInfo(chat, maxContext, isDryRun) {
|
||||
console.debug(`[WI] --- SEARCHING ENTRIES (on ${sortedEntries.length} entries) ---`);
|
||||
|
||||
while (scanState) {
|
||||
//if world_info_max_recursion_steps is non-zero min activations are disabled, and vice versa
|
||||
if (world_info_max_recursion_steps && world_info_max_recursion_steps <= count) {
|
||||
console.debug('[WI] Search stopped by reaching max recursion steps', world_info_max_recursion_steps);
|
||||
break;
|
||||
}
|
||||
|
||||
// Track how many times the loop has run. May be useful for debugging.
|
||||
count++;
|
||||
|
||||
@ -4762,8 +4775,13 @@ jQuery(() => {
|
||||
|
||||
$('#world_info_min_activations').on('input', function () {
|
||||
world_info_min_activations = Number($(this).val());
|
||||
$('#world_info_min_activations_counter').val($(this).val());
|
||||
saveSettings();
|
||||
$('#world_info_min_activations_counter').val(world_info_min_activations);
|
||||
|
||||
if (world_info_min_activations !== 0) {
|
||||
$('#world_info_max_recursion_steps').val(0).trigger('input');
|
||||
} else {
|
||||
saveSettings();
|
||||
}
|
||||
});
|
||||
|
||||
$('#world_info_min_activations_depth_max').on('input', function () {
|
||||
@ -4819,6 +4837,16 @@ jQuery(() => {
|
||||
saveSettings();
|
||||
});
|
||||
|
||||
$('#world_info_max_recursion_steps').on('input', function () {
|
||||
world_info_max_recursion_steps = Number($(this).val());
|
||||
$('#world_info_max_recursion_steps_counter').val(world_info_max_recursion_steps);
|
||||
if (world_info_max_recursion_steps !== 0) {
|
||||
$('#world_info_min_activations').val(0).trigger('input');
|
||||
} else {
|
||||
saveSettings();
|
||||
}
|
||||
});
|
||||
|
||||
$('#world_button').on('click', async function (event) {
|
||||
const chid = $('#set_character_world').data('chid');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user