forked from XiaoMo/ChatGPT-Next-Web
fix: #507 break cjk chars in stream mode
This commit is contained in:
parent
8df8ee8936
commit
7aee53ea05
@ -40,7 +40,7 @@ async function createStream(req: NextRequest) {
|
|||||||
|
|
||||||
const parser = createParser(onParse);
|
const parser = createParser(onParse);
|
||||||
for await (const chunk of res.body as any) {
|
for await (const chunk of res.body as any) {
|
||||||
parser.feed(decoder.decode(chunk));
|
parser.feed(decoder.decode(chunk, { stream: true }));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -171,7 +171,7 @@ export async function requestChatStream(
|
|||||||
const resTimeoutId = setTimeout(() => finish(), TIME_OUT_MS);
|
const resTimeoutId = setTimeout(() => finish(), TIME_OUT_MS);
|
||||||
const content = await reader?.read();
|
const content = await reader?.read();
|
||||||
clearTimeout(resTimeoutId);
|
clearTimeout(resTimeoutId);
|
||||||
const text = decoder.decode(content?.value);
|
const text = decoder.decode(content?.value, { stream: true });
|
||||||
responseText += text;
|
responseText += text;
|
||||||
|
|
||||||
const done = !content || content.done;
|
const done = !content || content.done;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user