Spaces:
Runtime error
Runtime error
Download agents/__init__.py from coollad49/First_agent_template: direct link, hf CLI and curl.
- Browser
- Download file 976 Bytes
-
https://huggingface.co/spaces/coollad49/First_agent_template/resolve/main/agents/__init__.py
- Command line
-
hf download hf://spaces/coollad49/First_agent_template/agents/__init__.py
-
curl -L -o __init__.py https://huggingface.co/spaces/coollad49/First_agent_template/resolve/main/agents/__init__.py
976 Bytes
| from smolagents import ToolCallingAgent, DuckDuckGoSearchTool, VisitWebpageTool, CodeAgent, OpenAIServerModel | |
| from dotenv import load_dotenv | |
| import os | |
| load_dotenv() | |
| openrouter_api_key = os.environ.get("OPENROUTER_API_KEY") | |
| model = OpenAIServerModel( | |
| model_id="google/gemini-2.0-flash-lite-preview-02-05:free", # or any other OpenRouter model | |
| api_base="https://openrouter.ai/api/v1", | |
| api_key=openrouter_api_key, | |
| custom_role_conversions=None, | |
| max_tokens=2096, | |
| temperature=0.5, | |
| ) | |
| def web_agent(): | |
| """ | |
| This function returns a web agent that uses the DuckDuckGoSearchTool and VisitWebpageTool to search for a query and visit a webpage. | |
| """ | |
| # Use the DuckDuckGoSearchTool to search for the query | |
| return CodeAgent( | |
| model=model, | |
| tools=[DuckDuckGoSearchTool(), VisitWebpageTool()], | |
| name="web_agent", | |
| description="Browses the web to find information", | |
| verbosity_level=0, | |
| max_steps=10, | |
| ) |