Synchronize max depths for plugins

This commit is contained in:
Cohee 2023-09-25 19:29:24 +03:00
parent db71b87309
commit edb79d8c53
5 changed files with 12 additions and 9 deletions

View File

@ -2613,7 +2613,7 @@
</div>
<div class="range-block-range-and-counter">
<div class="range-block-range paddingLeftRight5">
<input type="range" id="world_info_depth" name="volume" min="0" max="10" step="1">
<input type="range" id="world_info_depth" name="volume" min="0" max="100" step="1">
</div>
<div class="range-block-counter margin0">
<div contenteditable="true" data-for="world_info_depth" id="world_info_depth_counter">
@ -4018,7 +4018,7 @@
<div class="world_entry_form_control wi-enter-footer-text flex-container flexNoGap ">
<label for="depth" data-i18n="Depth:">Depth:</label>
<input class="text_pole wideMax100px margin0" type="number" name="depth" placeholder="" min="0" max="10000" />
<input class="text_pole wideMax100px margin0" type="number" name="depth" placeholder="" min="0" max="999" />
</div>
<div class="world_entry_form_control wi-enter-footer-text flex-container flexNoGap ">
@ -4362,7 +4362,7 @@
</label>
<label>
<input type="radio" name="extension_floating_position" value="1" />
In-chat @ Depth <input id="extension_floating_depth" class="text_pole widthUnset" type="number" min="0" max="99" />
In-chat @ Depth <input id="extension_floating_depth" class="text_pole widthUnset" type="number" min="0" max="999" />
</label>
</div>
<!--<label for="extension_floating_interval">In-Chat Insertion Depth</label>-->
@ -4430,7 +4430,7 @@
</label>
<label>
<input type="radio" name="extension_default_position" value="1" />
In-chat @ Depth <input id="extension_default_depth" class="text_pole widthUnset" type="number" min="0" max="99" />
In-chat @ Depth <input id="extension_default_depth" class="text_pole widthUnset" type="number" min="0" max="999" />
</label>
</div>
<label for="extension_default_interval">Insertion Frequency</label>

View File

@ -390,6 +390,8 @@ const extension_prompt_types = {
BEFORE_PROMPT: 2
};
export const MAX_INJECTION_DEPTH = 1000;
let system_messages = {};
function getSystemMessages() {
@ -2883,7 +2885,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
// TODO: Rewrite getExtensionPrompt to not require multiple for loops
// Set all extension prompts where insertion depth > mesSend length
if (finalMesSend.length) {
for (let upperDepth = 100; upperDepth >= finalMesSend.length; upperDepth--) {
for (let upperDepth = MAX_INJECTION_DEPTH; upperDepth >= finalMesSend.length; upperDepth--) {
const upperAnchor = getExtensionPrompt(extension_prompt_types.IN_CHAT, upperDepth);
if (upperAnchor && upperAnchor.length) {
finalMesSend[0].extensionPrompts.push(upperAnchor);
@ -5641,7 +5643,7 @@ function select_rm_characters() {
* @param {string} key Prompt injection id.
* @param {string} value Prompt injection value.
* @param {number} position Insertion position. 0 is after story string, 1 is in-chat with custom depth.
* @param {number} depth Insertion depth. 0 represets the last message in context. Expected values up to 100.
* @param {number} depth Insertion depth. 0 represets the last message in context. Expected values up to MAX_INJECTION_DEPTH.
*/
export function setExtensionPrompt(key, value, position, depth) {
extension_prompts[key] = { value: String(value), position: Number(position), depth: Number(depth) };

View File

@ -584,7 +584,7 @@ jQuery(function () {
</label>
<label>
<input type="radio" name="memory_position" value="1" />
In-chat @ Depth <input id="memory_depth" class="text_pole widthUnset" type="number" min="0" max="99" />
In-chat @ Depth <input id="memory_depth" class="text_pole widthUnset" type="number" min="0" max="999" />
</label>
</div>
<div data-source="main" class="memory_contents_controls">

View File

@ -35,7 +35,7 @@
</label>
<label>
<input type="radio" name="vectors_position" value="1" />
In-chat @ Depth <input id="vectors_depth" class="text_pole widthUnset" type="number" min="0" max="99" />
In-chat @ Depth <input id="vectors_depth" class="text_pole widthUnset" type="number" min="0" max="999" />
</label>
</div>
<div class="flex-container">

View File

@ -24,6 +24,7 @@ import {
eventSource,
event_types,
substituteParams,
MAX_INJECTION_DEPTH,
} from "../script.js";
import { groups, selected_group } from "./group-chats.js";
@ -323,7 +324,7 @@ function setOpenAIMessages(chat) {
}
// Add chat injections, 100 = maximum depth of injection. (Why would you ever need more?)
for (let i = 100; i >= 0; i--) {
for (let i = MAX_INJECTION_DEPTH; i >= 0; i--) {
const anchor = getExtensionPrompt(extension_prompt_types.IN_CHAT, i);
if (anchor && anchor.length) {