Better customized sysprompt migration

This commit is contained in:
Cohee 2024-09-22 12:20:07 +03:00
parent 6179c361dc
commit ade6ef8af8
2 changed files with 14 additions and 7 deletions

View File

@ -934,6 +934,7 @@ async function firstLoadInit() {
initDefaultSlashCommands();
initTextGenModels();
initSystemPrompts();
await initPresetManager();
await getSystemMessages();
sendSystemMessage(system_message_types.WELCOME);
sendSystemMessage(system_message_types.WELCOME_PROMPT);
@ -947,7 +948,6 @@ async function firstLoadInit() {
await getCharacters();
await getBackgrounds();
await initTokenizers();
await initPresetManager();
initBackgrounds();
initAuthorsNote();
initPersonas();

View File

@ -17,14 +17,21 @@ const $select = $('#sysprompt_select');
const $content = $('#sysprompt_content');
const $contentBlock = $('#SystemPromptBlock');
function migrateSystemPromptFromInstructMode() {
async function migrateSystemPromptFromInstructMode() {
if ('system_prompt' in power_user.instruct) {
power_user.sysprompt.enabled = power_user.instruct.enabled;
power_user.sysprompt.content = String(power_user.instruct.system_prompt);
const prompt = String(power_user.instruct.system_prompt);
delete power_user.instruct.system_prompt;
power_user.sysprompt.enabled = power_user.instruct.enabled;
power_user.sysprompt.content = prompt;
if (system_prompts.some(x => x.name === power_user.instruct.preset)) {
power_user.sysprompt.name = power_user.instruct.preset;
const existingPromptName = system_prompts.find(x => x.content === prompt)?.name;
if (existingPromptName) {
power_user.sysprompt.name = existingPromptName;
} else {
const data = { name: `${power_user.instruct.preset} (Migrated)`, content: prompt };
await getPresetManager('sysprompt')?.savePreset(data.name, data);
power_user.sysprompt.name = data.name;
}
saveSettingsDebounced();
@ -41,7 +48,7 @@ export async function loadSystemPrompts(data) {
system_prompts = data.sysprompt;
}
migrateSystemPromptFromInstructMode();
await migrateSystemPromptFromInstructMode();
toggleSystemPromptDisabledControls();
for (const prompt of system_prompts) {