From f4fd7cd10f2680aaae2c982e34c00fe81d1baf57 Mon Sep 17 00:00:00 2001 From: cliouo <71540889+cliouo@users.noreply.github.com> Date: Mon, 8 Apr 2024 04:39:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Heartbeat=20data=20skippe?= =?UTF-8?q?d=20every=2015?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix axios library does not support http2 heartbeat data causing errors, manually skip the time string of heartbeat data --- src/app.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app.ts b/src/app.ts index 0746ab2..861791e 100644 --- a/src/app.ts +++ b/src/app.ts @@ -149,6 +149,10 @@ async function handleChatCompletion(req: Request, res: Response) { let created = Date.now(); for await (const message of StreamCompletion(response.data)) { + + // Skip heartbeat detection + if (message.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{6}$/)) continue; + const parsed = JSON.parse(message); let content = parsed?.message?.content?.parts[0] ?? "";