From 7355ab37035c680219153b12911f9d7549ac0c6d Mon Sep 17 00:00:00 2001 From: Anuraag Agrawal Date: Thu, 3 Oct 2024 13:02:50 +0900 Subject: [PATCH] Return empty choices on usage chunk --- openai/openai.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openai/openai.go b/openai/openai.go index f5e9dbe9146..97f8b23b970 100644 --- a/openai/openai.go +++ b/openai/openai.go @@ -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 } @@ -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 }