Spaces:
Sleeping
Sleeping
File size: 740 Bytes
38ac685 333cfd3 38ac685 333cfd3 38ac685 333cfd3 38ac685 333cfd3 38ac685 333cfd3 38ac685 | 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 | import os
from smolagents import CodeAgent, LiteLLMModel, PythonInterpreterTool, GoogleSearchTool
ANTHROPIC_API_KEY = os.getenv("ANTHROPIC_API_KEY")
def create_agent():
model = LiteLLMModel(
model_id="claude-sonnet-4-20250514",
api_key=ANTHROPIC_API_KEY,
)
available_tools = []
# pw_mcp = PlaywrightMCP()
# available_tools = pw_mcp.get_tools()
available_tools.append(PythonInterpreterTool())
available_tools.append(GoogleSearchTool())
agent = CodeAgent(
tools=available_tools,
model=model,
add_base_tools=True,
)
# agent._pw_mcp = pw_mcp
return agent
def cleanup_agent(agent):
if hasattr(agent, '_pw_mcp'):
agent._pw_mcp.disconnect() |