Display existing prompts in instruct migration dialog

9d3887800789797f31d02a71b2412c092edba066

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +11 -3Ignore whitespace
public/scripts/sysprompt.js+2 -1
@@ -73,7 +73,8 @@ export async function checkForSystemPromptInInstructTemplate(name, template) {
73 return;73 return;
74 }74 }
75 if ('system_prompt' in template && template.system_prompt) {75 if ('system_prompt' in template && template.system_prompt) {
76 const html = await renderTemplateAsync('migrateInstructPrompt', { prompt: template.system_prompt });76 const existingName = system_prompts.find(x => x.content === template.system_prompt)?.name;
77 const html = await renderTemplateAsync('migrateInstructPrompt', { prompt: template.system_prompt, existing: existingName });
77 const confirm = await callGenericPopup(html, POPUP_TYPE.CONFIRM);78 const confirm = await callGenericPopup(html, POPUP_TYPE.CONFIRM);
78 if (confirm) {79 if (confirm) {
79 const migratedName = `[Migrated] ${name}`;80 const migratedName = `[Migrated] ${name}`;
public/scripts/templates/migrateInstructPrompt.html+9 -2
@@ -1,10 +1,17 @@
1<h3>1<h3>
2 This instruct template also contains a system prompt.2 This instruct template also contains a system prompt.
3</h3>3</h3>
4<div class="marginBot10">4<div>
5 Would you like to migrate the system prompt from the template?5 Would you like to migrate the system prompt from the template?
6</div>6</div>
7<div class="justifyLeft marginBot10">7{{#if existing}}
8<div class="marginTopBot5">
9 <b>Note:</b>
10 <span>you already have this prompt saved as:</span>
11 <span>{{existing}}</span>
12</div>
13{{/if}}
14<div class="justifyLeft marginTop5">
8 <div>15 <div>
9 <small>16 <small>
10 <b>"Yes"</b> &ndash; The prompt will be imported and selected as a current system prompt.17 <b>"Yes"</b> &ndash; The prompt will be imported and selected as a current system prompt.