add hash function to lua
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user