Skip to content

Commit

Permalink
fix: 🐛 Heartbeat data skipped every 15 (missuo#29)
Browse files Browse the repository at this point in the history
Fix axios library does not support http2 heartbeat data causing errors, manually skip the time string of heartbeat data

Co-authored-by: cliouo <[email protected]>
  • Loading branch information
2 people authored and lxzh committed Apr 11, 2024
1 parent f2153b0 commit ec8c862
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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] || "";
Expand Down

0 comments on commit ec8c862

Please sign in to comment.