mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Implement Behavior for Max Recursion Depth
This commit is contained in:
@ -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_depth = 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_depth,
|
||||
};
|
||||
}
|
||||
|
||||
@ -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_depth !== undefined)
|
||||
world_info_max_recursion_depth = Number(settings.world_info_max_recursion_depth);
|
||||
|
||||
// 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_depth').val(world_info_max_recursion_depth);
|
||||
$('#world_info_max_recursion_depth_counter').val(world_info_max_recursion_depth);
|
||||
|
||||
world_names = data.world_names?.length ? data.world_names : [];
|
||||
|
||||
// Add to existing selected WI if it exists
|
||||
@ -3723,6 +3730,10 @@ export async function checkWorldInfo(chat, maxContext, isDryRun) {
|
||||
console.debug(`[WI] --- SEARCHING ENTRIES (on ${sortedEntries.length} entries) ---`);
|
||||
|
||||
while (scanState) {
|
||||
if (world_info_max_recursion_depth && world_info_max_recursion_depth <= count) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Track how many times the loop has run. May be useful for debugging.
|
||||
count++;
|
||||
|
||||
@ -4819,6 +4830,12 @@ jQuery(() => {
|
||||
saveSettings();
|
||||
});
|
||||
|
||||
$('#world_info_max_recursion_depth').on('input', function () {
|
||||
world_info_max_recursion_depth = Number($(this).val());
|
||||
$('#world_info_max_recursion_depth_counter').val($(this).val());
|
||||
saveSettings();
|
||||
});
|
||||
|
||||
$('#world_button').on('click', async function (event) {
|
||||
const chid = $('#set_character_world').data('chid');
|
||||
|
||||
|
Reference in New Issue
Block a user