From 5bd946fbdda46c41cd735e105fa0634a72762afc Mon Sep 17 00:00:00 2001 From: JxQggg Date: Mon, 5 Aug 2024 10:34:44 +0800 Subject: [PATCH] fix(chatgpt): Resolve async response issue with Azure GPT-4o API (#1772) --- dbgpt/model/proxy/llms/chatgpt.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dbgpt/model/proxy/llms/chatgpt.py b/dbgpt/model/proxy/llms/chatgpt.py index 604ee83c7..afbb22ace 100755 --- a/dbgpt/model/proxy/llms/chatgpt.py +++ b/dbgpt/model/proxy/llms/chatgpt.py @@ -262,6 +262,9 @@ async def generate_stream_v1( async for r in chat_completion: if len(r.choices) == 0: continue + # Check for empty 'choices' issue in Azure GPT-4o responses + if r.choices[0] is not None and r.choices[0].delta is None: + continue if r.choices[0].delta.content is not None: content = r.choices[0].delta.content text += content