Fix being unable to save instruct templates

This commit is contained in:
Cohee 2024-09-19 23:42:41 +03:00
parent d0657161a1
commit 88c47fccdf

View File

@ -62,7 +62,10 @@ export async function loadSystemPrompts(data) {
* @param {object} template Instruct template object
*/
export async function checkForSystemPromptInInstructTemplate(name, template) {
if ('system_prompt' in template && name && template.system_prompt && !system_prompts.some(x => x.name === name)) {
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)) {
const html = await renderTemplateAsync('migrateInstructPrompt', { prompt: template.system_prompt });
const confirm = await callGenericPopup(html, POPUP_TYPE.CONFIRM);
if (confirm) {