Lesson 2 — Setting Up Your Tools
You need two things: a way for the AI to search the web, and a way for it to read web pages.
Lesson 2 — Setting Up Your Tools
You need two things: a way for the AI to search the web, and a way for it to read web pages.
Install dependencies:
pip install anthropic tavily-python requests beautifulsoup4
Get your API keys:
Create a `.env` file:
ANTHROPIC_API_KEY=your_key_here
TAVILY_API_KEY=your_key_here
Define your tools in Python:
import os
import anthropic
from tavily import TavilyClient
import requests
from bs4 import BeautifulSoup
anthropic_client = anthropic.Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])
tavily_client = TavilyClient(api_key=os.environ["TAVILY_API_KEY"])
def search_web(query: str, max_results: int = 5) -> list:
def read_page(url: str) -> str:
These two functions are your agent's eyes and hands. The AI will call them as it sees fit.