update stream mode based on response

This commit is contained in:
2023-03-28 21:18:30 +08:00
parent 7c34379ecb
commit 1158fdca38

View File

@@ -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}`;