mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-16 08:01:18 +00:00
perf: stream
This commit is contained in:
@@ -146,13 +146,13 @@ export const gpt35StreamResponse = ({
|
|||||||
|
|
||||||
const decoder = new TextDecoder();
|
const decoder = new TextDecoder();
|
||||||
try {
|
try {
|
||||||
|
const parser = createParser(onParse);
|
||||||
for await (const chunk of chatResponse.data as any) {
|
for await (const chunk of chatResponse.data as any) {
|
||||||
if (stream.destroyed) {
|
if (stream.destroyed) {
|
||||||
// 流被中断了,直接忽略后面的内容
|
// 流被中断了,直接忽略后面的内容
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const parser = createParser(onParse);
|
parser.feed(decoder.decode(chunk, { stream: true }));
|
||||||
parser.feed(decoder.decode(chunk));
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('pipe error', error);
|
console.log('pipe error', error);
|
||||||
|
Reference in New Issue
Block a user