remove global regex and lorebook and add convertion to modules

This commit is contained in:
kwaroran
2024-02-07 02:50:18 +09:00
parent e414b317d1
commit 8ed4555b2f
4 changed files with 44 additions and 43 deletions

View File

@@ -12,19 +12,7 @@ import { getModuleLorebooks } from "./modules";
export function addLorebook(type:number) {
let selectedID = get(selectedCharID)
let db = get(DataBase)
if(type === -1){
db.loreBook[db.loreBookPage].data.push({
key: '',
comment: `New Lore ${db.loreBook[db.loreBookPage].data.length + 1}`,
content: '',
mode: 'normal',
insertorder: 100,
alwaysActive: false,
secondkey: "",
selective: false
})
}
else if(type === 0){
if(type === 0){
db.characters[selectedID].globalLore.push({
key: '',
comment: `New Lore ${db.characters[selectedID].globalLore.length + 1}`,
@@ -71,9 +59,8 @@ export async function loadLoreBookPrompt(){
const page = char.chatPage
const characterLore = char.globalLore ?? []
const chatLore = char.chats[page].localLore ?? []
const globalLore = db.loreBook[db.loreBookPage]?.data ?? []
const moduleLorebook = getModuleLorebooks()
const fullLore = characterLore.concat(chatLore).concat(moduleLorebook).concat(globalLore)
const fullLore = characterLore.concat(chatLore).concat(moduleLorebook)
const currentChat = char.chats[page].message
const loreDepth = char.loreSettings?.scanDepth ?? db.loreBookDepth
const loreToken = char.loreSettings?.tokenBudget ?? db.loreBookToken
@@ -224,8 +211,7 @@ export async function loadLoreBookPlusPrompt(){
const page = char.chatPage
const characterLore = char.globalLore ?? []
const chatLore = char.chats[page].localLore ?? []
const globalLore = db.loreBook[db.loreBookPage]?.data ?? []
const fullLore = characterLore.concat(chatLore.concat(globalLore)).filter((v) => { return v.content })
const fullLore = characterLore.concat(chatLore).concat(getModuleLorebooks()).filter((v) => { return v.content })
const currentChat = char.chats[page].message
const loreDepth = char.loreSettings?.scanDepth ?? db.loreBookDepth
const loreToken = char.loreSettings?.tokenBudget ?? db.loreBookToken
@@ -317,7 +303,6 @@ export async function importLoreBook(mode:'global'|'local'|'sglobal'){
const page = mode === 'sglobal' ? -1 : db.characters[selectedID].chatPage
let lore =
mode === 'global' ? db.characters[selectedID].globalLore :
mode === 'sglobal' ? db.loreBook[db.loreBookPage].data :
db.characters[selectedID].chats[page].localLore
const lorebook = (await selectSingleFile(['json', 'lorebook'])).data
if(!lorebook){
@@ -376,9 +361,6 @@ export async function importLoreBook(mode:'global'|'local'|'sglobal'){
if(mode === 'global'){
db.characters[selectedID].globalLore = lore
}
else if(mode === 'sglobal'){
db.loreBook[db.loreBookPage].data = lore
}
else{
db.characters[selectedID].chats[page].localLore = lore
}
@@ -395,7 +377,6 @@ export async function exportLoreBook(mode:'global'|'local'|'sglobal'){
const page = mode === 'sglobal' ? -1 : db.characters[selectedID].chatPage
const lore =
mode === 'global' ? db.characters[selectedID].globalLore :
mode === 'sglobal' ? db.loreBook[db.loreBookPage].data :
db.characters[selectedID].chats[page].localLore
const stringl = Buffer.from(JSON.stringify({
type: 'risu',