fix: #507 break cjk chars in stream mode

This commit is contained in:
Yidadaa 2023-04-10 23:13:20 +08:00
parent 8df8ee8936
commit 7aee53ea05
2 changed files with 2 additions and 2 deletions

View File

@ -40,7 +40,7 @@ async function createStream(req: NextRequest) {
const parser = createParser(onParse);
for await (const chunk of res.body as any) {
parser.feed(decoder.decode(chunk));
parser.feed(decoder.decode(chunk, { stream: true }));
}
},
});

View File

@ -171,7 +171,7 @@ export async function requestChatStream(
const resTimeoutId = setTimeout(() => finish(), TIME_OUT_MS);
const content = await reader?.read();
clearTimeout(resTimeoutId);
const text = decoder.decode(content?.value);
const text = decoder.decode(content?.value, { stream: true });
responseText += text;
const done = !content || content.done;