From 88acc5a614f08d055696750aa74a719efd831f83 Mon Sep 17 00:00:00 2001 From: byte911 <92360792+byte911@users.noreply.github.com> Date: Sun, 22 Sep 2024 16:34:30 +0800 Subject: [PATCH] fix: return the usage info if not null (#1792) Usage is missing. --- relay/adaptor/openai/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/relay/adaptor/openai/main.go b/relay/adaptor/openai/main.go index 9ee547b371..970807384f 100644 --- a/relay/adaptor/openai/main.go +++ b/relay/adaptor/openai/main.go @@ -55,8 +55,8 @@ func StreamHandler(c *gin.Context, resp *http.Response, relayMode int) (*model.E render.StringData(c, data) // if error happened, pass the data to client continue // just ignore the error } - if len(streamResponse.Choices) == 0 { - // but for empty choice, we should not pass it to client, this is for azure + if len(streamResponse.Choices) == 0 && streamResponse.Usage == nil { + // but for empty choice and no usage, we should not pass it to client, this is for azure continue // just ignore empty choice } render.StringData(c, data)