From 1158fdca389f021aaf8718475c64009fcbf63b49 Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Tue, 28 Mar 2023 21:18:30 +0800 Subject: [PATCH] update stream mode based on response --- src/chatbox.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/chatbox.tsx b/src/chatbox.tsx index 98b47bd..29a44b2 100644 --- a/src/chatbox.tsx +++ b/src/chatbox.tsx @@ -109,8 +109,10 @@ export default function ChatBOX(props: { const response = await client._fetch(chatStore.streamMode); const contentType = response.headers.get("content-type"); if (contentType === "text/event-stream") { + chatStore.streamMode = true; await _completeWithStreamMode(response); } else if (contentType === "application/json") { + chatStore.streamMode = false; await _completeWithFetchMode(response); } else { throw `unknown response content type ${contentType}`;