@@ -358,10 +358,8 @@ def _parse_response(self, response: dict) -> dict:
358358 for output in response .output :
359359 if output .type == "function_call" :
360360 arguments = json .loads (output .arguments )
361- result .action = (
362- # f"{output.name}({", ".join([f"{k}={v}" for k, v in arguments.items()])})"
363- f"{ output .name } ({ ', ' .join ([f'{ k } =\" { v } \" ' if isinstance (v , str ) else f'{ k } ={ v } ' for k , v in arguments .items ()])} )"
364- )
361+ func_args_str = ', ' .join ([f'{ k } ="{ v } "' if isinstance (v , str ) else f'{ k } ={ v } ' for k , v in arguments .items ()])
362+ result .action = f"{ output .name } ({ func_args_str } )"
365363 result .tool_calls = output
366364 break
367365 elif output .type == "reasoning" :
@@ -439,7 +437,8 @@ def _parse_response(self, response: openai.types.chat.ChatCompletion) -> LLMOutp
439437 for tool_call in tool_calls :
440438 function = tool_call ["function" ]
441439 arguments = json .loads (function ["arguments" ])
442- output .action = f"{ function ['name' ]} ({ ', ' .join ([f'{ k } =\" { v } \" ' if isinstance (v , str ) else f'{ k } ={ v } ' for k , v in arguments .items ()])} )"
440+ func_args_str = ', ' .join ([f'{ k } ="{ v } "' if isinstance (v , str ) else f'{ k } ={ v } ' for k , v in arguments .items ()])
441+ output .action = f"{ function ['name' ]} ({ func_args_str } )"
443442 output .tool_calls = {
444443 "role" : "assistant" ,
445444 "tool_calls" : [message ["tool_calls" ][0 ]], # Use only the first tool call
@@ -574,7 +573,8 @@ def _parse_response(self, response: dict) -> dict:
574573 )
575574 for output in response .content :
576575 if output .type == "tool_use" :
577- result .action = f"{ output .name } ({ ', ' .join ([f'{ k } =\" { v } \" ' if isinstance (v , str ) else f'{ k } ={ v } ' for k , v in output .input .items ()])} )"
576+ func_args_str = ', ' .join ([f'{ k } ="{ v } "' if isinstance (v , str ) else f'{ k } ={ v } ' for k , v in output .input .items ()])
577+ result .action = f"{ output .name } ({ func_args_str } )"
578578 elif output .type == "text" :
579579 result .think += output .text
580580 return result
0 commit comments