Skip to content

Commit

Permalink
Merge branch 'openai-stream-usage' into testing
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraaga committed Oct 3, 2024
2 parents e27a487 + 7355ab3 commit a1bc986
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions openai/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ func (w *ChatWriter) writeResponse(data []byte) (int, error) {
if chatResponse.Done {
if w.streamUsage {
u := toUsage(chatResponse)
d, err := json.Marshal(ChatCompletionChunk{Usage: &u})
d, err := json.Marshal(ChatCompletionChunk{Choices: []ChunkChoice{}, Usage: &u})
if err != nil {
return 0, err
}
Expand Down Expand Up @@ -711,7 +711,7 @@ func (w *CompleteWriter) writeResponse(data []byte) (int, error) {
if generateResponse.Done {
if w.streamUsage {
u := toUsageGenerate(generateResponse)
d, err := json.Marshal(CompletionChunk{Usage: &u})
d, err := json.Marshal(CompletionChunk{Choices: []CompleteChunkChoice{}, Usage: &u})
if err != nil {
return 0, err
}
Expand Down

0 comments on commit a1bc986

Please sign in to comment.