Merge branch 'main' into lualore

This commit is contained in:
kwaroran
2025-05-17 01:09:37 +09:00
committed by GitHub
24 changed files with 2573 additions and 682 deletions

View File

@@ -15,6 +15,7 @@ import { Mutex } from "../mutex";
import { tokenize } from "../tokenizer";
import { fetchNative } from "../globalApi.svelte";
import { loadLoreBookV3Prompt } from './lorebook.svelte';
import { getPersonaPrompt, getUserName } from '../util';
let luaFactory:LuaFactory
let LuaSafeIds = new Set<string>()
@@ -461,6 +462,26 @@ export async function runLua(code:string, arg:{
return char.firstMessage
})
luaEngine.global.set('getPersonaName', (id:string) => {
if(!LuaSafeIds.has(id)){
return
}
return getUserName()
})
luaEngine.global.set('getPersonaDescription', (id:string) => {
if(!LuaSafeIds.has(id)){
return
}
const db = getDatabase()
const selectedChar = get(selectedCharID)
const char = db.characters[selectedChar]
return risuChatParser(getPersonaPrompt(), { chara: char })
})
luaEngine.global.set('getBackgroundEmbedding', async (id:string) => {
if(!LuaSafeIds.has(id)){
return