diff --git a/src/ts/process/lua.ts b/src/ts/process/lua.ts index 60b7694d..f1d5de25 100644 --- a/src/ts/process/lua.ts +++ b/src/ts/process/lua.ts @@ -1,4 +1,4 @@ -import { getChatVar, risuChatParser, setChatVar, type simpleCharacterArgument } from "../parser"; +import { getChatVar, hasher, risuChatParser, setChatVar, type simpleCharacterArgument } from "../parser"; import { LuaEngine, LuaFactory } from "wasmoon"; import { DataBase, setDatabase, type Chat, type character, type groupChat } from "../storage/database"; import { get } from "svelte/store"; @@ -222,6 +222,10 @@ export async function runLua(code:string, arg:{ return `{{inlay::${inlay}}}` }) + luaEngine.global.set('hash', async (id:string, value:string) => { + return await hasher(new TextEncoder().encode(value)) + }) + luaEngine.global.set('LLMMain', async (id:string, promptStr:string) => { let prompt:{ role: string,