mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-23 07:27:41 +01:00
Merge branch 'staging' of https://github.com/Cohee1207/SillyTavern into staging
This commit is contained in:
commit
b369be9201
@ -123,7 +123,9 @@
|
|||||||
<div data-i18n="clickslidertips" class="toggle-description wide100p editable-slider-notification">
|
<div data-i18n="clickslidertips" class="toggle-description wide100p editable-slider-notification">
|
||||||
Click slider numbers to input manually.
|
Click slider numbers to input manually.
|
||||||
</div>
|
</div>
|
||||||
<a href="https://docs.sillytavern.app/usage/api-connections/koboldai/" target="_blank" title="Improved Samplers documentation coming soon."><span name="samplerHelpButton" class="note-link-span topRightInset fa-solid fa-circle-question"></span></a>
|
<a href="https://docs.sillytavern.app/usage/common-settings/" target="_blank" title="Documentation on sampling parameters.">
|
||||||
|
<span name="samplerHelpButton" class="note-link-span topRightInset fa-solid fa-circle-question"></span>
|
||||||
|
</a>
|
||||||
<div class="scrollableInner">
|
<div class="scrollableInner">
|
||||||
<div class="flex-container" id="ai_response_configuration">
|
<div class="flex-container" id="ai_response_configuration">
|
||||||
<div id="respective-presets-block" class="width100p">
|
<div id="respective-presets-block" class="width100p">
|
||||||
@ -2510,7 +2512,6 @@
|
|||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div id="wi-holder" class="margin5">
|
<div id="wi-holder" class="margin5">
|
||||||
<div class="justifyContentSpaceAround wi-settings flex-container gap10px alignitemscenter">
|
|
||||||
<div id="WIMultiSelector" class="flex2 flex alignSelfStart range-block">
|
<div id="WIMultiSelector" class="flex2 flex alignSelfStart range-block">
|
||||||
<div class="range-block-title justifyLeft">
|
<div class="range-block-title justifyLeft">
|
||||||
<span data-i18n="Active World(s) for all chats"><small>Active World(s) for all chats</small></span>
|
<span data-i18n="Active World(s) for all chats"><small>Active World(s) for all chats</small></span>
|
||||||
@ -2523,6 +2524,15 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div data-newbie-hidden class="inline-drawer wide100p flexFlowColumn">
|
||||||
|
<div class="inline-drawer-toggle inline-drawer-header">
|
||||||
|
<b><span data-i18n="Activation Settings">Activation Settings</span></b>
|
||||||
|
<div class="fa-solid fa-circle-chevron-down inline-drawer-icon down"></div>
|
||||||
|
</div>
|
||||||
|
<div class="inline-drawer-content">
|
||||||
|
<div class="justifyContentSpaceAround wi-settings flex-container gap10px alignitemscenter">
|
||||||
<div class="flex2 flex-container flexFlowColumn">
|
<div class="flex2 flex-container flexFlowColumn">
|
||||||
<div data-newbie-hidden class="flex range-block">
|
<div data-newbie-hidden class="flex range-block">
|
||||||
<div class="range-block-title justifyLeft">
|
<div class="range-block-title justifyLeft">
|
||||||
@ -2565,7 +2575,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="range-block-counter margin0">
|
<div class="range-block-counter margin0">
|
||||||
<input type="number" min="1" max="100" step="1" data-for="world_info_budget" id="world_info_budget_counter">
|
<input type="number" min="1" max="100" step="1" data-for="world_info_budget" id="world_info_budget_counter">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -2580,13 +2589,46 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="range-block-counter margin0">
|
<div class="range-block-counter margin0">
|
||||||
<input type="number" min="0" max="8192" step="1" data-for="world_info_budget_cap" id="world_info_budget_cap_counter">
|
<input type="number" min="0" max="8192" step="1" data-for="world_info_budget_cap" id="world_info_budget_cap_counter">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="budget_cap_note">
|
<div class="budget_cap_note">
|
||||||
<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" title="Scan chronologically until reached min entries or token budget." data-i18n="[title]Scan chronologically until reached min entries or token budget.">
|
||||||
|
<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>
|
||||||
|
<div data-newbie-hidden class="flex1 gap5px range-block">
|
||||||
|
<div class="wide10pMinFit">
|
||||||
|
<small data-i18n="Max Depth">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 = unlimited, use budget)">(0 = unlimited, use budget)</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -2616,8 +2658,8 @@
|
|||||||
</small>
|
</small>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div id="WIInputWidthReference" style="display:none; height:1px;">10000</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="world_popup">
|
<div id="world_popup">
|
||||||
|
@ -260,7 +260,7 @@ export {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cohee: Uncomment when we decide to use loader
|
// Cohee: Uncomment when we decide to use loader
|
||||||
// showLoader();
|
showLoader();
|
||||||
|
|
||||||
// Allow target="_blank" in links
|
// Allow target="_blank" in links
|
||||||
DOMPurify.addHook('afterSanitizeAttributes', function (node) {
|
DOMPurify.addHook('afterSanitizeAttributes', function (node) {
|
||||||
@ -713,6 +713,7 @@ async function firstLoadInit() {
|
|||||||
const tokenData = await tokenResponse.json();
|
const tokenData = await tokenResponse.json();
|
||||||
token = tokenData.token;
|
token = tokenData.token;
|
||||||
} catch {
|
} catch {
|
||||||
|
hideLoader();
|
||||||
toastr.error("Couldn't get CSRF token. Please refresh the page.", "Error", { timeOut: 0, extendedTimeOut: 0, preventDuplicates: true });
|
toastr.error("Couldn't get CSRF token. Please refresh the page.", "Error", { timeOut: 0, extendedTimeOut: 0, preventDuplicates: true });
|
||||||
throw new Error("Initialization failed");
|
throw new Error("Initialization failed");
|
||||||
}
|
}
|
||||||
@ -734,7 +735,7 @@ async function firstLoadInit() {
|
|||||||
initCfg();
|
initCfg();
|
||||||
doDailyExtensionUpdatesCheck();
|
doDailyExtensionUpdatesCheck();
|
||||||
// Cohee: Uncomment when we decide to use loader
|
// Cohee: Uncomment when we decide to use loader
|
||||||
// hideLoader();
|
hideLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkOnlineStatus() {
|
function checkOnlineStatus() {
|
||||||
@ -2631,6 +2632,13 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
coreChat.pop();
|
coreChat.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
coreChat = coreChat.map(x => ({
|
||||||
|
...x,
|
||||||
|
mes: getRegexedString(x.mes, x.is_user ? regex_placement.USER_INPUT : regex_placement.AI_OUTPUT, {
|
||||||
|
isPrompt: true,
|
||||||
|
}),
|
||||||
|
}))
|
||||||
|
|
||||||
// Determine token limit
|
// Determine token limit
|
||||||
let this_max_context = getMaxContextSize();
|
let this_max_context = getMaxContextSize();
|
||||||
|
|
||||||
@ -5450,6 +5458,12 @@ export async function displayPastChats() {
|
|||||||
|
|
||||||
const group = selected_group ? groups.find(x => x.id === selected_group) : null;
|
const group = selected_group ? groups.find(x => x.id === selected_group) : null;
|
||||||
const data = await (selected_group ? getGroupPastChats(selected_group) : getPastCharacterChats());
|
const data = await (selected_group ? getGroupPastChats(selected_group) : getPastCharacterChats());
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
toastr.error('Could not load chat data. Try reloading the page.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const currentChat = selected_group ? group?.chat_id : characters[this_chid]["chat"];
|
const currentChat = selected_group ? group?.chat_id : characters[this_chid]["chat"];
|
||||||
const displayName = selected_group ? group?.name : characters[this_chid].name;
|
const displayName = selected_group ? group?.name : characters[this_chid].name;
|
||||||
const avatarImg = selected_group ? group?.avatar_url : getThumbnailUrl('avatar', characters[this_chid]['avatar']);
|
const avatarImg = selected_group ? group?.avatar_url : getThumbnailUrl('avatar', characters[this_chid]['avatar']);
|
||||||
@ -8804,7 +8818,7 @@ jQuery(async function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('input', '.range-block-counter input', function () {
|
$(document).on('input', '.range-block-counter input, .neo-range-input', function () {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const caretPosition = saveCaretPosition($(this).get(0));
|
const caretPosition = saveCaretPosition($(this).get(0));
|
||||||
const myText = $(this).val().trim();
|
const myText = $(this).val().trim();
|
||||||
|
@ -86,6 +86,10 @@
|
|||||||
<input type="checkbox" name="only_format_display" />
|
<input type="checkbox" name="only_format_display" />
|
||||||
<span data-i18n="Only Format Display">Only Format Display</span>
|
<span data-i18n="Only Format Display">Only Format Display</span>
|
||||||
</label>
|
</label>
|
||||||
|
<label class="checkbox flex-container" title="Chat history won't change, only the prompt as the request is sent (on generation)">
|
||||||
|
<input type="checkbox" name="only_format_prompt"/>
|
||||||
|
<span data-i18n="Only Format Prompt (?)">Only Format Prompt (?)</span>
|
||||||
|
</label>
|
||||||
<label class="checkbox flex-container">
|
<label class="checkbox flex-container">
|
||||||
<input type="checkbox" name="run_on_edit" />
|
<input type="checkbox" name="run_on_edit" />
|
||||||
<span data-i18n="Run On Edit">Run On Edit</span>
|
<span data-i18n="Run On Edit">Run On Edit</span>
|
||||||
|
@ -38,20 +38,25 @@ function regexFromString(input) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parent function to fetch a regexed version of a raw string
|
// Parent function to fetch a regexed version of a raw string
|
||||||
function getRegexedString(rawString, placement, { characterOverride, isMarkdown } = {}) {
|
function getRegexedString(rawString, placement, { characterOverride, isMarkdown, isPrompt } = {}) {
|
||||||
let finalString = rawString;
|
let finalString = rawString;
|
||||||
if (extension_settings.disabledExtensions.includes("regex") || !rawString || placement === undefined) {
|
if (extension_settings.disabledExtensions.includes("regex") || !rawString || placement === undefined) {
|
||||||
return finalString;
|
return finalString;
|
||||||
}
|
}
|
||||||
|
|
||||||
extension_settings.regex.forEach((script) => {
|
extension_settings.regex.forEach((script) => {
|
||||||
if ((script.markdownOnly && !isMarkdown) || (!script.markdownOnly && isMarkdown)) {
|
if (
|
||||||
return;
|
// Script applies to Markdown and input is Markdown
|
||||||
}
|
(script.markdownOnly && isMarkdown) ||
|
||||||
|
// Script applies to Generate and input is Generate
|
||||||
|
(script.promptOnly && isPrompt) ||
|
||||||
|
// Script applies to all cases when neither "only"s are true, but there's no need to do it when `isMarkdown`, the as source (chat history) should already be changed beforehand
|
||||||
|
(!script.markdownOnly && !script.promptOnly && !isMarkdown)
|
||||||
|
) {
|
||||||
if (script.placement.includes(placement)) {
|
if (script.placement.includes(placement)) {
|
||||||
finalString = runRegexScript(script, finalString, { characterOverride });
|
finalString = runRegexScript(script, finalString, { characterOverride });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return finalString;
|
return finalString;
|
||||||
|
@ -113,6 +113,9 @@ async function onRegexEditorOpenClick(existingId) {
|
|||||||
editorHtml
|
editorHtml
|
||||||
.find(`input[name="only_format_display"]`)
|
.find(`input[name="only_format_display"]`)
|
||||||
.prop("checked", existingScript.markdownOnly ?? false);
|
.prop("checked", existingScript.markdownOnly ?? false);
|
||||||
|
editorHtml
|
||||||
|
.find(`input[name="only_format_prompt"]`)
|
||||||
|
.prop("checked", existingScript.promptOnly ?? false);
|
||||||
editorHtml
|
editorHtml
|
||||||
.find(`input[name="run_on_edit"]`)
|
.find(`input[name="run_on_edit"]`)
|
||||||
.prop("checked", existingScript.runOnEdit ?? false);
|
.prop("checked", existingScript.runOnEdit ?? false);
|
||||||
@ -165,6 +168,10 @@ async function onRegexEditorOpenClick(existingId) {
|
|||||||
editorHtml
|
editorHtml
|
||||||
.find(`input[name="only_format_display"]`)
|
.find(`input[name="only_format_display"]`)
|
||||||
.prop("checked"),
|
.prop("checked"),
|
||||||
|
promptOnly:
|
||||||
|
editorHtml
|
||||||
|
.find(`input[name="only_format_prompt"]`)
|
||||||
|
.prop("checked"),
|
||||||
runOnEdit:
|
runOnEdit:
|
||||||
editorHtml
|
editorHtml
|
||||||
.find(`input[name="run_on_edit"]`)
|
.find(`input[name="run_on_edit"]`)
|
||||||
@ -197,6 +204,7 @@ function migrateSettings() {
|
|||||||
script.placement = script.placement.filter((e) => e !== regex_placement.MD_DISPLAY);
|
script.placement = script.placement.filter((e) => e !== regex_placement.MD_DISPLAY);
|
||||||
|
|
||||||
script.markdownOnly = true
|
script.markdownOnly = true
|
||||||
|
script.promptOnly = true
|
||||||
|
|
||||||
performSave = true;
|
performSave = true;
|
||||||
}
|
}
|
||||||
|
@ -639,21 +639,34 @@ async function sendCommentMessage(_, text) {
|
|||||||
await saveChatConditional();
|
await saveChatConditional();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a help message from the slash command
|
||||||
|
* @param {any} _ Unused
|
||||||
|
* @param {string} type Type of help to display
|
||||||
|
*/
|
||||||
function helpCommandCallback(_, type) {
|
function helpCommandCallback(_, type) {
|
||||||
switch (type?.trim()) {
|
switch (type?.trim()?.toLowerCase()) {
|
||||||
case 'slash':
|
case 'slash':
|
||||||
|
case 'commands':
|
||||||
|
case 'slashes':
|
||||||
|
case 'slash commands':
|
||||||
case '1':
|
case '1':
|
||||||
sendSystemMessage(system_message_types.SLASH_COMMANDS);
|
sendSystemMessage(system_message_types.SLASH_COMMANDS);
|
||||||
break;
|
break;
|
||||||
case 'format':
|
case 'format':
|
||||||
|
case 'formatting':
|
||||||
|
case 'formats':
|
||||||
|
case 'chat formatting':
|
||||||
case '2':
|
case '2':
|
||||||
sendSystemMessage(system_message_types.FORMATTING);
|
sendSystemMessage(system_message_types.FORMATTING);
|
||||||
break;
|
break;
|
||||||
case 'hotkeys':
|
case 'hotkeys':
|
||||||
|
case 'hotkey':
|
||||||
case '3':
|
case '3':
|
||||||
sendSystemMessage(system_message_types.HOTKEYS);
|
sendSystemMessage(system_message_types.HOTKEYS);
|
||||||
break;
|
break;
|
||||||
case 'macros':
|
case 'macros':
|
||||||
|
case 'macro':
|
||||||
case '4':
|
case '4':
|
||||||
sendSystemMessage(system_message_types.MACROS);
|
sendSystemMessage(system_message_types.MACROS);
|
||||||
break;
|
break;
|
||||||
|
@ -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,
|
||||||
@ -35,6 +37,9 @@ let world_info = {};
|
|||||||
let selected_world_info = [];
|
let selected_world_info = [];
|
||||||
let world_names;
|
let world_names;
|
||||||
let world_info_depth = 2;
|
let world_info_depth = 2;
|
||||||
|
let world_info_min_activations = 0; // if > 0, will continue seeking chat until minimum world infos are activated
|
||||||
|
let world_info_min_activations_depth_max = 0; // used when (world_info_min_activations > 0)
|
||||||
|
|
||||||
let world_info_budget = 25;
|
let world_info_budget = 25;
|
||||||
let world_info_recursive = false;
|
let world_info_recursive = false;
|
||||||
let world_info_overflow_alert = false;
|
let world_info_overflow_alert = false;
|
||||||
@ -55,14 +60,14 @@ const worldInfoFilter = new FilterHelper(() => updateEditor());
|
|||||||
const SORT_ORDER_KEY = 'world_info_sort_order';
|
const SORT_ORDER_KEY = 'world_info_sort_order';
|
||||||
const METADATA_KEY = 'world_info';
|
const METADATA_KEY = 'world_info';
|
||||||
|
|
||||||
const InputWidthReference = $("#WIInputWidthReference");
|
|
||||||
|
|
||||||
const DEFAULT_DEPTH = 4;
|
const DEFAULT_DEPTH = 4;
|
||||||
|
|
||||||
export function getWorldInfoSettings() {
|
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,
|
||||||
@ -102,6 +107,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)
|
||||||
@ -138,6 +147,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);
|
||||||
|
|
||||||
@ -367,24 +382,23 @@ function displayWorldEntries(name, data, navigation = navigation_option.none) {
|
|||||||
<small class="flex1">
|
<small class="flex1">
|
||||||
Title/Memo
|
Title/Memo
|
||||||
</small>
|
</small>
|
||||||
<small style="width:${InputWidthReference.width() + 5 + 'px'}">
|
<small style="width: calc(3.5em + 5px)">
|
||||||
Status
|
Status
|
||||||
</small>
|
</small>
|
||||||
<small style="width:${InputWidthReference.width() + 20 + 'px'}">
|
<small style="width: calc(3.5em + 20px)">
|
||||||
Position
|
Position
|
||||||
</small>
|
</small>
|
||||||
<small style="width:${InputWidthReference.width() + 15 + 'px'}">
|
<small style="width: calc(3.5em + 15px)">
|
||||||
Depth
|
Depth
|
||||||
</small>
|
</small>
|
||||||
<small style="width:${InputWidthReference.width() + 15 + 'px'}">
|
<small style="width: calc(3.5em + 15px)">
|
||||||
Order
|
Order
|
||||||
</small>
|
</small>
|
||||||
<small style="width:${InputWidthReference.width() + 15 + 'px'}">
|
<small style="width: calc(3.5em + 15px)">
|
||||||
Trigger %
|
Trigger %
|
||||||
</small>
|
</small>
|
||||||
|
|
||||||
</div>`
|
</div>`
|
||||||
const blocks = page.map(entry => getWorldEntry(name, data, entry));
|
const blocks = page.map(entry => getWorldEntry(name, data, entry)).filter(x => x);
|
||||||
$("#world_popup_entries_list").append(keywordHeaders);
|
$("#world_popup_entries_list").append(keywordHeaders);
|
||||||
$("#world_popup_entries_list").append(blocks);
|
$("#world_popup_entries_list").append(blocks);
|
||||||
},
|
},
|
||||||
@ -545,6 +559,10 @@ function deleteOriginalDataValue(data, uid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getWorldEntry(name, data, entry) {
|
function getWorldEntry(name, data, entry) {
|
||||||
|
if (!data.entries[entry.uid]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const template = $("#entry_edit_template .world_entry").clone();
|
const template = $("#entry_edit_template .world_entry").clone();
|
||||||
template.data("uid", entry.uid);
|
template.data("uid", entry.uid);
|
||||||
template.attr("uid", entry.uid);
|
template.attr("uid", entry.uid);
|
||||||
@ -819,7 +837,7 @@ function getWorldEntry(name, data, entry) {
|
|||||||
saveWorldInfo(name, data);
|
saveWorldInfo(name, data);
|
||||||
});
|
});
|
||||||
orderInput.val(entry.order).trigger("input");
|
orderInput.val(entry.order).trigger("input");
|
||||||
orderInput.width(InputWidthReference.width() + 15 + 'px')
|
orderInput.css('width', 'calc(3em + 15px)');
|
||||||
|
|
||||||
// probability
|
// probability
|
||||||
if (entry.probability === undefined) {
|
if (entry.probability === undefined) {
|
||||||
@ -840,7 +858,7 @@ function getWorldEntry(name, data, entry) {
|
|||||||
saveWorldInfo(name, data);
|
saveWorldInfo(name, data);
|
||||||
});
|
});
|
||||||
depthInput.val(entry.depth ?? DEFAULT_DEPTH).trigger("input");
|
depthInput.val(entry.depth ?? DEFAULT_DEPTH).trigger("input");
|
||||||
depthInput.width(InputWidthReference.width() + 15 + 'px');
|
depthInput.css('width', 'calc(3em + 15px)');
|
||||||
|
|
||||||
// Hide by default unless depth is specified
|
// Hide by default unless depth is specified
|
||||||
if (entry.position === world_info_position.atDepth) {
|
if (entry.position === world_info_position.atDepth) {
|
||||||
@ -868,7 +886,7 @@ function getWorldEntry(name, data, entry) {
|
|||||||
saveWorldInfo(name, data);
|
saveWorldInfo(name, data);
|
||||||
});
|
});
|
||||||
probabilityInput.val(entry.probability).trigger("input");
|
probabilityInput.val(entry.probability).trigger("input");
|
||||||
probabilityInput.width(InputWidthReference.width() + 15 + 'px')
|
probabilityInput.css('width', 'calc(3em + 15px)');
|
||||||
|
|
||||||
// probability toggle
|
// probability toggle
|
||||||
if (entry.useProbability === undefined) {
|
if (entry.useProbability === undefined) {
|
||||||
@ -1379,6 +1397,7 @@ async function checkWorldInfo(chat, maxContext) {
|
|||||||
|
|
||||||
// Combine the chat
|
// Combine the chat
|
||||||
let textToScan = chat.slice(0, messagesToLookBack).join("");
|
let textToScan = chat.slice(0, messagesToLookBack).join("");
|
||||||
|
let minActivationMsgIndex = messagesToLookBack; // tracks chat index to satisfy `world_info_min_activations`
|
||||||
|
|
||||||
// Add the depth or AN if enabled
|
// Add the depth or AN if enabled
|
||||||
// Put this code here since otherwise, the chat reference is modified
|
// Put this code here since otherwise, the chat reference is modified
|
||||||
@ -1402,6 +1421,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();
|
||||||
@ -1531,6 +1551,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1553,6 +1574,24 @@ async function checkWorldInfo(chat, maxContext) {
|
|||||||
textToScan = (currentlyActivatedText + '\n' + textToScan);
|
textToScan = (currentlyActivatedText + '\n' + textToScan);
|
||||||
allActivatedText = (currentlyActivatedText + '\n' + allActivatedText);
|
allActivatedText = (currentlyActivatedText + '\n' + allActivatedText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// world_info_min_activations
|
||||||
|
if (!needsToScan && !token_budget_overflowed) {
|
||||||
|
if (world_info_min_activations > 0 && (allActivatedEntries.size < world_info_min_activations)) {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Forward-sorted list of entries for joining
|
// Forward-sorted list of entries for joining
|
||||||
@ -2027,7 +2066,7 @@ jQuery(() => {
|
|||||||
$("#world_editor_select").on('change', async () => {
|
$("#world_editor_select").on('change', async () => {
|
||||||
$("#world_info_search").val('');
|
$("#world_info_search").val('');
|
||||||
worldInfoFilter.setFilterData(FILTER_TYPES.WORLD_INFO_SEARCH, '', true);
|
worldInfoFilter.setFilterData(FILTER_TYPES.WORLD_INFO_SEARCH, '', true);
|
||||||
const selectedIndex = $("#world_editor_select").find(":selected").val();
|
const selectedIndex = String($("#world_editor_select").find(":selected").val());
|
||||||
|
|
||||||
if (selectedIndex === "") {
|
if (selectedIndex === "") {
|
||||||
hideWorldEditor();
|
hideWorldEditor();
|
||||||
@ -2042,27 +2081,39 @@ jQuery(() => {
|
|||||||
eventSource.emit(event_types.WORLDINFO_SETTINGS_UPDATED);
|
eventSource.emit(event_types.WORLDINFO_SETTINGS_UPDATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).on("input", "#world_info_depth", function () {
|
$("#world_info_depth").on('input', function () {
|
||||||
world_info_depth = Number($(this).val());
|
world_info_depth = Number($(this).val());
|
||||||
$("#world_info_depth_counter").val($(this).val());
|
$("#world_info_depth_counter").val($(this).val());
|
||||||
saveSettings();
|
saveSettings();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("input", "#world_info_budget", function () {
|
$("#world_info_min_activations").on('input', function () {
|
||||||
|
world_info_min_activations = Number($(this).val());
|
||||||
|
$("#world_info_min_activations_counter").val($(this).val());
|
||||||
|
saveSettings();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#world_info_min_activations_depth_max").on('input', function () {
|
||||||
|
world_info_min_activations_depth_max = Number($(this).val());
|
||||||
|
$("#world_info_min_activations_depth_max_counter").val($(this).val());
|
||||||
|
saveSettings();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#world_info_budget").on('input', 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());
|
||||||
saveSettings();
|
saveSettings();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("input", "#world_info_recursive", function () {
|
$("#world_info_recursive").on('input', function () {
|
||||||
world_info_recursive = !!$(this).prop('checked');
|
world_info_recursive = !!$(this).prop('checked');
|
||||||
saveSettings();
|
saveSettings();
|
||||||
})
|
});
|
||||||
|
|
||||||
$('#world_info_case_sensitive').on('input', function () {
|
$('#world_info_case_sensitive').on('input', function () {
|
||||||
world_info_case_sensitive = !!$(this).prop('checked');
|
world_info_case_sensitive = !!$(this).prop('checked');
|
||||||
saveSettings();
|
saveSettings();
|
||||||
})
|
});
|
||||||
|
|
||||||
$('#world_info_match_whole_words').on('input', function () {
|
$('#world_info_match_whole_words').on('input', function () {
|
||||||
world_info_match_whole_words = !!$(this).prop('checked');
|
world_info_match_whole_words = !!$(this).prop('checked');
|
||||||
|
@ -2698,12 +2698,9 @@ h5 {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* .select_chat_block_wrapper {
|
.select_chat_block_wrapper {
|
||||||
display: grid;
|
cursor: pointer;
|
||||||
grid-template-columns: auto min-content;
|
}
|
||||||
align-items: center;
|
|
||||||
grid-gap: 10px;
|
|
||||||
} */
|
|
||||||
|
|
||||||
.select_chat_block {
|
.select_chat_block {
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user