import os import smolagents import smolagents.models def generate_tool_calling_agent_with_tools( tools=None, name: str = "tool_calling_agent_without_tools" ): """ Create a JSON tool-calling agent with specified tools. """ if tools is None: tools = [] return smolagents.ToolCallingAgent( name=name, model=smolagents.models.OpenAIServerModel( model_id=os.getenv("AGENT_MODEL", ""), api_base=os.getenv("UPSTREAM_OPENAI_BASE", "").rstrip("/"), api_key=os.getenv("OPENAI_API_KEY"), ), tools=tools, add_base_tools=False, max_steps=4, verbosity_level=int( os.getenv("AGENT_VERBOSITY", "1") ), # quieter by default; override via env ) def generate_tool_calling_agent_with_search_and_code(): """ Create a code-writing agent without any extra tools. """ tools = [ smolagents.WebSearchTool(max_results=5), smolagents.PythonInterpreterTool(), ] return generate_tool_calling_agent_with_tools( tools, name="tool_calling_agent_with_search_and_code" )