Skip to content

Commit

Permalink
Update stream.js
Browse files Browse the repository at this point in the history
  • Loading branch information
zachey01 committed Jul 30, 2024
1 parent c415f90 commit 6038aec
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Utils/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ async function startStreaming(response, onData) {
chunk = chunk.replace(/^data: /, "");
if (chunk.trim() !== "" && !seenChunks.has(chunk)) {
seenChunks.add(chunk);
if (chunk.trim() === "[DONE]") {
return; // Skip processing [DONE] responses
}
if (chunk.trim() === "[DONE]" || chunk.trim().match(/>\s*p\s*r\s*o\s*v\s*i\s*d\s*e\s*d/i)) {
return; // Skip processing [DONE] or "> provided" (For Nextway) responses
}
try {
let chunkObj = JSON.parse(chunk);
onData(chunkObj.choices[0].delta.content);
Expand Down

0 comments on commit 6038aec

Please sign in to comment.