From c6a0c87ad182e5cbe941f497c7ec378640bef1bc Mon Sep 17 00:00:00 2001 From: Martial BE Date: Sat, 27 Apr 2024 17:17:58 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20Handle=20empty=20openaiRe?= =?UTF-8?q?sponse.Choices=20in=20HandlerChatStream?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- providers/openai/chat.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/providers/openai/chat.go b/providers/openai/chat.go index bd1bea6b..574a5f1f 100644 --- a/providers/openai/chat.go +++ b/providers/openai/chat.go @@ -109,6 +109,11 @@ func (h *OpenAIStreamHandler) HandlerChatStream(rawLine *[]byte, dataChan chan s return } + if len(openaiResponse.Choices) == 0 { + *rawLine = nil + return + } + dataChan <- string(*rawLine) if h.isAzure {