Add WI toggle to include/exclude names in scanning
This commit is contained in:
parent
13630c896a
commit
ff23808d3b
|
@ -13,6 +13,7 @@
|
|||
},
|
||||
"world_info_depth": 2,
|
||||
"world_info_budget": 25,
|
||||
"world_info_include_names": true,
|
||||
"world_info_recursive": true,
|
||||
"world_info_overflow_alert": false,
|
||||
"world_info_case_sensitive": false,
|
||||
|
|
|
@ -3542,6 +3542,12 @@
|
|||
</div>
|
||||
</div>
|
||||
<div id="wiCheckboxes" class="flex1 flex-container flexFlowColumn">
|
||||
<label title="Include names with each message into the context for scanning" data-i18n="[title]Include names with each message into the context for scanning" class="checkbox_label flex1">
|
||||
<input id="world_info_include_names" type="checkbox" />
|
||||
<small data-i18n="Include Names" class="whitespacenowrap flex1">
|
||||
Include Names
|
||||
</small>
|
||||
</label>
|
||||
<label title="Entries can activate other entries by mentioning their keywords" data-i18n="[title]Entries can activate other entries by mentioning their keywords" class="checkbox_label flex1">
|
||||
<input id="world_info_recursive" type="checkbox" />
|
||||
<small data-i18n="Recursive Scan" class="whitespacenowrap flex1">
|
||||
|
|
|
@ -35,6 +35,7 @@ import {
|
|||
setWorldInfoButtonClass,
|
||||
importWorldInfo,
|
||||
wi_anchor_position,
|
||||
world_info_include_names,
|
||||
} from './scripts/world-info.js';
|
||||
|
||||
import {
|
||||
|
@ -3500,7 +3501,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
|||
// Add WI to prompt (and also inject WI to AN value via hijack)
|
||||
// Make quiet prompt available for WIAN
|
||||
setExtensionPrompt('QUIET_PROMPT', quiet_prompt || '', extension_prompt_types.IN_PROMPT, 0, true);
|
||||
const chatForWI = coreChat.map(x => `${x.name}: ${x.mes}`).reverse();
|
||||
const chatForWI = coreChat.map(x => world_info_include_names ? `${x.name}: ${x.mes}` : x.mes).reverse();
|
||||
const { worldInfoString, worldInfoBefore, worldInfoAfter, worldInfoExamples, worldInfoDepth } = await getWorldInfoPrompt(chatForWI, this_max_context, dryRun);
|
||||
setExtensionPrompt('QUIET_PROMPT', '', extension_prompt_types.IN_PROMPT, 0, true);
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ export {
|
|||
world_info_depth,
|
||||
world_info_min_activations,
|
||||
world_info_min_activations_depth_max,
|
||||
world_info_include_names,
|
||||
world_info_recursive,
|
||||
world_info_overflow_alert,
|
||||
world_info_case_sensitive,
|
||||
|
@ -83,6 +84,7 @@ let world_info_min_activations = 0; // if > 0, will continue seeking chat until
|
|||
let world_info_min_activations_depth_max = 0; // used when (world_info_min_activations > 0)
|
||||
|
||||
let world_info_budget = 25;
|
||||
let world_info_include_names = true;
|
||||
let world_info_recursive = false;
|
||||
let world_info_overflow_alert = false;
|
||||
let world_info_case_sensitive = false;
|
||||
|
@ -710,6 +712,7 @@ export function getWorldInfoSettings() {
|
|||
world_info_min_activations,
|
||||
world_info_min_activations_depth_max,
|
||||
world_info_budget,
|
||||
world_info_include_names,
|
||||
world_info_recursive,
|
||||
world_info_overflow_alert,
|
||||
world_info_case_sensitive,
|
||||
|
@ -739,7 +742,7 @@ const worldInfoCache = new Map();
|
|||
|
||||
/**
|
||||
* Gets the world info based on chat messages.
|
||||
* @param {string[]} chat The chat messages to scan.
|
||||
* @param {string[]} chat The chat messages to scan, in reverse order.
|
||||
* @param {number} maxContext The maximum context size of the generation.
|
||||
* @param {boolean} isDryRun If true, the function will not emit any events.
|
||||
* @typedef {{worldInfoString: string, worldInfoBefore: string, worldInfoAfter: string, worldInfoExamples: any[], worldInfoDepth: any[]}} WIPromptResult
|
||||
|
@ -776,6 +779,8 @@ function setWorldInfoSettings(settings, data) {
|
|||
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_include_names !== undefined)
|
||||
world_info_include_names = Boolean(settings.world_info_include_names);
|
||||
if (settings.world_info_recursive !== undefined)
|
||||
world_info_recursive = Boolean(settings.world_info_recursive);
|
||||
if (settings.world_info_overflow_alert !== undefined)
|
||||
|
@ -825,6 +830,7 @@ function setWorldInfoSettings(settings, data) {
|
|||
$('#world_info_budget_counter').val(world_info_budget);
|
||||
$('#world_info_budget').val(world_info_budget);
|
||||
|
||||
$('#world_info_include_names').prop('checked', world_info_include_names);
|
||||
$('#world_info_recursive').prop('checked', world_info_recursive);
|
||||
$('#world_info_overflow_alert').prop('checked', world_info_overflow_alert);
|
||||
$('#world_info_case_sensitive').prop('checked', world_info_case_sensitive);
|
||||
|
@ -3527,7 +3533,7 @@ export async function getSortedEntries() {
|
|||
|
||||
/**
|
||||
* Performs a scan on the chat and returns the world info activated.
|
||||
* @param {string[]} chat The chat messages to scan.
|
||||
* @param {string[]} chat The chat messages to scan, in reverse order.
|
||||
* @param {number} maxContext The maximum context size of the generation.
|
||||
* @param {boolean} isDryRun Whether to perform a dry run.
|
||||
* @typedef {{ worldInfoBefore: string, worldInfoAfter: string, EMEntries: any[], WIDepthEntries: any[], allActivatedEntries: Set<any> }} WIActivated
|
||||
|
@ -4533,6 +4539,11 @@ jQuery(() => {
|
|||
saveSettings();
|
||||
});
|
||||
|
||||
$('#world_info_include_names').on('input', function () {
|
||||
world_info_include_names = !!$(this).prop('checked');
|
||||
saveSettings();
|
||||
});
|
||||
|
||||
$('#world_info_recursive').on('input', function () {
|
||||
world_info_recursive = !!$(this).prop('checked');
|
||||
saveSettings();
|
||||
|
|
Loading…
Reference in New Issue