From 717c76f4dd10ce388f24a2ed3d26c9f40c141264 Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Tue, 24 Oct 2023 22:59:49 +0800 Subject: [PATCH] fix: application/json, ignore empty input --- src/chatbox.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chatbox.tsx b/src/chatbox.tsx index 4c5db37..5aad2d6 100644 --- a/src/chatbox.tsx +++ b/src/chatbox.tsx @@ -187,7 +187,7 @@ export default function ChatBOX(props: { const contentType = response.headers.get("content-type"); if (contentType?.startsWith("text/event-stream")) { await _completeWithStreamMode(response); - } else if (contentType === "application/json") { + } else if (contentType?.startsWith("application/json")) { await _completeWithFetchMode(response); } else { throw `unknown response content type ${contentType}`; @@ -211,7 +211,7 @@ export default function ChatBOX(props: { // when user click the "send" button or ctrl+Enter in the textarea const send = async (msg = "") => { - const inputMsg = msg; + const inputMsg = msg.trim(); if (!inputMsg) { console.log("empty message"); return;