Skip to content

Commit

Permalink
Merge pull request ChatGPTNextWeb#721 from helloworld-xdy/main
Browse files Browse the repository at this point in the history
fix:修复正常响应结果后额外追加‘出错了,请稍后再试’bug
  • Loading branch information
Yidadaa authored Apr 11, 2023
2 parents 3f2a8cc + d8ef4a1 commit 88fff82
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,15 @@ export async function requestChatStream(
const resTimeoutId = setTimeout(() => finish(), TIME_OUT_MS);
const content = await reader?.read();
clearTimeout(resTimeoutId);
const text = decoder.decode(content?.value, { stream: true });

if (!content || !content.value) {
break;
}

const text = decoder.decode(content.value, { stream: true });
responseText += text;

const done = !content || content.done;
const done = content.done;
options?.onMessage(responseText, false);

if (done) {
Expand Down

0 comments on commit 88fff82

Please sign in to comment.