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.
This commit is contained in:
HanishKVC 2024-05-30 04:32:35 +05:30
parent b75b3db7bf
commit cdb4f6d243

View file

@ -422,19 +422,19 @@ class SimpleChat {
assistant: "", assistant: "",
trimmed: "", trimmed: "",
} }
let origMsg;
if (gMe.bStream) { if (gMe.bStream) {
try { try {
origMsg = await this.handle_response_multipart(resp, apiEP, elDiv); theResp.assistant = await this.handle_response_multipart(resp, apiEP, elDiv);
this.latestResponse = ""; this.latestResponse = "";
} catch (error) { } catch (error) {
origMsg = this.latestResponse; theResp.assistant = this.latestResponse;
throw error; throw error;
} }
} else { } else {
origMsg = await this.handle_response_oneshot(resp, apiEP); theResp.assistant = await this.handle_response_oneshot(resp, apiEP);
} }
if (gMe.bTrimGarbage) { if (gMe.bTrimGarbage) {
let origMsg = theResp.assistant;
theResp.assistant = du.trim_garbage_at_end(origMsg); theResp.assistant = du.trim_garbage_at_end(origMsg);
theResp.trimmed = origMsg.substring(theResp.assistant.length); theResp.trimmed = origMsg.substring(theResp.assistant.length);
} }