#1226 Add chat-bound lorebooks

This commit is contained in:
Cohee
2023-10-16 23:03:42 +03:00
parent 8a3547ecd0
commit 6a1b230c7e
6 changed files with 99 additions and 9 deletions

View File

@ -1811,15 +1811,18 @@ function convertWorldInfoToCharacterBook(name, entries) {
}
function readWorldInfoFile(worldInfoName) {
const dummyObject = { entries: {} };
if (!worldInfoName) {
return { entries: {} };
return dummyObject;
}
const filename = `${worldInfoName}.json`;
const pathToWorldInfo = path.join(DIRECTORIES.worlds, filename);
if (!fs.existsSync(pathToWorldInfo)) {
throw new Error(`World info file ${filename} doesn't exist.`);
console.log(`World info file ${filename} doesn't exist.`);
return dummyObject;
}
const worldInfoText = fs.readFileSync(pathToWorldInfo, 'utf8');