From 614f7b2f17074fcb98b9140f61f5e7b491a36940 Mon Sep 17 00:00:00 2001 From: Kwaroran Date: Fri, 31 Jan 2025 17:39:34 +0900 Subject: [PATCH] fix: improve error handling in chat message logging --- src/ts/process/index.svelte.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/ts/process/index.svelte.ts b/src/ts/process/index.svelte.ts index 1a52fc72..7ec06c09 100644 --- a/src/ts/process/index.svelte.ts +++ b/src/ts/process/index.svelte.ts @@ -105,13 +105,19 @@ export async function sendChat(chatProcessIndex = -1,arg:{ function throwError(error:string){ if(DBState.db.inlayErrorResponse){ - DBState.db.characters[selectedChar].chats[selectedChat].message.push({ - role: 'char', - data: `\`\`\`risuerror\n${error}\n\`\`\``, - saying: currentChar.chaId, - time: Date.now(), - generationInfo, - }) + if(DBState.db.characters[selectedChar].chats[selectedChat].message[DBState.db.characters[selectedChar].chats[selectedChat].message.length - 1].role === 'char'){ + DBState.db.characters[selectedChar].chats[selectedChat].message[DBState.db.characters[selectedChar].chats[selectedChat].message.length - 1].data += `\n\`\`\`risuerror\n${error}\n\`\`\`` + } + else{ + + DBState.db.characters[selectedChar].chats[selectedChat].message.push({ + role: 'char', + data: `\`\`\`risuerror\n${error}\n\`\`\``, + saying: currentChar.chaId, + time: Date.now(), + generationInfo, + }) + } return }