Add migrated prefix to imported legacy instructs

This commit is contained in:
Cohee 2024-09-22 22:33:36 +03:00
parent 45e92fdf20
commit ece2684001
1 changed files with 5 additions and 4 deletions

View File

@ -72,14 +72,15 @@ export async function checkForSystemPromptInInstructTemplate(name, template) {
if (!template || !name || typeof name !== 'string' || typeof template !== 'object') {
return;
}
if ('system_prompt' in template && template.system_prompt && !system_prompts.some(x => x.name === name)) {
if ('system_prompt' in template && template.system_prompt) {
const html = await renderTemplateAsync('migrateInstructPrompt', { prompt: template.system_prompt });
const confirm = await callGenericPopup(html, POPUP_TYPE.CONFIRM);
if (confirm) {
const prompt = { name: name, content: template.system_prompt };
const migratedName = `[Migrated] ${name}`;
const prompt = { name: migratedName, content: template.system_prompt };
const presetManager = getPresetManager('sysprompt');
await presetManager.savePreset(prompt.name, prompt);
toastr.success(`System prompt "${prompt.name}" has been saved.`);
await presetManager.savePreset(migratedName, prompt);
toastr.success(`System prompt "${migratedName}" has been saved.`);
} else {
toastr.info('System prompt has been discarded.');
}