From c765cfabad7f71daa97eb6c39a9acb0fc9dfc8f3 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Tue, 27 Aug 2024 16:57:38 +0900 Subject: [PATCH] add hash function to lua --- src/ts/process/lua.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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,