From cdb4f6d243032881a773bb71033d8c3f59b84f70 Mon Sep 17 00:00:00 2001 From: HanishKVC Date: Thu, 30 May 2024 04:32:35 +0530 Subject: [PATCH] SimpleChat:theResp-origMsg: Undo a prev change to fix non trim When the response handling was moved into SimpleChat, I had changed a flow bit unnecessarily and carelessly, which resulted in the non trim flow, missing out on retaining the ai assistant response. This has been fixed now. --- examples/server/public_simplechat/simplechat.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/server/public_simplechat/simplechat.js b/examples/server/public_simplechat/simplechat.js index 24a26dbe6..d77e27108 100644 --- a/examples/server/public_simplechat/simplechat.js +++ b/examples/server/public_simplechat/simplechat.js @@ -422,19 +422,19 @@ class SimpleChat { assistant: "", trimmed: "", } - let origMsg; if (gMe.bStream) { try { - origMsg = await this.handle_response_multipart(resp, apiEP, elDiv); + theResp.assistant = await this.handle_response_multipart(resp, apiEP, elDiv); this.latestResponse = ""; } catch (error) { - origMsg = this.latestResponse; + theResp.assistant = this.latestResponse; throw error; } } else { - origMsg = await this.handle_response_oneshot(resp, apiEP); + theResp.assistant = await this.handle_response_oneshot(resp, apiEP); } if (gMe.bTrimGarbage) { + let origMsg = theResp.assistant; theResp.assistant = du.trim_garbage_at_end(origMsg); theResp.trimmed = origMsg.substring(theResp.assistant.length); }