@@ -830,8 +830,11 @@ async def chat_completion_stream_generator(
830
830
delta_content = ""
831
831
if delta_message .content :
832
832
delta_content = delta_message .content
833
- elif delta_message .tool_calls and delta_message .tool_calls [0 ].function and delta_message .tool_calls [0 ].function .arguments :
834
- delta_content = delta_message .tool_calls [0 ].function .arguments
833
+ elif (delta_message .tool_calls and
834
+ delta_message .tool_calls [0 ].function and
835
+ delta_message .tool_calls [0 ].function .arguments ):
836
+ func_args = delta_message .tool_calls [0 ].function .arguments
837
+ delta_content = func_args
835
838
836
839
if delta_content :
837
840
self .request_logger .log_outputs (
@@ -1200,8 +1203,10 @@ async def chat_completion_full_generator(
1200
1203
tool_call_descriptions = []
1201
1204
for tool_call in choice .message .tool_calls :
1202
1205
if hasattr (tool_call .function , 'name' ) and hasattr (tool_call .function , 'arguments' ):
1203
- tool_call_descriptions .append (f"{ tool_call .function .name } ({ tool_call .function .arguments } )" )
1204
- output_text = f"[tool_calls: { ', ' .join (tool_call_descriptions )} ]"
1206
+ tool_call_descriptions .append (
1207
+ f"{ tool_call .function .name } ({ tool_call .function .arguments } )" )
1208
+ tool_calls_str = ', ' .join (tool_call_descriptions )
1209
+ output_text = f"[tool_calls: { tool_calls_str } ]"
1205
1210
1206
1211
if output_text :
1207
1212
# Get the corresponding output token IDs
0 commit comments