This commit is contained in:
Archer
2023-03-15 21:36:56 +08:00
parent be69cfb966
commit 7529f51e72
7 changed files with 196 additions and 172 deletions

View File

@@ -103,9 +103,14 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
}
};
for await (const chunk of chatResponse.data as any) {
const parser = createParser(onParse);
parser.feed(decodeURIComponent(chunk));
const decoder = new TextDecoder();
try {
for await (const chunk of chatResponse.data as any) {
const parser = createParser(onParse);
parser.feed(decoder.decode(chunk));
}
} catch (error) {
console.log('pipe error', error);
}
pass.push(null);
} catch (err: any) {