mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
World Info Min Activations: added UI & persistence & budget respect
This commit is contained in:
@@ -12,6 +12,8 @@ export {
|
||||
world_info,
|
||||
world_info_budget,
|
||||
world_info_depth,
|
||||
world_info_min_activations,
|
||||
world_info_min_activations_depth_max,
|
||||
world_info_recursive,
|
||||
world_info_overflow_alert,
|
||||
world_info_case_sensitive,
|
||||
@@ -66,6 +68,8 @@ export function getWorldInfoSettings() {
|
||||
return {
|
||||
world_info,
|
||||
world_info_depth,
|
||||
world_info_min_activations,
|
||||
world_info_min_activations_depth_max,
|
||||
world_info_budget,
|
||||
world_info_recursive,
|
||||
world_info_overflow_alert,
|
||||
@@ -105,6 +109,10 @@ async function getWorldInfoPrompt(chat2, maxContext) {
|
||||
function setWorldInfoSettings(settings, data) {
|
||||
if (settings.world_info_depth !== undefined)
|
||||
world_info_depth = Number(settings.world_info_depth);
|
||||
if (settings.world_info_min_activations !== undefined)
|
||||
world_info_min_activations = Number(settings.world_info_min_activations);
|
||||
if (settings.world_info_min_activations_depth_max !== undefined)
|
||||
world_info_min_activations_depth_max = Number(settings.world_info_min_activations_depth_max);
|
||||
if (settings.world_info_budget !== undefined)
|
||||
world_info_budget = Number(settings.world_info_budget);
|
||||
if (settings.world_info_recursive !== undefined)
|
||||
@@ -141,6 +149,12 @@ function setWorldInfoSettings(settings, data) {
|
||||
$("#world_info_depth_counter").val(world_info_depth);
|
||||
$("#world_info_depth").val(world_info_depth);
|
||||
|
||||
$("#world_info_min_activations_counter").val(world_info_min_activations);
|
||||
$("#world_info_min_activations").val(world_info_min_activations);
|
||||
|
||||
$("#world_info_min_activations_depth_max_counter").val(world_info_min_activations_depth_max);
|
||||
$("#world_info_min_activations_depth_max").val(world_info_min_activations_depth_max);
|
||||
|
||||
$("#world_info_budget_counter").val(world_info_budget);
|
||||
$("#world_info_budget").val(world_info_budget);
|
||||
|
||||
@@ -1406,6 +1420,7 @@ async function checkWorldInfo(chat, maxContext) {
|
||||
textToScan = transformString(textToScan);
|
||||
|
||||
let needsToScan = true;
|
||||
let token_budget_overflowed = false;
|
||||
let count = 0;
|
||||
let allActivatedEntries = new Set();
|
||||
let failedProbabilityChecks = new Set();
|
||||
@@ -1535,6 +1550,7 @@ async function checkWorldInfo(chat, maxContext) {
|
||||
toastr.warning(`World info budget reached after ${allActivatedEntries.size} entries.`, 'World Info');
|
||||
}
|
||||
needsToScan = false;
|
||||
token_budget_overflowed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1559,9 +1575,16 @@ async function checkWorldInfo(chat, maxContext) {
|
||||
}
|
||||
|
||||
// world_info_min_activations
|
||||
if (!needsToScan) {
|
||||
if (!needsToScan && !token_budget_overflowed) {
|
||||
if (world_info_min_activations > 0 && (allActivatedEntries.size < world_info_min_activations)) {
|
||||
if (minActivationMsgIndex <= world_info_min_activations_depth_max) {
|
||||
let over_max = false
|
||||
over_max = (
|
||||
world_info_min_activations_depth_max > 0 &&
|
||||
minActivationMsgIndex > world_info_min_activations_depth_max
|
||||
) || (
|
||||
minActivationMsgIndex >= chat.length
|
||||
)
|
||||
if (!over_max) {
|
||||
needsToScan = true
|
||||
textToScan = transformString(chat.slice(minActivationMsgIndex, minActivationMsgIndex + 1).join(""));
|
||||
minActivationMsgIndex += 1
|
||||
@@ -2063,6 +2086,18 @@ jQuery(() => {
|
||||
saveSettings();
|
||||
});
|
||||
|
||||
$(document).on("input", "#world_info_min_activations", function () {
|
||||
world_info_min_activations = Number($(this).val());
|
||||
$("#world_info_min_activations_counter").val($(this).val());
|
||||
saveSettings();
|
||||
});
|
||||
|
||||
$(document).on("input", "#world_info_min_activations_depth_max", function () {
|
||||
world_info_min_activations_depth_max = Number($(this).val());
|
||||
$("#world_info_min_activations_depth_max_counter").val($(this).val());
|
||||
saveSettings();
|
||||
});
|
||||
|
||||
$(document).on("input", "#world_info_budget", function () {
|
||||
world_info_budget = Number($(this).val());
|
||||
$("#world_info_budget_counter").val($(this).val());
|
||||
|
Reference in New Issue
Block a user