add hash function to lua

This commit is contained in:
kwaroran
2024-08-27 16:57:38 +09:00
parent c141f9398e
commit c765cfabad

View File

@@ -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,