mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Increase maximum injection depth and WI order (#3800)
This commit is contained in:
@ -5142,7 +5142,7 @@
|
|||||||
<div id="persona_depth_position_settings" class="flex-container">
|
<div id="persona_depth_position_settings" class="flex-container">
|
||||||
<div class="flex1">
|
<div class="flex1">
|
||||||
<label for="persona_depth_value" data-i18n="Depth:">Depth:</label>
|
<label for="persona_depth_value" data-i18n="Depth:">Depth:</label>
|
||||||
<input id="persona_depth_value" class="text_pole" type="number" min="0" max="999" step="1">
|
<input id="persona_depth_value" class="text_pole" type="number" min="0" max="9999" step="1">
|
||||||
</div>
|
</div>
|
||||||
<div class="flex1">
|
<div class="flex1">
|
||||||
<label for="persona_depth_role" data-i18n="Role:">Role:</label>
|
<label for="persona_depth_role" data-i18n="Role:">Role:</label>
|
||||||
@ -5795,7 +5795,7 @@
|
|||||||
@ Depth
|
@ Depth
|
||||||
</span>
|
</span>
|
||||||
</h4>
|
</h4>
|
||||||
<input id="depth_prompt_depth" name="depth_prompt_depth" class="text_pole textarea_compact m-t-0" type="number" min="0" max="999" value="4" form="form_create" />
|
<input id="depth_prompt_depth" name="depth_prompt_depth" class="text_pole textarea_compact m-t-0" type="number" min="0" max="9999" value="4" form="form_create" />
|
||||||
<h4>
|
<h4>
|
||||||
<span data-i18n="Role">
|
<span data-i18n="Role">
|
||||||
Role
|
Role
|
||||||
@ -6016,11 +6016,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="world_entry_form_control wi-enter-footer-text flex-container flexNoGap">
|
<div class="world_entry_form_control wi-enter-footer-text flex-container flexNoGap">
|
||||||
<label for="depth" class="WIEntryHeaderTitleMobile" data-i18n="Depth:">Depth:</label>
|
<label for="depth" class="WIEntryHeaderTitleMobile" data-i18n="Depth:">Depth:</label>
|
||||||
<input title="Depth" class="text_pole wideMax100px margin0" type="number" name="depth" data-i18n="[title]Depth" placeholder="" min="0" max="999" />
|
<input title="Depth" class="text_pole wideMax100px margin0" type="number" name="depth" data-i18n="[title]Depth" placeholder="" min="0" max="9999" />
|
||||||
</div>
|
</div>
|
||||||
<div class="world_entry_form_control wi-enter-footer-text flex-container flexNoGap">
|
<div class="world_entry_form_control wi-enter-footer-text flex-container flexNoGap">
|
||||||
<label for="order" class="WIEntryHeaderTitleMobile" data-i18n="Order:">Order:</label>
|
<label for="order" class="WIEntryHeaderTitleMobile" data-i18n="Order:">Order:</label>
|
||||||
<input title="Order" data-i18n="[title]Order" class="text_pole wideMax100px margin0" type="number" name="order" placeholder="" min="0" max="999" />
|
<input title="Order" data-i18n="[title]Order" class="text_pole wideMax100px margin0" type="number" name="order" placeholder="" min="0" max="9999" />
|
||||||
</div>
|
</div>
|
||||||
<div class="world_entry_form_control wi-enter-footer-text flex-container flexNoGap probabilityContainer">
|
<div class="world_entry_form_control wi-enter-footer-text flex-container flexNoGap probabilityContainer">
|
||||||
<label for="order" class="WIEntryHeaderTitleMobile" data-i18n="Trigger %:">Trigger %:</label>
|
<label for="order" class="WIEntryHeaderTitleMobile" data-i18n="Trigger %:">Trigger %:</label>
|
||||||
@ -6382,7 +6382,7 @@
|
|||||||
<span data-i18n="prompt_manager_depth">Depth</span>
|
<span data-i18n="prompt_manager_depth">Depth</span>
|
||||||
</label>
|
</label>
|
||||||
<div class="text_muted" data-i18n="Injection depth. 0 = after the last message, 1 = before the last message, etc.">Injection depth. 0 = after the last message, 1 = before the last message, etc.</div>
|
<div class="text_muted" data-i18n="Injection depth. 0 = after the last message, 1 = before the last message, etc.">Injection depth. 0 = after the last message, 1 = before the last message, etc.</div>
|
||||||
<input id="completion_prompt_manager_popup_entry_form_injection_depth" class="text_pole" type="number" name="injection_depth" min="0" max="999" value="4" />
|
<input id="completion_prompt_manager_popup_entry_form_injection_depth" class="text_pole" type="number" name="injection_depth" min="0" max="9999" value="4" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="completion_prompt_manager_popup_entry_form_control">
|
<div class="completion_prompt_manager_popup_entry_form_control">
|
||||||
@ -6742,7 +6742,7 @@
|
|||||||
<label class="checkbox_label alignItemsCenter" for="extension_floating_position_depth">
|
<label class="checkbox_label alignItemsCenter" for="extension_floating_position_depth">
|
||||||
<input type="radio" id="extension_floating_position_depth" name="extension_floating_position" value="1" />
|
<input type="radio" id="extension_floating_position_depth" name="extension_floating_position" value="1" />
|
||||||
<span data-i18n="In-chat @ Depth">In-chat @ Depth</span>
|
<span data-i18n="In-chat @ Depth">In-chat @ Depth</span>
|
||||||
<input id="extension_floating_depth" class="text_pole textarea_compact widthNatural" type="number" min="0" max="999" />
|
<input id="extension_floating_depth" class="text_pole textarea_compact widthNatural" type="number" min="0" max="9999" />
|
||||||
<span data-i18n="as">as</span>
|
<span data-i18n="as">as</span>
|
||||||
<select id="extension_floating_role" class="text_pole widthNatural">
|
<select id="extension_floating_role" class="text_pole widthNatural">
|
||||||
<option data-i18n="System" value="0">System</option>
|
<option data-i18n="System" value="0">System</option>
|
||||||
@ -6757,7 +6757,7 @@
|
|||||||
<span data-i18n="Insertion Frequency">Insertion Frequency</span>
|
<span data-i18n="Insertion Frequency">Insertion Frequency</span>
|
||||||
<small data-i18n="(0 = Disable, 1 = Always)">(0 = Disable, 1 = Always)</small>
|
<small data-i18n="(0 = Disable, 1 = Always)">(0 = Disable, 1 = Always)</small>
|
||||||
</label>
|
</label>
|
||||||
<input id="extension_floating_interval" class="text_pole widthUnset" type="number" min="0" max="999" />
|
<input id="extension_floating_interval" class="text_pole widthUnset" type="number" min="0" max="9999" />
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<span><span data-i18n="User inputs until next insertion:">User inputs until next insertion:</span> <span id="extension_floating_counter">(disabled)</span></span>
|
<span><span data-i18n="User inputs until next insertion:">User inputs until next insertion:</span> <span id="extension_floating_counter">(disabled)</span></span>
|
||||||
@ -6827,7 +6827,7 @@
|
|||||||
<label class="checkbox_label alignItemsCenter" for="extension_default_position_depth">
|
<label class="checkbox_label alignItemsCenter" for="extension_default_position_depth">
|
||||||
<input type="radio" id="extension_default_position_depth" name="extension_default_position" value="1" />
|
<input type="radio" id="extension_default_position_depth" name="extension_default_position" value="1" />
|
||||||
<span data-i18n="In-chat @ Depth">In-chat @ Depth</span>
|
<span data-i18n="In-chat @ Depth">In-chat @ Depth</span>
|
||||||
<input id="extension_default_depth" class="text_pole textarea_compact widthNatural" type="number" min="0" max="999" />
|
<input id="extension_default_depth" class="text_pole textarea_compact widthNatural" type="number" min="0" max="9999" />
|
||||||
<span data-i18n="as">as</span>
|
<span data-i18n="as">as</span>
|
||||||
<select id="extension_default_role" class="text_pole widthNatural">
|
<select id="extension_default_role" class="text_pole widthNatural">
|
||||||
<option data-i18n="System" value="0">System</option>
|
<option data-i18n="System" value="0">System</option>
|
||||||
@ -6841,7 +6841,7 @@
|
|||||||
<span data-i18n="Insertion Frequency">Insertion Frequency</span>
|
<span data-i18n="Insertion Frequency">Insertion Frequency</span>
|
||||||
<small data-i18n="(0 = Disable, 1 = Always)">(0 = Disable, 1 = Always)</small>
|
<small data-i18n="(0 = Disable, 1 = Always)">(0 = Disable, 1 = Always)</small>
|
||||||
</label>
|
</label>
|
||||||
<input id="extension_default_interval" class="text_pole widthUnset" type="number" min="0" max="999" />
|
<input id="extension_default_interval" class="text_pole widthUnset" type="number" min="0" max="9999" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -651,7 +651,7 @@ export const extension_prompt_roles = {
|
|||||||
ASSISTANT: 2,
|
ASSISTANT: 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const MAX_INJECTION_DEPTH = 1000;
|
export const MAX_INJECTION_DEPTH = 10000;
|
||||||
|
|
||||||
const SAFETY_CHAT = [
|
const SAFETY_CHAT = [
|
||||||
{
|
{
|
||||||
@ -3046,6 +3046,17 @@ export async function getExtensionPromptByName(moduleName) {
|
|||||||
return substituteParams(prompt.value);
|
return substituteParams(prompt.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the maximum depth of extension prompts.
|
||||||
|
* @returns {number} Maximum depth of extension prompts
|
||||||
|
*/
|
||||||
|
export function getExtensionPromptMaxDepth() {
|
||||||
|
const prompts = Object.values(extension_prompts);
|
||||||
|
const maxDepth = Math.max(...prompts.map(x => x.depth ?? 0));
|
||||||
|
// Clamp to 1 <= depth <= MAX_INJECTION_DEPTH
|
||||||
|
return Math.max(Math.min(maxDepth, MAX_INJECTION_DEPTH), 1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the extension prompt for the given position, depth, and role.
|
* Returns the extension prompt for the given position, depth, and role.
|
||||||
* If multiple prompts are found, they are joined with a separator.
|
* If multiple prompts are found, they are joined with a separator.
|
||||||
@ -5099,7 +5110,8 @@ async function doChatInject(messages, isContinue) {
|
|||||||
let totalInsertedMessages = 0;
|
let totalInsertedMessages = 0;
|
||||||
messages.reverse();
|
messages.reverse();
|
||||||
|
|
||||||
for (let i = 0; i <= MAX_INJECTION_DEPTH; i++) {
|
const maxDepth = getExtensionPromptMaxDepth();
|
||||||
|
for (let i = 0; i <= maxDepth; i++) {
|
||||||
// Order of priority (most important go lower)
|
// Order of priority (most important go lower)
|
||||||
const roles = [extension_prompt_roles.SYSTEM, extension_prompt_roles.USER, extension_prompt_roles.ASSISTANT];
|
const roles = [extension_prompt_roles.SYSTEM, extension_prompt_roles.USER, extension_prompt_roles.ASSISTANT];
|
||||||
const names = {
|
const names = {
|
||||||
|
@ -132,7 +132,7 @@
|
|||||||
</label>
|
</label>
|
||||||
<label class="flex-container alignItemsCenter" title="How many messages before the current end of the chat." data-i18n="[title]How many messages before the current end of the chat.">
|
<label class="flex-container alignItemsCenter" title="How many messages before the current end of the chat." data-i18n="[title]How many messages before the current end of the chat.">
|
||||||
<input type="radio" name="memory_position" value="1" />
|
<input type="radio" name="memory_position" value="1" />
|
||||||
<span data-i18n="In-chat @ Depth">In-chat @ Depth</span> <input id="memory_depth" class="text_pole widthUnset" type="number" min="0" max="999" />
|
<span data-i18n="In-chat @ Depth">In-chat @ Depth</span> <input id="memory_depth" class="text_pole widthUnset" type="number" min="0" max="9999" />
|
||||||
<span data-i18n="as">as</span>
|
<span data-i18n="as">as</span>
|
||||||
<select id="memory_role" class="text_pole widthNatural">
|
<select id="memory_role" class="text_pole widthNatural">
|
||||||
<option value="0" data-i18n="System">System</option>
|
<option value="0" data-i18n="System">System</option>
|
||||||
|
@ -113,14 +113,14 @@
|
|||||||
<span data-i18n="Min Depth">Min Depth</span>
|
<span data-i18n="Min Depth">Min Depth</span>
|
||||||
<span class="fa-solid fa-circle-question note-link-span"></span>
|
<span class="fa-solid fa-circle-question note-link-span"></span>
|
||||||
</small>
|
</small>
|
||||||
<input name="min_depth" class="text_pole textarea_compact" type="number" min="-1" max="999" data-i18n="[placeholder]ext_regex_min_depth_placeholder" placeholder="Unlimited" />
|
<input name="min_depth" class="text_pole textarea_compact" type="number" min="-1" max="9999" data-i18n="[placeholder]ext_regex_min_depth_placeholder" placeholder="Unlimited" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex1 flex-container flexNoGap">
|
<div class="flex1 flex-container flexNoGap">
|
||||||
<small data-i18n="[title]ext_regex_max_depth_desc" title="When applied to prompts or display, only affect messages no more than N levels deep. 0 = last message, 1 = penultimate message, etc. System prompt and utility prompts are not affected. Max must be greater than Min for regex to apply.">
|
<small data-i18n="[title]ext_regex_max_depth_desc" title="When applied to prompts or display, only affect messages no more than N levels deep. 0 = last message, 1 = penultimate message, etc. System prompt and utility prompts are not affected. Max must be greater than Min for regex to apply.">
|
||||||
<span data-i18n="Max Depth">Max Depth</span>
|
<span data-i18n="Max Depth">Max Depth</span>
|
||||||
<span class="fa-solid fa-circle-question note-link-span"></span>
|
<span class="fa-solid fa-circle-question note-link-span"></span>
|
||||||
</small>
|
</small>
|
||||||
<input name="max_depth" class="text_pole textarea_compact" type="number" min="0" max="999" data-i18n="[placeholder]ext_regex_min_depth_placeholder" placeholder="Unlimited" />
|
<input name="max_depth" class="text_pole textarea_compact" type="number" min="0" max="9999" data-i18n="[placeholder]ext_regex_min_depth_placeholder" placeholder="Unlimited" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -310,7 +310,7 @@
|
|||||||
<label for="vectors_file_depth_db" title="How many messages before the current end of the chat." data-i18n="[title]How many messages before the current end of the chat.">
|
<label for="vectors_file_depth_db" title="How many messages before the current end of the chat." data-i18n="[title]How many messages before the current end of the chat.">
|
||||||
<input type="radio" name="vectors_file_position_db" value="1" />
|
<input type="radio" name="vectors_file_position_db" value="1" />
|
||||||
<span data-i18n="In-chat @ Depth">In-chat @ Depth</span>
|
<span data-i18n="In-chat @ Depth">In-chat @ Depth</span>
|
||||||
<input id="vectors_file_depth_db" class="text_pole widthUnset" type="number" min="0" max="999" />
|
<input id="vectors_file_depth_db" class="text_pole widthUnset" type="number" min="0" max="9999" />
|
||||||
<span>as</span>
|
<span>as</span>
|
||||||
<select id="vectors_file_depth_role_db" class="text_pole widthNatural">
|
<select id="vectors_file_depth_role_db" class="text_pole widthNatural">
|
||||||
<option value="0" data-i18n="System">System</option>
|
<option value="0" data-i18n="System">System</option>
|
||||||
@ -362,7 +362,7 @@
|
|||||||
<label for="vectors_depth" title="How many messages before the current end of the chat." data-i18n="[title]How many messages before the current end of the chat.">
|
<label for="vectors_depth" title="How many messages before the current end of the chat." data-i18n="[title]How many messages before the current end of the chat.">
|
||||||
<input type="radio" name="vectors_position" value="1" />
|
<input type="radio" name="vectors_position" value="1" />
|
||||||
<span data-i18n="In-chat @ Depth">In-chat @ Depth </span>
|
<span data-i18n="In-chat @ Depth">In-chat @ Depth </span>
|
||||||
<input id="vectors_depth" class="text_pole widthUnset" type="number" min="0" max="999" />
|
<input id="vectors_depth" class="text_pole widthUnset" type="number" min="0" max="9999" />
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-container">
|
<div class="flex-container">
|
||||||
|
@ -15,12 +15,12 @@ import {
|
|||||||
extension_prompt_types,
|
extension_prompt_types,
|
||||||
Generate,
|
Generate,
|
||||||
getExtensionPrompt,
|
getExtensionPrompt,
|
||||||
|
getExtensionPromptMaxDepth,
|
||||||
getNextMessageId,
|
getNextMessageId,
|
||||||
getRequestHeaders,
|
getRequestHeaders,
|
||||||
getStoppingStrings,
|
getStoppingStrings,
|
||||||
is_send_press,
|
is_send_press,
|
||||||
main_api,
|
main_api,
|
||||||
MAX_INJECTION_DEPTH,
|
|
||||||
name1,
|
name1,
|
||||||
name2,
|
name2,
|
||||||
replaceItemizedPromptText,
|
replaceItemizedPromptText,
|
||||||
@ -742,7 +742,8 @@ async function populationInjectionPrompts(prompts, messages) {
|
|||||||
'assistant': extension_prompt_roles.ASSISTANT,
|
'assistant': extension_prompt_roles.ASSISTANT,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (let i = 0; i <= MAX_INJECTION_DEPTH; i++) {
|
const maxDepth = getExtensionPromptMaxDepth();
|
||||||
|
for (let i = 0; i <= maxDepth; i++) {
|
||||||
// Get prompts for current depth
|
// Get prompts for current depth
|
||||||
const depthPrompts = prompts.filter(prompt => prompt.injection_depth === i && prompt.content);
|
const depthPrompts = prompts.filter(prompt => prompt.injection_depth === i && prompt.content);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user