Fix being unable to save instruct templates

88c47fccdfa9c56f97135932701039d2f33e90ca

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

1 files changed, +4 -1Showing whitespace changes
public/scripts/sysprompt.js+4 -1
@@ -62,7 +62,10 @@ export async function loadSystemPrompts(data) {
6262 * @param {object} template Instruct template object
6363 */
6464export async function checkForSystemPromptInInstructTemplate(name, template) {
65- if ('system_prompt' in template && name && template.system_prompt && !system_prompts.some(x => x.name === name)) {
65+ if (!template || !name || typeof name !== 'string' || typeof template !== 'object') {
66+ return;
67+ }
68+ if ('system_prompt' in template && template.system_prompt && !system_prompts.some(x => x.name === name)) {
6669 const html = await renderTemplateAsync('migrateInstructPrompt', { prompt: template.system_prompt });
6770 const confirm = await callGenericPopup(html, POPUP_TYPE.CONFIRM);
6871 if (confirm) {