World Info Min Activations: added UI & persistence & budget respect
This commit is contained in:
parent
8203ebb835
commit
77bde48a48
|
@ -2713,6 +2713,44 @@
|
||||||
<small data-i18n="(0 = disabled)">(0 = disabled)</small>
|
<small data-i18n="(0 = disabled)">(0 = disabled)</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div data-newbie-hidden class="flex1 gap5px range-block">
|
||||||
|
<div class="wide10pMinFit">
|
||||||
|
<small data-i18n="Min Activations">Min Activations</small>
|
||||||
|
</div>
|
||||||
|
<div class="range-block-range-and-counter">
|
||||||
|
<div class="range-block-range paddingLeftRight5">
|
||||||
|
<input type="range" id="world_info_min_activations" name="volume" min="0" max="100" step="1">
|
||||||
|
</div>
|
||||||
|
<div class="range-block-counter margin0">
|
||||||
|
<input type="number" data-for="world_info_min_activations" id="world_info_min_activations_counter">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="budget_cap_note">
|
||||||
|
<small data-i18n="(0 = disabled) scan chronologically until min entries or token budget filled">(0 = disabled) scan chronologically until min entries or token budget filled</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div data-newbie-hidden class="flex1 gap5px range-block">
|
||||||
|
<div class="wide10pMinFit">
|
||||||
|
<small data-i18n="Min Activations: Max Depth">Min Activations: Max Depth</small>
|
||||||
|
</div>
|
||||||
|
<div class="range-block-range-and-counter">
|
||||||
|
<div class="range-block-range paddingLeftRight5">
|
||||||
|
<input type="range" id="world_info_min_activations_depth_max" name="volume" min="0" max="100" step="1">
|
||||||
|
</div>
|
||||||
|
<div class="range-block-counter margin0">
|
||||||
|
<input type="number" data-for="world_info_min_activations_depth_max" id="world_info_min_activations_depth_max_counter">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="budget_cap_note">
|
||||||
|
<small data-i18n="(0 = chronological scan depth unlimited, token budget recommended if min is high)">(0 = chronological scan depth unlimited, token budget recommended if min is high)</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ export {
|
||||||
world_info,
|
world_info,
|
||||||
world_info_budget,
|
world_info_budget,
|
||||||
world_info_depth,
|
world_info_depth,
|
||||||
|
world_info_min_activations,
|
||||||
|
world_info_min_activations_depth_max,
|
||||||
world_info_recursive,
|
world_info_recursive,
|
||||||
world_info_overflow_alert,
|
world_info_overflow_alert,
|
||||||
world_info_case_sensitive,
|
world_info_case_sensitive,
|
||||||
|
@ -66,6 +68,8 @@ export function getWorldInfoSettings() {
|
||||||
return {
|
return {
|
||||||
world_info,
|
world_info,
|
||||||
world_info_depth,
|
world_info_depth,
|
||||||
|
world_info_min_activations,
|
||||||
|
world_info_min_activations_depth_max,
|
||||||
world_info_budget,
|
world_info_budget,
|
||||||
world_info_recursive,
|
world_info_recursive,
|
||||||
world_info_overflow_alert,
|
world_info_overflow_alert,
|
||||||
|
@ -105,6 +109,10 @@ async function getWorldInfoPrompt(chat2, maxContext) {
|
||||||
function setWorldInfoSettings(settings, data) {
|
function setWorldInfoSettings(settings, data) {
|
||||||
if (settings.world_info_depth !== undefined)
|
if (settings.world_info_depth !== undefined)
|
||||||
world_info_depth = Number(settings.world_info_depth);
|
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)
|
if (settings.world_info_budget !== undefined)
|
||||||
world_info_budget = Number(settings.world_info_budget);
|
world_info_budget = Number(settings.world_info_budget);
|
||||||
if (settings.world_info_recursive !== undefined)
|
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_counter").val(world_info_depth);
|
||||||
$("#world_info_depth").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_counter").val(world_info_budget);
|
||||||
$("#world_info_budget").val(world_info_budget);
|
$("#world_info_budget").val(world_info_budget);
|
||||||
|
|
||||||
|
@ -1406,6 +1420,7 @@ async function checkWorldInfo(chat, maxContext) {
|
||||||
textToScan = transformString(textToScan);
|
textToScan = transformString(textToScan);
|
||||||
|
|
||||||
let needsToScan = true;
|
let needsToScan = true;
|
||||||
|
let token_budget_overflowed = false;
|
||||||
let count = 0;
|
let count = 0;
|
||||||
let allActivatedEntries = new Set();
|
let allActivatedEntries = new Set();
|
||||||
let failedProbabilityChecks = 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');
|
toastr.warning(`World info budget reached after ${allActivatedEntries.size} entries.`, 'World Info');
|
||||||
}
|
}
|
||||||
needsToScan = false;
|
needsToScan = false;
|
||||||
|
token_budget_overflowed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1559,9 +1575,16 @@ async function checkWorldInfo(chat, maxContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// world_info_min_activations
|
// world_info_min_activations
|
||||||
if (!needsToScan) {
|
if (!needsToScan && !token_budget_overflowed) {
|
||||||
if (world_info_min_activations > 0 && (allActivatedEntries.size < world_info_min_activations)) {
|
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
|
needsToScan = true
|
||||||
textToScan = transformString(chat.slice(minActivationMsgIndex, minActivationMsgIndex + 1).join(""));
|
textToScan = transformString(chat.slice(minActivationMsgIndex, minActivationMsgIndex + 1).join(""));
|
||||||
minActivationMsgIndex += 1
|
minActivationMsgIndex += 1
|
||||||
|
@ -2063,6 +2086,18 @@ jQuery(() => {
|
||||||
saveSettings();
|
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 () {
|
$(document).on("input", "#world_info_budget", function () {
|
||||||
world_info_budget = Number($(this).val());
|
world_info_budget = Number($(this).val());
|
||||||
$("#world_info_budget_counter").val($(this).val());
|
$("#world_info_budget_counter").val($(this).val());
|
||||||
|
|
Loading…
Reference in New Issue