[test] lua code dummy, for future

This commit is contained in:
kwaroran
2023-06-22 22:00:42 +09:00
parent 4447da7a6b
commit 0de412414f
5 changed files with 51 additions and 3 deletions

View File

@@ -159,7 +159,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
}
if(!currentChar.utilityBot){
const mainp = currentChar.systemPrompt || db.mainPrompt
const mainp = currentChar.systemPrompt.replaceAll('{{original}}', db.mainPrompt) || db.mainPrompt
function formatPrompt(data:string){
@@ -188,7 +188,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
unformated.jailbreak.push(...formatPrompt(replacePlaceholders(db.jailbreak, currentChar.name)))
}
unformated.globalNote.push(...formatPrompt(replacePlaceholders(currentChar.replaceGlobalNote || db.globalNote, currentChar.name)))
unformated.globalNote.push(...formatPrompt(replacePlaceholders(currentChar.replaceGlobalNote.replaceAll('{{original}}', db.globalNote) || db.globalNote, currentChar.name)))
}
if(currentChat.note){

33
src/ts/process/lua.ts Normal file
View File

@@ -0,0 +1,33 @@
import { get } from "svelte/store";
import { DataBase, type character } from "../storage/database";
import type {LuaEngine} from 'wasmoon'
import { selectedCharID } from "../stores";
let lua: LuaEngine = null
export class CharacterLua{
char:character
constructor(char:character){
this.char = char
}
async init(){
if(!lua){
const factory = new (await import("wasmoon")).LuaFactory
lua = await factory.createEngine()
lua.global.set('getChat', () => {
const cha = get(DataBase).characters[get(selectedCharID)]
return cha.chats[cha.chatPage].message
})
lua.global.set('setChat', () => {
const cha = get(DataBase).characters[get(selectedCharID)]
return cha.chats[cha.chatPage].message
})
lua.global.set('doSend', (a:string) => {
console.log(a)
})
}
}
}