in src/smolagents/agents.py [0:0]
def process_single_tool_call(tool_call: ToolCall) -> ToolOutput:
tool_name = tool_call.name
tool_arguments = tool_call.arguments or {}
self.logger.log(
Panel(Text(f"Calling tool: '{tool_name}' with arguments: {tool_arguments}")),
level=LogLevel.INFO,
)
tool_call_result = self.execute_tool_call(tool_name, tool_arguments)
tool_call_result_type = type(tool_call_result)
if tool_call_result_type in [AgentImage, AgentAudio]:
if tool_call_result_type == AgentImage:
observation_name = "image.png"
elif tool_call_result_type == AgentAudio:
observation_name = "audio.mp3"
# TODO: tool_call_result naming could allow for different names of same type
self.state[observation_name] = tool_call_result
observation = f"Stored '{observation_name}' in memory."
else:
observation = str(tool_call_result).strip()
self.logger.log(
f"Observations: {observation.replace('[', '|')}", # escape potential rich-tag-like components
level=LogLevel.INFO,
)
is_final_answer = tool_name == "final_answer"
return ToolOutput(
id=tool_call.id,
output=tool_call_result,
is_final_answer=is_final_answer,
observation=observation,
tool_call=tool_call,
)