@@ -96,8 +96,8 @@ def extract_tool_calls(
9696 tool_calls = []
9797 for match in function_call_tuples :
9898 function_id , function_args = match
99- # function_id: functions.get_weather:0
100- function_name = function_id .split (". " )[1 ].split (": " )[0 ]
99+ # function_id: functions.get_weather:0 or get_weather:0
100+ function_name = function_id .split (": " )[0 ].split (". " )[- 1 ]
101101 tool_calls .append (
102102 ToolCall (
103103 id = function_id ,
@@ -254,7 +254,7 @@ def extract_tool_calls_streaming(
254254 )
255255 if current_tool_call_matches :
256256 tool_id , tool_args = current_tool_call_matches .groups ()
257- tool_name = tool_id .split (". " )[1 ].split (": " )[0 ]
257+ tool_name = tool_id .split (": " )[0 ].split (". " )[- 1 ]
258258 current_tool_call ["id" ] = tool_id
259259 current_tool_call ["name" ] = tool_name
260260 current_tool_call ["arguments" ] = tool_args
@@ -264,7 +264,7 @@ def extract_tool_calls_streaming(
264264 )
265265 if current_tool_call_name_matches :
266266 (tool_id_str ,) = current_tool_call_name_matches .groups ()
267- tool_name = tool_id_str .split (". " )[1 ].split (": " )[0 ]
267+ tool_name = tool_id_str .split (": " )[0 ].split (". " )[- 1 ]
268268 current_tool_call ["id" ] = tool_id_str
269269 current_tool_call ["name" ] = tool_name
270270 current_tool_call ["arguments" ] = ""
0 commit comments