Explorar o código

fix: [azure_openai] Error: 'NoneType' object has no attribute 'content' (#3389)

saga.rey hai 1 ano
pai
achega
b699945b47

+ 6 - 2
api/core/model_runtime/model_providers/azure_openai/llm/llm.py

@@ -343,8 +343,12 @@ class AzureOpenAILargeLanguageModel(_CommonAzureOpenAI, LargeLanguageModel):
 
             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