remove global regex and lorebook and add convertion to modules
This commit is contained in:
@@ -88,24 +88,6 @@
|
|||||||
<AccessibilityIcon />
|
<AccessibilityIcon />
|
||||||
<span>{language.accessibility}</span>
|
<span>{language.accessibility}</span>
|
||||||
</button>
|
</button>
|
||||||
<button class="flex gap-2 items-center hover:text-textcolor"
|
|
||||||
class:text-textcolor={$SettingsMenuIndex === 8}
|
|
||||||
class:text-textcolor2={$SettingsMenuIndex !== 8}
|
|
||||||
on:click={() => {
|
|
||||||
$SettingsMenuIndex = 8
|
|
||||||
}}>
|
|
||||||
<BookIcon />
|
|
||||||
<span>{language.globalLoreBook}</span>
|
|
||||||
</button>
|
|
||||||
<button class="flex gap-2 items-center hover:text-textcolor"
|
|
||||||
class:text-textcolor={$SettingsMenuIndex === 9}
|
|
||||||
class:text-textcolor2={$SettingsMenuIndex !== 9}
|
|
||||||
on:click={() => {
|
|
||||||
$SettingsMenuIndex = 9
|
|
||||||
}}>
|
|
||||||
<AlignLeft />
|
|
||||||
<span>{language.globalRegexScript}</span>
|
|
||||||
</button>
|
|
||||||
<button class="flex gap-2 items-center hover:text-textcolor"
|
<button class="flex gap-2 items-center hover:text-textcolor"
|
||||||
class:text-textcolor={$SettingsMenuIndex === 14}
|
class:text-textcolor={$SettingsMenuIndex === 14}
|
||||||
class:text-textcolor2={$SettingsMenuIndex !== 14}
|
class:text-textcolor2={$SettingsMenuIndex !== 14}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { calcString } from './process/infunctions';
|
|||||||
import { findCharacterbyId } from './util';
|
import { findCharacterbyId } from './util';
|
||||||
import { getInlayImage } from './image';
|
import { getInlayImage } from './image';
|
||||||
import { autoMarkNew } from './plugins/automark';
|
import { autoMarkNew } from './plugins/automark';
|
||||||
|
import { getModuleLorebooks } from './process/modules';
|
||||||
|
|
||||||
const mconverted = new Marked({
|
const mconverted = new Marked({
|
||||||
gfm: true,
|
gfm: true,
|
||||||
@@ -490,8 +491,7 @@ const matcher = (p1:string,matcherArg:matcherArg) => {
|
|||||||
const chat = selchar.chats[selchar.chatPage]
|
const chat = selchar.chats[selchar.chatPage]
|
||||||
const characterLore = (achara.type === 'group') ? [] : (achara.globalLore ?? [])
|
const characterLore = (achara.type === 'group') ? [] : (achara.globalLore ?? [])
|
||||||
const chatLore = chat.localLore ?? []
|
const chatLore = chat.localLore ?? []
|
||||||
const globalLore = db.loreBook[db.loreBookPage]?.data ?? []
|
const fullLore = characterLore.concat(chatLore.concat(getModuleLorebooks()))
|
||||||
const fullLore = characterLore.concat(chatLore.concat(globalLore))
|
|
||||||
return fullLore.map((f) => {
|
return fullLore.map((f) => {
|
||||||
return JSON.stringify(f)
|
return JSON.stringify(f)
|
||||||
}).join("§\n")
|
}).join("§\n")
|
||||||
|
|||||||
@@ -12,19 +12,7 @@ import { getModuleLorebooks } from "./modules";
|
|||||||
export function addLorebook(type:number) {
|
export function addLorebook(type:number) {
|
||||||
let selectedID = get(selectedCharID)
|
let selectedID = get(selectedCharID)
|
||||||
let db = get(DataBase)
|
let db = get(DataBase)
|
||||||
if(type === -1){
|
if(type === 0){
|
||||||
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){
|
|
||||||
db.characters[selectedID].globalLore.push({
|
db.characters[selectedID].globalLore.push({
|
||||||
key: '',
|
key: '',
|
||||||
comment: `New Lore ${db.characters[selectedID].globalLore.length + 1}`,
|
comment: `New Lore ${db.characters[selectedID].globalLore.length + 1}`,
|
||||||
@@ -71,9 +59,8 @@ export async function loadLoreBookPrompt(){
|
|||||||
const page = char.chatPage
|
const page = char.chatPage
|
||||||
const characterLore = char.globalLore ?? []
|
const characterLore = char.globalLore ?? []
|
||||||
const chatLore = char.chats[page].localLore ?? []
|
const chatLore = char.chats[page].localLore ?? []
|
||||||
const globalLore = db.loreBook[db.loreBookPage]?.data ?? []
|
|
||||||
const moduleLorebook = getModuleLorebooks()
|
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 currentChat = char.chats[page].message
|
||||||
const loreDepth = char.loreSettings?.scanDepth ?? db.loreBookDepth
|
const loreDepth = char.loreSettings?.scanDepth ?? db.loreBookDepth
|
||||||
const loreToken = char.loreSettings?.tokenBudget ?? db.loreBookToken
|
const loreToken = char.loreSettings?.tokenBudget ?? db.loreBookToken
|
||||||
@@ -224,8 +211,7 @@ export async function loadLoreBookPlusPrompt(){
|
|||||||
const page = char.chatPage
|
const page = char.chatPage
|
||||||
const characterLore = char.globalLore ?? []
|
const characterLore = char.globalLore ?? []
|
||||||
const chatLore = char.chats[page].localLore ?? []
|
const chatLore = char.chats[page].localLore ?? []
|
||||||
const globalLore = db.loreBook[db.loreBookPage]?.data ?? []
|
const fullLore = characterLore.concat(chatLore).concat(getModuleLorebooks()).filter((v) => { return v.content })
|
||||||
const fullLore = characterLore.concat(chatLore.concat(globalLore)).filter((v) => { return v.content })
|
|
||||||
const currentChat = char.chats[page].message
|
const currentChat = char.chats[page].message
|
||||||
const loreDepth = char.loreSettings?.scanDepth ?? db.loreBookDepth
|
const loreDepth = char.loreSettings?.scanDepth ?? db.loreBookDepth
|
||||||
const loreToken = char.loreSettings?.tokenBudget ?? db.loreBookToken
|
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
|
const page = mode === 'sglobal' ? -1 : db.characters[selectedID].chatPage
|
||||||
let lore =
|
let lore =
|
||||||
mode === 'global' ? db.characters[selectedID].globalLore :
|
mode === 'global' ? db.characters[selectedID].globalLore :
|
||||||
mode === 'sglobal' ? db.loreBook[db.loreBookPage].data :
|
|
||||||
db.characters[selectedID].chats[page].localLore
|
db.characters[selectedID].chats[page].localLore
|
||||||
const lorebook = (await selectSingleFile(['json', 'lorebook'])).data
|
const lorebook = (await selectSingleFile(['json', 'lorebook'])).data
|
||||||
if(!lorebook){
|
if(!lorebook){
|
||||||
@@ -376,9 +361,6 @@ export async function importLoreBook(mode:'global'|'local'|'sglobal'){
|
|||||||
if(mode === 'global'){
|
if(mode === 'global'){
|
||||||
db.characters[selectedID].globalLore = lore
|
db.characters[selectedID].globalLore = lore
|
||||||
}
|
}
|
||||||
else if(mode === 'sglobal'){
|
|
||||||
db.loreBook[db.loreBookPage].data = lore
|
|
||||||
}
|
|
||||||
else{
|
else{
|
||||||
db.characters[selectedID].chats[page].localLore = lore
|
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 page = mode === 'sglobal' ? -1 : db.characters[selectedID].chatPage
|
||||||
const lore =
|
const lore =
|
||||||
mode === 'global' ? db.characters[selectedID].globalLore :
|
mode === 'global' ? db.characters[selectedID].globalLore :
|
||||||
mode === 'sglobal' ? db.loreBook[db.loreBookPage].data :
|
|
||||||
db.characters[selectedID].chats[page].localLore
|
db.characters[selectedID].chats[page].localLore
|
||||||
const stringl = Buffer.from(JSON.stringify({
|
const stringl = Buffer.from(JSON.stringify({
|
||||||
type: 'risu',
|
type: 'risu',
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { writeBinaryFile,BaseDirectory, readBinaryFile, exists, createDir, readDir, removeFile } from "@tauri-apps/api/fs"
|
import { writeBinaryFile,BaseDirectory, readBinaryFile, exists, createDir, readDir, removeFile } from "@tauri-apps/api/fs"
|
||||||
import { changeFullscreen, checkNullish, findCharacterbyId, sleep } from "../util"
|
import { changeFullscreen, checkNullish, findCharacterbyId, sleep } from "../util"
|
||||||
import { convertFileSrc, invoke } from "@tauri-apps/api/tauri"
|
import { convertFileSrc, invoke } from "@tauri-apps/api/tauri"
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4, v4 } from 'uuid';
|
||||||
import { appDataDir, join } from "@tauri-apps/api/path";
|
import { appDataDir, join } from "@tauri-apps/api/path";
|
||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
import {open} from '@tauri-apps/api/shell'
|
import {open} from '@tauri-apps/api/shell'
|
||||||
@@ -26,6 +26,7 @@ import { saveDbKei } from "../kei/backup";
|
|||||||
import { Capacitor, CapacitorHttp } from '@capacitor/core';
|
import { Capacitor, CapacitorHttp } from '@capacitor/core';
|
||||||
import * as CapFS from '@capacitor/filesystem'
|
import * as CapFS from '@capacitor/filesystem'
|
||||||
import { save } from "@tauri-apps/api/dialog";
|
import { save } from "@tauri-apps/api/dialog";
|
||||||
|
import type { RisuModule } from "../process/modules";
|
||||||
|
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
export const isTauri = !!window.__TAURI__
|
export const isTauri = !!window.__TAURI__
|
||||||
@@ -985,6 +986,43 @@ async function checkNewFormat() {
|
|||||||
|
|
||||||
db.formatversion = 3
|
db.formatversion = 3
|
||||||
}
|
}
|
||||||
|
if(db.formatversion < 4){
|
||||||
|
db.modules ??= []
|
||||||
|
db.enabledModules ??=[]
|
||||||
|
//convert globallore and global regex to modules
|
||||||
|
if(db.globalscript && db.globalscript.length > 0){
|
||||||
|
const id = v4()
|
||||||
|
let regexModule:RisuModule = {
|
||||||
|
name: "Global Regex",
|
||||||
|
description: "Converted from legacy global regex",
|
||||||
|
id: id,
|
||||||
|
regex: cloneDeep(db.globalscript)
|
||||||
|
}
|
||||||
|
db.modules.push(regexModule)
|
||||||
|
db.enabledModules.push(id)
|
||||||
|
db.globalscript = []
|
||||||
|
}
|
||||||
|
if(db.loreBook && db.loreBook.length > 0){
|
||||||
|
const selIndex = db.loreBookPage
|
||||||
|
for(let i=0;i<db.loreBook.length;i++){
|
||||||
|
const id = v4()
|
||||||
|
let lbModule:RisuModule = {
|
||||||
|
name: db.loreBook[i].name || "Unnamed Global Lorebook",
|
||||||
|
description: "Converted from legacy global lorebook",
|
||||||
|
id: id,
|
||||||
|
lorebook: cloneDeep(db.loreBook[i].data)
|
||||||
|
}
|
||||||
|
db.modules.push(lbModule)
|
||||||
|
if(i === selIndex){
|
||||||
|
db.enabledModules.push(id)
|
||||||
|
}
|
||||||
|
db.globalscript = []
|
||||||
|
}
|
||||||
|
db.loreBook = []
|
||||||
|
}
|
||||||
|
|
||||||
|
db.formatversion = 4
|
||||||
|
}
|
||||||
if(!db.characterOrder){
|
if(!db.characterOrder){
|
||||||
db.characterOrder = []
|
db.characterOrder = []
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user