Spaces:
Sleeping
Sleeping
File size: 1,142 Bytes
99ca1a9 b0394f8 99ca1a9 f1fb3af e5cbdce 1e30ae2 e5cbdce d604728 f1fb3af 99ca1a9 d604728 99ca1a9 d604728 1e30ae2 d604728 f1fb3af |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
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"
)
|