diff --git a/public/scripts/preset-manager.js b/public/scripts/preset-manager.js index 7127befc7..96b213600 100644 --- a/public/scripts/preset-manager.js +++ b/public/scripts/preset-manager.js @@ -25,7 +25,7 @@ import { ARGUMENT_TYPE, SlashCommandArgument } from './slash-commands/SlashComma import { enumIcons } from './slash-commands/SlashCommandCommonEnumsProvider.js'; import { SlashCommandEnumValue, enumTypes } from './slash-commands/SlashCommandEnumValue.js'; import { SlashCommandParser } from './slash-commands/SlashCommandParser.js'; -import { system_prompts } from './sysprompt.js'; +import { checkForSystemPromptInInstructTemplate, system_prompts } from './sysprompt.js'; import { textgenerationwebui_preset_names, textgenerationwebui_presets, @@ -72,7 +72,7 @@ function autoSelectPreset() { * @param {string} apiId API id * @returns {PresetManager} Preset manager */ -function getPresetManager(apiId = '') { +export function getPresetManager(apiId = '') { if (!apiId) { apiId = main_api == 'koboldhorde' ? 'kobold' : main_api; } @@ -183,6 +183,10 @@ class PresetManager { } async savePreset(name, settings) { + if (this.apiId === 'instruct') { + await checkForSystemPromptInInstructTemplate(name, settings); + } + const preset = settings ?? this.getPresetSettings(name); const response = await fetch('/api/presets/save', { diff --git a/public/scripts/sysprompt.js b/public/scripts/sysprompt.js index b212bf816..494d834d3 100644 --- a/public/scripts/sysprompt.js +++ b/public/scripts/sysprompt.js @@ -1,10 +1,13 @@ import { saveSettingsDebounced } from '../script.js'; +import { callGenericPopup, POPUP_TYPE } from './popup.js'; import { power_user } from './power-user.js'; +import { getPresetManager } from './preset-manager.js'; import { SlashCommand } from './slash-commands/SlashCommand.js'; import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js'; import { commonEnumProviders, enumIcons } from './slash-commands/SlashCommandCommonEnumsProvider.js'; import { enumTypes, SlashCommandEnumValue } from './slash-commands/SlashCommandEnumValue.js'; import { SlashCommandParser } from './slash-commands/SlashCommandParser.js'; +import { renderTemplateAsync } from './templates.js'; import { isTrueBoolean, resetScrollHeight } from './utils.js'; export let system_prompts = []; @@ -39,7 +42,7 @@ export async function loadSystemPrompts(data) { } migrateSystemPromptFromInstructMode(); - toggleSyspromptDisabledControls(); + toggleSystemPromptDisabledControls(); for (const prompt of system_prompts) { $('