mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-04 05:08:26 +01:00
Allow "none" position for extension prompt injects
This commit is contained in:
parent
1ad57e6ff6
commit
87e562b752
@ -7,7 +7,8 @@
|
|||||||
background-color: green;
|
background-color: green;
|
||||||
}
|
}
|
||||||
|
|
||||||
.extensions_block input[type="checkbox"] {
|
.extensions_block input[type="checkbox"],
|
||||||
|
.extensions_block input[type="radio"] {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
@ -570,6 +570,7 @@ export const system_message_types = {
|
|||||||
* @enum {number} Extension prompt types
|
* @enum {number} Extension prompt types
|
||||||
*/
|
*/
|
||||||
export const extension_prompt_types = {
|
export const extension_prompt_types = {
|
||||||
|
NONE: -1,
|
||||||
IN_PROMPT: 0,
|
IN_PROMPT: 0,
|
||||||
IN_CHAT: 1,
|
IN_CHAT: 1,
|
||||||
BEFORE_PROMPT: 2,
|
BEFORE_PROMPT: 2,
|
||||||
|
@ -14,6 +14,7 @@ import {
|
|||||||
substituteParamsExtended,
|
substituteParamsExtended,
|
||||||
generateRaw,
|
generateRaw,
|
||||||
getMaxContextSize,
|
getMaxContextSize,
|
||||||
|
setExtensionPrompt,
|
||||||
} from '../../../script.js';
|
} from '../../../script.js';
|
||||||
import { is_group_generating, selected_group } from '../../group-chats.js';
|
import { is_group_generating, selected_group } from '../../group-chats.js';
|
||||||
import { loadMovingUIState } from '../../power-user.js';
|
import { loadMovingUIState } from '../../power-user.js';
|
||||||
@ -73,6 +74,7 @@ const defaultSettings = {
|
|||||||
template: defaultTemplate,
|
template: defaultTemplate,
|
||||||
position: extension_prompt_types.IN_PROMPT,
|
position: extension_prompt_types.IN_PROMPT,
|
||||||
role: extension_prompt_roles.SYSTEM,
|
role: extension_prompt_roles.SYSTEM,
|
||||||
|
scan: false,
|
||||||
depth: 2,
|
depth: 2,
|
||||||
promptWords: 200,
|
promptWords: 200,
|
||||||
promptMinWords: 25,
|
promptMinWords: 25,
|
||||||
@ -122,6 +124,7 @@ function loadSettings() {
|
|||||||
$(`input[name="memory_prompt_builder"][value="${extension_settings.memory.prompt_builder}"]`).prop('checked', true).trigger('input');
|
$(`input[name="memory_prompt_builder"][value="${extension_settings.memory.prompt_builder}"]`).prop('checked', true).trigger('input');
|
||||||
$('#memory_override_response_length').val(extension_settings.memory.overrideResponseLength).trigger('input');
|
$('#memory_override_response_length').val(extension_settings.memory.overrideResponseLength).trigger('input');
|
||||||
$('#memory_max_messages_per_request').val(extension_settings.memory.maxMessagesPerRequest).trigger('input');
|
$('#memory_max_messages_per_request').val(extension_settings.memory.maxMessagesPerRequest).trigger('input');
|
||||||
|
$('#memory_include_wi_scan').prop('checked', extension_settings.memory.scan).trigger('input');
|
||||||
switchSourceControls(extension_settings.memory.source);
|
switchSourceControls(extension_settings.memory.source);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,6 +282,13 @@ function onMemoryPositionChange(e) {
|
|||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onMemoryIncludeWIScanInput() {
|
||||||
|
const value = !!$(this).prop('checked');
|
||||||
|
extension_settings.memory.scan = value;
|
||||||
|
reinsertMemory();
|
||||||
|
saveSettingsDebounced();
|
||||||
|
}
|
||||||
|
|
||||||
function onMemoryPromptWordsForceInput() {
|
function onMemoryPromptWordsForceInput() {
|
||||||
const value = $(this).val();
|
const value = $(this).val();
|
||||||
extension_settings.memory.promptForceWords = Number(value);
|
extension_settings.memory.promptForceWords = Number(value);
|
||||||
@ -800,8 +810,7 @@ function reinsertMemory() {
|
|||||||
* @param {number|null} index Index of the chat message to save the summary to. If null, the pre-last message is used.
|
* @param {number|null} index Index of the chat message to save the summary to. If null, the pre-last message is used.
|
||||||
*/
|
*/
|
||||||
function setMemoryContext(value, saveToMessage, index = null) {
|
function setMemoryContext(value, saveToMessage, index = null) {
|
||||||
const context = getContext();
|
setExtensionPrompt(MODULE_NAME, formatMemoryValue(value), extension_settings.memory.position, extension_settings.memory.depth, extension_settings.memory.scan, extension_settings.memory.role);
|
||||||
context.setExtensionPrompt(MODULE_NAME, formatMemoryValue(value), extension_settings.memory.position, extension_settings.memory.depth, false, extension_settings.memory.role);
|
|
||||||
$('#memory_contents').val(value);
|
$('#memory_contents').val(value);
|
||||||
|
|
||||||
const summaryLog = value
|
const summaryLog = value
|
||||||
@ -809,6 +818,7 @@ function setMemoryContext(value, saveToMessage, index = null) {
|
|||||||
: 'Summary has no content';
|
: 'Summary has no content';
|
||||||
console.debug(summaryLog);
|
console.debug(summaryLog);
|
||||||
|
|
||||||
|
const context = getContext();
|
||||||
if (saveToMessage && context.chat.length) {
|
if (saveToMessage && context.chat.length) {
|
||||||
const idx = index ?? context.chat.length - 2;
|
const idx = index ?? context.chat.length - 2;
|
||||||
const mes = context.chat[idx < 0 ? 0 : idx];
|
const mes = context.chat[idx < 0 ? 0 : idx];
|
||||||
@ -894,6 +904,7 @@ function setupListeners() {
|
|||||||
$('#memory_prompt_words_auto').off('click').on('click', onPromptForceWordsAutoClick);
|
$('#memory_prompt_words_auto').off('click').on('click', onPromptForceWordsAutoClick);
|
||||||
$('#memory_override_response_length').off('click').on('input', onOverrideResponseLengthInput);
|
$('#memory_override_response_length').off('click').on('input', onOverrideResponseLengthInput);
|
||||||
$('#memory_max_messages_per_request').off('click').on('input', onMaxMessagesPerRequestInput);
|
$('#memory_max_messages_per_request').off('click').on('input', onMaxMessagesPerRequestInput);
|
||||||
|
$('#memory_include_wi_scan').off('input').on('input', onMemoryIncludeWIScanInput);
|
||||||
$('#summarySettingsBlockToggle').off('click').on('click', function () {
|
$('#summarySettingsBlockToggle').off('click').on('click', function () {
|
||||||
console.log('saw settings button click');
|
console.log('saw settings button click');
|
||||||
$('#summarySettingsBlock').slideToggle(200, 'swing'); //toggleClass("hidden");
|
$('#summarySettingsBlock').slideToggle(200, 'swing'); //toggleClass("hidden");
|
||||||
|
@ -109,7 +109,16 @@
|
|||||||
<textarea id="memory_template" class="text_pole textarea_compact" rows="2" data-i18n="[placeholder]ext_sum_memory_template_placeholder" placeholder="{{summary}} will resolve to the current summary contents."></textarea>
|
<textarea id="memory_template" class="text_pole textarea_compact" rows="2" data-i18n="[placeholder]ext_sum_memory_template_placeholder" placeholder="{{summary}} will resolve to the current summary contents."></textarea>
|
||||||
</div>
|
</div>
|
||||||
<label for="memory_position" data-i18n="ext_sum_injection_position">Injection Position</label>
|
<label for="memory_position" data-i18n="ext_sum_injection_position">Injection Position</label>
|
||||||
|
<label class="checkbox_label" for="memory_include_wi_scan" data-i18n="[title]ext_sum_include_wi_scan_desc" title="Include the latest summary in the WI scan.">
|
||||||
|
<input id="memory_include_wi_scan" type="checkbox" />
|
||||||
|
<span data-i18n="ext_sum_include_wi_scan">Include in World Info Scanning</span>
|
||||||
|
</label>
|
||||||
<div class="radio_group">
|
<div class="radio_group">
|
||||||
|
<label>
|
||||||
|
<input type="radio" name="memory_position" value="-1" />
|
||||||
|
<span data-i18n="None (not injected)">None (not injected)</span>
|
||||||
|
<i class="fa-solid fa-info-circle" title="The summary will not be injected into the prompt. You can still access it via the {{summary}} macro." data-i18n="[title]ext_sum_injection_position_none"></i>
|
||||||
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<input type="radio" name="memory_position" value="2" />
|
<input type="radio" name="memory_position" value="2" />
|
||||||
<span data-i18n="Before Main Prompt / Story String">Before Main Prompt / Story String</span>
|
<span data-i18n="Before Main Prompt / Story String">Before Main Prompt / Story String</span>
|
||||||
|
@ -1356,7 +1356,7 @@ export function initDefaultSlashCommands() {
|
|||||||
enumProvider: commonEnumProviders.injects,
|
enumProvider: commonEnumProviders.injects,
|
||||||
}),
|
}),
|
||||||
new SlashCommandNamedArgument(
|
new SlashCommandNamedArgument(
|
||||||
'position', 'injection position', [ARGUMENT_TYPE.STRING], false, false, 'after', ['before', 'after', 'chat'],
|
'position', 'injection position', [ARGUMENT_TYPE.STRING], false, false, 'after', ['before', 'after', 'chat', 'none'],
|
||||||
),
|
),
|
||||||
new SlashCommandNamedArgument(
|
new SlashCommandNamedArgument(
|
||||||
'depth', 'injection depth', [ARGUMENT_TYPE.NUMBER], false, false, '4',
|
'depth', 'injection depth', [ARGUMENT_TYPE.NUMBER], false, false, '4',
|
||||||
@ -1384,7 +1384,7 @@ export function initDefaultSlashCommands() {
|
|||||||
'text', [ARGUMENT_TYPE.STRING], false,
|
'text', [ARGUMENT_TYPE.STRING], false,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
helpString: 'Injects a text into the LLM prompt for the current chat. Requires a unique injection ID. Positions: "before" main prompt, "after" main prompt, in-"chat" (default: after). Depth: injection depth for the prompt (default: 4). Role: role for in-chat injections (default: system). Scan: include injection content into World Info scans (default: false).',
|
helpString: 'Injects a text into the LLM prompt for the current chat. Requires a unique injection ID. Positions: "before" main prompt, "after" main prompt, in-"chat", hidden with "none" (default: after). Depth: injection depth for the prompt (default: 4). Role: role for in-chat injections (default: system). Scan: include injection content into World Info scans (default: false). Hidden injects in "none" position are not inserted into the prompt but can be used for triggering WI entries.',
|
||||||
}));
|
}));
|
||||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||||
name: 'listinjects',
|
name: 'listinjects',
|
||||||
@ -1486,6 +1486,7 @@ function injectCallback(args, value) {
|
|||||||
'before': extension_prompt_types.BEFORE_PROMPT,
|
'before': extension_prompt_types.BEFORE_PROMPT,
|
||||||
'after': extension_prompt_types.IN_PROMPT,
|
'after': extension_prompt_types.IN_PROMPT,
|
||||||
'chat': extension_prompt_types.IN_CHAT,
|
'chat': extension_prompt_types.IN_CHAT,
|
||||||
|
'none': extension_prompt_types.NONE,
|
||||||
};
|
};
|
||||||
const roles = {
|
const roles = {
|
||||||
'system': extension_prompt_roles.SYSTEM,
|
'system': extension_prompt_roles.SYSTEM,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user