mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Import Risu lorebooks
This commit is contained in:
@ -902,6 +902,30 @@ function convertAgnaiMemoryBook(inputObj) {
|
|||||||
return outputObj;
|
return outputObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function convertRisuLorebook(inputObj) {
|
||||||
|
const outputObj = { entries: {} };
|
||||||
|
|
||||||
|
inputObj.data.forEach((entry, index) => {
|
||||||
|
outputObj.entries[index] = {
|
||||||
|
uid: index,
|
||||||
|
key: entry.key.split(',').map(x => x.trim()),
|
||||||
|
keysecondary: entry.secondkey ? entry.secondkey.split(',').map(x => x.trim()) : [],
|
||||||
|
comment: entry.comment,
|
||||||
|
content: entry.content,
|
||||||
|
constant: entry.alwaysActive,
|
||||||
|
selective: entry.selective,
|
||||||
|
order: entry.insertorder,
|
||||||
|
position: world_info_position.before,
|
||||||
|
disable: false,
|
||||||
|
addMemo: true,
|
||||||
|
excludeRecursion: false,
|
||||||
|
displayIndex: index,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return outputObj;
|
||||||
|
}
|
||||||
|
|
||||||
function convertNovelLorebook(inputObj) {
|
function convertNovelLorebook(inputObj) {
|
||||||
const outputObj = {
|
const outputObj = {
|
||||||
entries: {}
|
entries: {}
|
||||||
@ -1055,13 +1079,21 @@ jQuery(() => {
|
|||||||
|
|
||||||
// Convert Novel Lorebook
|
// Convert Novel Lorebook
|
||||||
if (jsonData.lorebookVersion !== undefined) {
|
if (jsonData.lorebookVersion !== undefined) {
|
||||||
|
console.log('Converting Novel Lorebook');
|
||||||
formData.append('convertedData', JSON.stringify(convertNovelLorebook(jsonData)));
|
formData.append('convertedData', JSON.stringify(convertNovelLorebook(jsonData)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert Agnai Memory Book
|
// Convert Agnai Memory Book
|
||||||
if (jsonData.kind === 'memory') {
|
if (jsonData.kind === 'memory') {
|
||||||
|
console.log('Converting Agnai Memory Book');
|
||||||
formData.append('convertedData', JSON.stringify(convertAgnaiMemoryBook(jsonData)));
|
formData.append('convertedData', JSON.stringify(convertAgnaiMemoryBook(jsonData)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert Risu Lorebook
|
||||||
|
if (jsonData.type === 'risu') {
|
||||||
|
console.log('Converting Risu Lorebook');
|
||||||
|
formData.append('convertedData', JSON.stringify(convertRisuLorebook(jsonData)));
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toastr.error(`Error parsing file: ${error}`);
|
toastr.error(`Error parsing file: ${error}`);
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user