mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
#230 Make recursive scanning of WI entries optional
This commit is contained in:
@ -1257,20 +1257,51 @@
|
||||
<div id="world_info_edit_button" class="menu_button fa-solid fa-pencil" title="Details"></div>
|
||||
</div>
|
||||
|
||||
<div id="world_info_depth_block">
|
||||
<h4>
|
||||
<div class="flex-container alignitemscenter">
|
||||
<div class="flex1 range-block">
|
||||
<div class="range-block-title">
|
||||
Scan Depth <a href="/notes#scandepth" class="notes-link" target="_blank"><span class="note-link-span">?</span></a>
|
||||
</h4>
|
||||
<label for="world_info_depth" id="world_info_depth_counter">depth</label>
|
||||
</div>
|
||||
<div class="range-block-range-and-counter">
|
||||
<div class="range-block-range">
|
||||
<input type="range" id="world_info_depth" name="volume" min="1" max="10" step="1">
|
||||
</div>
|
||||
<div id="world_info_budget_block">
|
||||
<h4>
|
||||
<div class="range-block-counter">
|
||||
<div contenteditable="true" data-for="world_info_depth" id="world_info_depth_counter">
|
||||
depth
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex1 range-block">
|
||||
<div class="range-block-title">
|
||||
Token Budget <a href="/notes#budget" class="notes-link" target="_blank"><span class="note-link-span">?</span></a>
|
||||
</h4>
|
||||
<label for="world_info_budget" id="world_info_budget_counter">budget</label>
|
||||
</div>
|
||||
<div class="range-block-range-and-counter">
|
||||
<div class="range-block-range">
|
||||
<input type="range" id="world_info_budget" name="volume" min="32" max="2048" step="16">
|
||||
</div>
|
||||
<div class="range-block-counter">
|
||||
<div contenteditable="true" data-for="world_info_budget" id="world_info_budget_counter">
|
||||
budget
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex1 range-block">
|
||||
<label title="Entries can activate other entries by mentioning their keywords" class="checkbox_label">
|
||||
<input id="world_info_recursive" type="checkbox" />
|
||||
<span>
|
||||
Recursive scanning
|
||||
<a href="/notes#recursivescanning" class="notes-link" target="_blank">
|
||||
<span class="note-link-span">?</span>
|
||||
</a>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="softprompt_block">
|
||||
<h4>Soft Prompt</h4>
|
||||
|
@ -213,6 +213,26 @@ Constant entries will be inserted first. Then entries with higher order numbers.
|
||||
|
||||
Entries inserted by direct mentioning of their keys have higher priority than those that were mentioned in other entries contents.
|
||||
|
||||
### Recursive scanning
|
||||
|
||||
**Entries can activate other entries by mentioning their keywords in the content text.**
|
||||
|
||||
For example, if your World Info contains two entries:
|
||||
|
||||
```
|
||||
Entry #1
|
||||
Keyword: Bessie
|
||||
Content: Bessie is a cow and is friend with Rufus.
|
||||
```
|
||||
|
||||
```
|
||||
Entry #2
|
||||
Keyword: Rufus
|
||||
Content: Rufus is a dog.
|
||||
```
|
||||
|
||||
**Both** of them will be pulled into the context if the message text mentions **just Bessie**.
|
||||
|
||||
## KoboldAI
|
||||
|
||||
### Basic Settings
|
||||
|
@ -24,6 +24,7 @@ import {
|
||||
selectImportedWorldInfo,
|
||||
setWorldInfoSettings,
|
||||
deleteWorldInfo,
|
||||
world_info_recursive,
|
||||
} from "./scripts/world-info.js";
|
||||
|
||||
import {
|
||||
@ -3174,6 +3175,7 @@ async function saveSettings(type) {
|
||||
world_info: world_info,
|
||||
world_info_depth: world_info_depth,
|
||||
world_info_budget: world_info_budget,
|
||||
world_info_recursive: world_info_recursive,
|
||||
textgenerationwebui_settings: textgenerationwebui_settings,
|
||||
swipes: swipes,
|
||||
horde_settings: horde_settings,
|
||||
|
@ -6,6 +6,7 @@ export {
|
||||
world_info_data,
|
||||
world_info_budget,
|
||||
world_info_depth,
|
||||
world_info_recursive,
|
||||
world_names,
|
||||
imported_world_name,
|
||||
checkWorldInfo,
|
||||
@ -21,6 +22,7 @@ let world_info_data = null;
|
||||
let world_info_depth = 2;
|
||||
let world_info_budget = 128;
|
||||
let is_world_edit_open = false;
|
||||
let world_info_recursive = false;
|
||||
let imported_world_name = "";
|
||||
const saveWorldDebounced = debounce(async () => await _save(), 500);
|
||||
const saveSettingsDebounced = debounce(() => saveSettings(), 500);
|
||||
@ -47,13 +49,17 @@ function setWorldInfoSettings(settings, data) {
|
||||
world_info_depth = Number(settings.world_info_depth);
|
||||
if (settings.world_info_budget !== undefined)
|
||||
world_info_budget = Number(settings.world_info_budget);
|
||||
if (settings.world_info_recursive !== undefined)
|
||||
world_info_recursive = Boolean(settings.world_info_recursive);
|
||||
|
||||
$("#world_info_depth_counter").html(`${world_info_depth} Messages`);
|
||||
$("#world_info_depth_counter").text(world_info_depth);
|
||||
$("#world_info_depth").val(world_info_depth);
|
||||
|
||||
$("#world_info_budget_counter").html(`${world_info_budget} Tokens`);
|
||||
$("#world_info_budget_counter").text(world_info_budget);
|
||||
$("#world_info_budget").val(world_info_budget);
|
||||
|
||||
$("#world_info_recursive").prop('checked', world_info_recursive);
|
||||
|
||||
world_names = data.world_names?.length ? data.world_names : [];
|
||||
|
||||
if (settings.world_info != undefined) {
|
||||
@ -524,7 +530,7 @@ function checkWorldInfo(chat) {
|
||||
}
|
||||
}
|
||||
|
||||
needsToScan = activatedNow.size > 0;
|
||||
needsToScan = world_info_recursive && activatedNow.size > 0;
|
||||
const newEntries = [...activatedNow]
|
||||
.map((x) => world_info_data.entries[x])
|
||||
.sort((a, b) => sortedEntries.indexOf(a) - sortedEntries.indexOf(b));
|
||||
@ -665,13 +671,18 @@ $(document).ready(() => {
|
||||
|
||||
$(document).on("input", "#world_info_depth", function () {
|
||||
world_info_depth = Number($(this).val());
|
||||
$("#world_info_depth_counter").html(`${$(this).val()} Messages`);
|
||||
$("#world_info_depth_counter").text($(this).val());
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$(document).on("input", "#world_info_budget", function () {
|
||||
world_info_budget = Number($(this).val());
|
||||
$("#world_info_budget_counter").html(`${$(this).val()} Tokens`);
|
||||
$("#world_info_budget_counter").text($(this).val());
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$(document).on("input", "#world_info_recursive", function () {
|
||||
world_info_recursive = !!$(this).prop('checked');
|
||||
saveSettingsDebounced();
|
||||
})
|
||||
});
|
Reference in New Issue
Block a user