Refactor chat processing logic

This commit is contained in:
kwaroran
2024-03-25 02:57:31 +09:00
parent 98257b2bd6
commit 6fb5b7d6a0

View File

@@ -1026,6 +1026,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
console.log(lastResponseChunk) console.log(lastResponseChunk)
addRerolls(generationId, Object.values(lastResponseChunk)) addRerolls(generationId, Object.values(lastResponseChunk))
db.characters[selectedChar].chats[selectedChat] = runCurrentChatFunction(db.characters[selectedChar].chats[selectedChat])
currentChat = db.characters[selectedChar].chats[selectedChat] currentChat = db.characters[selectedChar].chats[selectedChat]
const triggerResult = await runTrigger(currentChar, 'output', {chat:currentChat}) const triggerResult = await runTrigger(currentChar, 'output', {chat:currentChat})
if(triggerResult && triggerResult.chat){ if(triggerResult && triggerResult.chat){
@@ -1105,6 +1106,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
addRerolls(generationId, mrerolls) addRerolls(generationId, mrerolls)
} }
db.characters[selectedChar].chats[selectedChat] = runCurrentChatFunction(db.characters[selectedChar].chats[selectedChat])
currentChat = db.characters[selectedChar].chats[selectedChat] currentChat = db.characters[selectedChar].chats[selectedChat]
const triggerResult = await runTrigger(currentChar, 'output', {chat:currentChat}) const triggerResult = await runTrigger(currentChar, 'output', {chat:currentChat})
@@ -1114,7 +1116,6 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
} }
} }
db.characters[selectedChar].chats[selectedChat] = runCurrentChatFunction(db.characters[selectedChar].chats[selectedChat])
sendPeerChar() sendPeerChar()
if(req.special){ if(req.special){