Better customized sysprompt migration
| @@ -934,6 +934,7 @@ async function firstLoadInit() { | |||
| 934 | initDefaultSlashCommands(); | 934 | initDefaultSlashCommands(); |
| 935 | initTextGenModels(); | 935 | initTextGenModels(); |
| 936 | initSystemPrompts(); | 936 | initSystemPrompts(); |
| 937 | await initPresetManager(); | ||
| 937 | await getSystemMessages(); | 938 | await getSystemMessages(); |
| 938 | sendSystemMessage(system_message_types.WELCOME); | 939 | sendSystemMessage(system_message_types.WELCOME); |
| 939 | sendSystemMessage(system_message_types.WELCOME_PROMPT); | 940 | sendSystemMessage(system_message_types.WELCOME_PROMPT); |
| @@ -947,7 +948,6 @@ async function firstLoadInit() { | |||
| 947 | await getCharacters(); | 948 | await getCharacters(); |
| 948 | await getBackgrounds(); | 949 | await getBackgrounds(); |
| 949 | await initTokenizers(); | 950 | await initTokenizers(); |
| 950 | await initPresetManager(); | ||
| 951 | initBackgrounds(); | 951 | initBackgrounds(); |
| 952 | initAuthorsNote(); | 952 | initAuthorsNote(); |
| 953 | initPersonas(); | 953 | initPersonas(); |
| @@ -17,14 +17,21 @@ const $select = $('#sysprompt_select'); | |||
| 17 | const $content = $('#sysprompt_content'); | 17 | const $content = $('#sysprompt_content'); |
| 18 | const $contentBlock = $('#SystemPromptBlock'); | 18 | const $contentBlock = $('#SystemPromptBlock'); |
| 19 | 19 | ||
| 20 | function migrateSystemPromptFromInstructMode() { | 20 | async function migrateSystemPromptFromInstructMode() { |
| 21 | if ('system_prompt' in power_user.instruct) { | 21 | if ('system_prompt' in power_user.instruct) { |
| 22 | power_user.sysprompt.enabled = power_user.instruct.enabled; | 22 | const prompt = String(power_user.instruct.system_prompt); |
| 23 | power_user.sysprompt.content = String(power_user.instruct.system_prompt); | ||
| 24 | delete power_user.instruct.system_prompt; | 23 | delete power_user.instruct.system_prompt; |
| 24 | power_user.sysprompt.enabled = power_user.instruct.enabled; | ||
| 25 | power_user.sysprompt.content = prompt; | ||
| 25 | 26 | ||
| 26 | if (system_prompts.some(x => x.name === power_user.instruct.preset)) { | 27 | const existingPromptName = system_prompts.find(x => x.content === prompt)?.name; |
| 27 | power_user.sysprompt.name = power_user.instruct.preset; | 28 | |
| 29 | if (existingPromptName) { | ||
| 30 | power_user.sysprompt.name = existingPromptName; | ||
| 31 | } else { | ||
| 32 | const data = { name: `${power_user.instruct.preset} (Migrated)`, content: prompt }; | ||
| 33 | await getPresetManager('sysprompt')?.savePreset(data.name, data); | ||
| 34 | power_user.sysprompt.name = data.name; | ||
| 28 | } | 35 | } |
| 29 | 36 | ||
| 30 | saveSettingsDebounced(); | 37 | saveSettingsDebounced(); |
| @@ -41,7 +48,7 @@ export async function loadSystemPrompts(data) { | |||
| 41 | system_prompts = data.sysprompt; | 48 | system_prompts = data.sysprompt; |
| 42 | } | 49 | } |
| 43 | 50 | ||
| 44 | migrateSystemPromptFromInstructMode(); | 51 | await migrateSystemPromptFromInstructMode(); |
| 45 | toggleSystemPromptDisabledControls(); | 52 | toggleSystemPromptDisabledControls(); |
| 46 | 53 | ||
| 47 | for (const prompt of system_prompts) { | 54 | for (const prompt of system_prompts) { |