Spaces:
Runtime error
Runtime error
File size: 976 Bytes
0cbdd47 97c2a16 0cbdd47 97c2a16 0cbdd47 97c2a16 0cbdd47 97c2a16 0cbdd47 97c2a16 | 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 | 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,
) |