From 12606e30a1ecde40d62a37bd3213ff3d573ddd13 Mon Sep 17 00:00:00 2001 From: thanseefpp Date: Fri, 8 Sep 2023 15:51:33 +0400 Subject: [PATCH 1/2] Streaming AIApplication error with Azure OpenAI API #541 fixed --- src/marvin/engine/language_models/openai.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/marvin/engine/language_models/openai.py b/src/marvin/engine/language_models/openai.py index 127953fb2..88bb8ec7c 100644 --- a/src/marvin/engine/language_models/openai.py +++ b/src/marvin/engine/language_models/openai.py @@ -48,7 +48,10 @@ async def handle_streaming_response( async for r in api_response: response["llm_response"] = r.to_dict_recursive() - delta = r.choices[0].delta + delta = r.choices[0].delta if r.choices and r.choices[0] else None + + if delta is None: + continue if "role" in delta: response["role"] = delta.role From f0f352150e1086ae8edcadea9b70e8eaa2614bbe Mon Sep 17 00:00:00 2001 From: thanseefpp Date: Fri, 8 Sep 2023 22:52:47 +0400 Subject: [PATCH 2/2] Streaming AIApplication error with Azure OpenAI API #541 fixed, pre-commit executed --- src/marvin/engine/language_models/openai.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/marvin/engine/language_models/openai.py b/src/marvin/engine/language_models/openai.py index 88bb8ec7c..f0ee94409 100644 --- a/src/marvin/engine/language_models/openai.py +++ b/src/marvin/engine/language_models/openai.py @@ -49,7 +49,7 @@ async def handle_streaming_response( response["llm_response"] = r.to_dict_recursive() delta = r.choices[0].delta if r.choices and r.choices[0] else None - + if delta is None: continue