# # SPDX-FileCopyrightText: Hadad # SPDX-License-Identifier: Apache-2.0 # from config import REASONING_STEPS def tool_reasoning(tool_name, tool_arguments, stage, error=None, result=None): if tool_name == "web_search": if stage == "completed": preview = result[:300] + "..." if result and len(result) > 300 else result return REASONING_STEPS["web_search"][stage].format( query=tool_arguments.get("query", "") if tool_arguments else "", engine=tool_arguments.get("engine", "google") if tool_arguments else "google", preview=preview ) elif stage == "error": return REASONING_STEPS["web_search"][stage].format( query=tool_arguments.get("query", "") if tool_arguments else "", engine=tool_arguments.get("engine", "google") if tool_arguments else "google", error=error ) else: return REASONING_STEPS["web_search"][stage].format( query=tool_arguments.get("query", "") if tool_arguments else "", engine=tool_arguments.get("engine", "google") if tool_arguments else "google" ) elif tool_name == "read_url": if stage == "completed": preview = result[:300] + "..." if result and len(result) > 300 else result return REASONING_STEPS["read_url"][stage].format( url=tool_arguments.get("url", "") if tool_arguments else "", preview=preview ) elif stage == "error": return REASONING_STEPS["read_url"][stage].format( url=tool_arguments.get("url", "") if tool_arguments else "", error=error ) else: return REASONING_STEPS["read_url"][stage].format( url=tool_arguments.get("url", "") if tool_arguments else "" )