CoolFace
Apppublic

mithiladharankar/smolagents_Web_Search_Agent

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
app.py31 linesDownload Raw Back to root
1import re2import requests3from markdownify import markdownify4from smolagents import ToolCallingAgent, DuckDuckGoSearchTool, HfApiModel, tool5from Gradio_UI import GradioUI6 7@tool8def visit_webpage(url: str) -> str:9    """Fetch a webpage and return readable markdown (truncated)."""10    r = requests.get(url, timeout=15)11    r.raise_for_status()12    md = markdownify(r.text)13    md = re.sub(r"\n{3,}", "\n\n", md)14    return md[:6000]15 16model = HfApiModel(17    model_id="Qwen/Qwen2.5-Coder-32B-Instruct",18    temperature=0.2,19    max_tokens=90020)21 22agent = ToolCallingAgent(23    model=model,24    tools=[DuckDuckGoSearchTool(), visit_webpage],25    max_steps=6,26    name="web_search_agent",27    description="Searches the web + opens pages to answer with evidence."28)29 30GradioUI(agent).launch()31