mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-01 11:56:48 +01:00
parent
5a4e23f62f
commit
d9a8638109
@ -347,6 +347,8 @@ async function migrateSystemPrompts() {
|
|||||||
if (fs.existsSync(migrateMarker)) {
|
if (fs.existsSync(migrateMarker)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
const backupsPath = path.join(directory.backups, '_sysprompt');
|
||||||
|
fs.mkdirSync(backupsPath, { recursive: true });
|
||||||
const defaultPrompts = await getDefaultSystemPrompts();
|
const defaultPrompts = await getDefaultSystemPrompts();
|
||||||
const instucts = fs.readdirSync(directory.instruct);
|
const instucts = fs.readdirSync(directory.instruct);
|
||||||
let migratedPrompts = [];
|
let migratedPrompts = [];
|
||||||
@ -356,6 +358,8 @@ async function migrateSystemPrompts() {
|
|||||||
if (path.extname(instruct) === '.json' && !fs.existsSync(sysPromptPath)) {
|
if (path.extname(instruct) === '.json' && !fs.existsSync(sysPromptPath)) {
|
||||||
const instructData = JSON.parse(fs.readFileSync(instructPath, 'utf8'));
|
const instructData = JSON.parse(fs.readFileSync(instructPath, 'utf8'));
|
||||||
if ('system_prompt' in instructData && 'name' in instructData) {
|
if ('system_prompt' in instructData && 'name' in instructData) {
|
||||||
|
const backupPath = path.join(backupsPath, `${instructData.name}.json`);
|
||||||
|
fs.cpSync(instructPath, backupPath, { force: true });
|
||||||
const syspromptData = { name: instructData.name, content: instructData.system_prompt };
|
const syspromptData = { name: instructData.name, content: instructData.system_prompt };
|
||||||
migratedPrompts.push(syspromptData);
|
migratedPrompts.push(syspromptData);
|
||||||
delete instructData.system_prompt;
|
delete instructData.system_prompt;
|
||||||
@ -374,8 +378,8 @@ async function migrateSystemPrompts() {
|
|||||||
console.log(`Migrated system prompt ${sysPromptData.name} for ${directory.root.split(path.sep).pop()}`);
|
console.log(`Migrated system prompt ${sysPromptData.name} for ${directory.root.split(path.sep).pop()}`);
|
||||||
}
|
}
|
||||||
writeFileAtomicSync(migrateMarker, '');
|
writeFileAtomicSync(migrateMarker, '');
|
||||||
} catch {
|
} catch (error) {
|
||||||
// Ignore errors
|
console.error('Error migrating system prompts:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user