TC sysprompt: Add Post-History Instructions control

Closes #3920
This commit is contained in:
Cohee
2025-04-28 00:14:57 +03:00
parent 97e1f482c1
commit 775ae0f557
48 changed files with 31 additions and 63 deletions

View File

@ -17,6 +17,7 @@ export let system_prompts = [];
const $enabled = $('#sysprompt_enabled');
const $select = $('#sysprompt_select');
const $content = $('#sysprompt_content');
const $postHistory = $('#sysprompt_post_history');
const $contentBlock = $('#SystemPromptBlock');
async function migrateSystemPromptFromInstructMode() {
@ -25,6 +26,7 @@ async function migrateSystemPromptFromInstructMode() {
delete power_user.instruct.system_prompt;
power_user.sysprompt.enabled = power_user.instruct.enabled;
power_user.sysprompt.content = prompt;
power_user.sysprompt.post_history = '';
const existingPromptName = system_prompts.find(x => x.content === prompt)?.name;
@ -59,7 +61,8 @@ export async function loadSystemPrompts(data) {
$enabled.prop('checked', power_user.sysprompt.enabled);
$select.val(power_user.sysprompt.name);
$content.val(power_user.sysprompt.content);
$content.val(power_user.sysprompt.content || '');
$postHistory.val(power_user.sysprompt.post_history || '');
if (!CSS.supports('field-sizing', 'content')) {
await resetScrollHeight($content);
}
@ -165,13 +168,17 @@ export function initSystemPrompts() {
const name = String($(this).val());
const prompt = system_prompts.find(p => p.name === name);
if (prompt) {
$content.val(prompt.content);
$content.val(prompt.content || '');
$postHistory.val(prompt.post_history || '');
if (!CSS.supports('field-sizing', 'content')) {
await resetScrollHeight($content);
await resetScrollHeight($postHistory);
}
power_user.sysprompt.name = name;
power_user.sysprompt.content = prompt.content;
power_user.sysprompt.content = prompt.content || '';
power_user.sysprompt.post_history = prompt.post_history || '';
}
saveSettingsDebounced();
});
@ -181,6 +188,11 @@ export function initSystemPrompts() {
saveSettingsDebounced();
});
$postHistory.on('input', function () {
power_user.sysprompt.post_history = String($(this).val());
saveSettingsDebounced();
});
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'sysprompt',
aliases: ['system-prompt'],