Skip to content

Commit

Permalink
chore: only return usage in last stream chunk for pplx
Browse files Browse the repository at this point in the history
  • Loading branch information
VisargD committed Jan 29, 2025
1 parent dbbebe3 commit 77c3604
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/providers/perplexity-ai/chatComplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ export const PerplexityAIChatCompleteStreamChunkTransform: (
finish_reason: parsedChunk.choices[0]?.finish_reason,
},
],
...(parsedChunk.usage && { usage: parsedChunk.usage }),
...(parsedChunk.usage &&
parsedChunk.choices[0]?.finish_reason && { usage: parsedChunk.usage }),
})}` + '\n\n';

if (parsedChunk.choices[0]?.finish_reason)
Expand Down

0 comments on commit 77c3604

Please sign in to comment.