fix: 🐛 Heartbeat data skipped every 15 (#29)

Fix axios library does not support http2 heartbeat data causing errors, manually skip the time string of heartbeat data

Co-authored-by: cliouo <cliouo@163.com>
This commit is contained in:
cliouo
2024-04-08 06:42:46 +08:00
committed by GitHub
parent f2153b0783
commit 2a91042a61

3
app.js
View File

@@ -161,6 +161,9 @@ async function handleChatCompletion(req, res) {
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] || "";