From b699945b47723c15f028abc0a458f52f907a67d6 Mon Sep 17 00:00:00 2001 From: "saga.rey" Date: Fri, 12 Apr 2024 14:44:17 +0800 Subject: [PATCH] fix: [azure_openai] Error: 'NoneType' object has no attribute 'content' (#3389) --- .../model_runtime/model_providers/azure_openai/llm/llm.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api/core/model_runtime/model_providers/azure_openai/llm/llm.py b/api/core/model_runtime/model_providers/azure_openai/llm/llm.py index 4b89adaa49beb0..eb6d985f230b8e 100644 --- a/api/core/model_runtime/model_providers/azure_openai/llm/llm.py +++ b/api/core/model_runtime/model_providers/azure_openai/llm/llm.py @@ -343,8 +343,12 @@ def _handle_chat_generate_stream_response(self, model: str, credentials: dict, delta = chunk.choices[0] - if delta.finish_reason is None and (delta.delta.content is None or delta.delta.content == '') and \ - delta.delta.function_call is None: + # Handling exceptions when content filters' streaming mode is set to asynchronous modified filter + if delta.delta is None or ( + delta.finish_reason is None + and (delta.delta.content is None or delta.delta.content == '') + and delta.delta.function_call is None + ): continue # assistant_message_tool_calls = delta.delta.tool_calls