Get startedGet started for free

Let Agents Search the Web

Your friend wants to send $500 to her sister in New York but isn't sure if the exchange rate is still favorable. She remembers seeing “1 GBP → 1.24 USD” last week, but exchange rates can change daily.

To help her make a smart decision, you decide to build a code agent that can:

  • Look up live GBP -> USD rate
  • Summarize how the rate has changed over the past 7 days

You'll give your agent web search powers using the built-in VisitWebpageTool.

Note: The model has been initialized for you. The CodeAgent class has been imported as well.

This exercise is part of the course

AI Agents with Hugging Face smolagents

View Course

Exercise instructions

  • Import the VisitWebpageTool from the smolagents library.
  • Create the agent using the provided model and a tools list that includes an instance of VisitWebpageTool().
  • Run the agent using the .run() method and pass in the task.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Import the VisitWebpageTool class
from smolagents import ____

# Create agent with web search capabilities
agent = CodeAgent(
    tools=[____],
    model=model
)

task = "Find GBP to USD exchange rates and summarize how this rate has changed over the past 7 days. A good source is usually Wise."

# Run the agent with the task
result = agent.run(____)
Edit and Run Code