Skip to content

Commit

Permalink
chore: sending usage details if present for stream chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
Sai Krishna authored and Sai Krishna committed Apr 3, 2024
1 parent 71df568 commit 7c0bf84
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/providers/fireworks-ai/chatComplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ export interface FireworksAIStreamChunk {
index: number;
finish_reason: string | null;
}[];
usage: null | {
prompt_tokens: number;
completion_tokens: number;
total_tokens: number;
};
}

export const FireworksAIErrorResponseTransform: (
Expand Down Expand Up @@ -200,6 +205,7 @@ export const FireworksAIChatCompleteStreamChunkTransform: (
finish_reason: parsedChunk.choices[0].finish_reason,
},
],
...(parsedChunk.usage ? { usage: parsedChunk.usage } : {}),
})}` + '\n\n'
);
};
1 change: 1 addition & 0 deletions src/providers/fireworks-ai/complete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export const FireworksAICompleteStreamChunkTransform: (
finish_reason: parsedChunk.choices[0].finish_reason,
},
],
...(parsedChunk.usage ? { usage: parsedChunk.usage } : {}),
})}` + '\n\n'
);
};

0 comments on commit 7c0bf84

Please # to comment.