chore: fix trimmed end break line

This commit is contained in:
Louis 2023-09-29 15:11:36 +07:00 committed by Louis
parent a0afdda16e
commit 706e8e9c78
2 changed files with 5 additions and 5 deletions

View File

@ -48,7 +48,7 @@ export default function renderChatMessage({
avatarUrl={senderAvatarUrl}
senderName={senderName}
createdAt={createdAt}
text={htmlText ?? text}
text={htmlText && htmlText.trim().length > 0 ? htmlText : text}
/>
) : (
<StreamTextMessage
@ -57,7 +57,7 @@ export default function renderChatMessage({
avatarUrl={senderAvatarUrl}
senderName={senderName}
createdAt={createdAt}
text={htmlText ?? text}
text={htmlText && htmlText.trim().length > 0 ? htmlText : text}
/>
);
default:

View File

@ -116,7 +116,7 @@ export default function useSendChatMessage() {
const data = JSON.parse(line.replace("data: ", ""));
answer += data.choices[0]?.delta?.content ?? "";
if (answer.startsWith("assistant: ")) {
answer = answer.replace("assistant: ", "").trim();
answer = answer.replace("assistant: ", "");
}
updateStreamMessage({
...responseChatMessage,
@ -133,11 +133,11 @@ export default function useSendChatMessage() {
updateMessage(
responseChatMessage.id,
responseChatMessage.conversationId,
answer
answer.trimEnd()
);
await executeSerial(DataService.UPDATE_MESSAGE, {
...newResponse,
message: answer,
message: answer.trimEnd(),
updated_at: new Date()
.toISOString()
.replace("T", " ")