@@ -3085,32 +3085,52 @@ def show_send_output(self, completion):
30853085
30863086 # Check for tool calls in the non-streaming response
30873087 try :
3088- if completion .choices and completion .choices [0 ].message and completion .choices [0 ].message .tool_calls :
3088+ if (
3089+ completion .choices
3090+ and completion .choices [0 ].message
3091+ and completion .choices [0 ].message .tool_calls
3092+ ):
30893093 self ._register_partial_response (tool_calls = True )
30903094 except (AttributeError , IndexError ):
30913095 pass
30923096
30933097 # Check for function calls in the non-streaming response
30943098 try :
3095- if completion .choices and completion .choices [0 ].message and completion .choices [0 ].message .function_call :
3099+ if (
3100+ completion .choices
3101+ and completion .choices [0 ].message
3102+ and completion .choices [0 ].message .function_call
3103+ ):
30963104 self ._register_partial_response (function_call = True )
30973105 except (AttributeError , IndexError ):
30983106 pass
30993107
31003108 # Check for reasoning content in the non-streaming response
31013109 try :
3102- if completion .choices and completion .choices [0 ].message and completion .choices [0 ].message .reasoning_content :
3110+ if (
3111+ completion .choices
3112+ and completion .choices [0 ].message
3113+ and completion .choices [0 ].message .reasoning_content
3114+ ):
31033115 self ._register_partial_response (reasoning = True )
31043116 except AttributeError :
31053117 try :
3106- if completion .choices and completion .choices [0 ].message and completion .choices [0 ].message .reasoning :
3118+ if (
3119+ completion .choices
3120+ and completion .choices [0 ].message
3121+ and completion .choices [0 ].message .reasoning
3122+ ):
31073123 self ._register_partial_response (reasoning = True )
31083124 except AttributeError :
31093125 pass
31103126
31113127 # Check for regular content in the non-streaming response
31123128 try :
3113- if completion .choices and completion .choices [0 ].message and completion .choices [0 ].message .content :
3129+ if (
3130+ completion .choices
3131+ and completion .choices [0 ].message
3132+ and completion .choices [0 ].message .content
3133+ ):
31143134 self ._register_partial_response (content = True )
31153135 except AttributeError :
31163136 pass
0 commit comments