Welcome! This beginner-friendly workshop will teach you how to build AI assistants (agents) powered by large language models like Claude. You'll start with simple agents and gradually build more advanced features - no prior AI experience required!
In this step-by-step workshop, you'll learn how to:
- Create AI agents that can use tools and run code
- Connect your agents to external services like Notion and image generators
- Build systems where multiple AI agents work together
- Create user-friendly web interfaces for your agents
- Let your agents browse the web and interact with websites
AI agents are programs that use large language models (LLMs) like Claude or GPT to:
- Understand natural language requests
- Plan how to complete tasks
- Use tools and services to accomplish goals
- Communicate results back to humans
Think of them as smart assistants that can perform tasks for you by combining AI with access to various tools.
This workshop includes 7 progressive tutorials, each building on the previous one:
- Basic Agent: A simple AI assistant that can answer questions
- Custom Tools: Add capabilities like creating files to your agent
- External Services: Connect your agent to image generation tools
- Multiple Services: Let your agent use both Notion and image generation
- Multi-Agent Systems: Create specialized agents that work together
- Web Interface: Build a user-friendly chat interface for your agents
- Web Navigation: Enable your agent to browse websites (Coming soon: Local Models)
Before starting, you'll need:
- Python 3.8 or newer installed on your computer
- Node.js and npm installed (for running tool servers)
- Git for downloading this workshop
- API Keys (most examples use Claude's API):
- Anthropic API Key (Required for all examples)
- Notion Integration Token (For tutorial #3 and beyond)
- Hugging Face API Key (For tutorial #6)
π‘ New to APIs? An API key is like a password that lets your code access services like Claude. You'll need to create accounts with these services to get your keys.
Open your terminal or command prompt and run:
git clone https://github.com/ltejedor/building-ai-agents.git
cd building-ai-agentsCreate a file named .env in the main folder and add your API keys. Example at .env.example
HF_TOKEN=your_hf_token_here
NOTION_API_KEY=""
RIME_API_KEY=""
β οΈ Important: Never share your API keys or commit them to public repositories!
Run this command to install all required Python packages:
pip install -r requirements.txtThis installs:
smolagents: The framework we'll use to build agentsmcp: A protocol for connecting to external tools- Other helpful libraries for our projects
This workshop is designed to be followed in order. Each tutorial builds on skills from previous ones.
For each tutorial:
- Read the explanation
- Run the script
- Try the example and experiment with your own inputs
- Look at the code to understand how it works
Let's begin!
What you'll learn: How to create your first AI agent that can answer questions and write code.
Run it:
python 0_agent.pyTry asking:
- "Write a Python function for calculating Fibonacci numbers"
- "Explain how solar panels work"
- "Create a simple HTML webpage with CSS"
How it works: This script creates a simple agent powered by Claude. It can understand your questions and generate helpful responses, including code.
What you'll learn: How to give your agent special abilities (tools) like creating files.
Run it:
python 1_tools.pyTry asking:
- "Create a file named test.txt with content 'Hello World'"
- "Write a Python script that prints the current date and save it to date.py"
How it works: We add custom tools to our agent using Python functions. The agent can now interact with your computer by creating files when you ask it to.
What you'll learn: How to connect your agent to external AI services like image generators.
Run it:
python 2_mcp.pyTry asking:
- "Generate an image of a sunset over mountains"
- "Create a picture of a futuristic robot in a garden"
How it works: This script connects to an external image generation service (Replicate) using a protocol called MCP. Your agent can now create images based on your descriptions.
What you'll learn: How to connect your agent to multiple services at once.
Run it:
python 3_multimcp.pyTry asking:
- "Create a Notion page about AI history and add an image of a neural network"
- "Make a Notion page with travel tips and include an image of a tropical beach"
How it works: Your agent can now use both Notion (for creating documents) and image generation services together, combining their capabilities to complete more complex tasks.
What you'll learn: How to create a team of specialized AI agents that work together.
Run it:
python 4_multiagent.pyTry asking:
- "Research the history of LLMs and present it conversationally"
- "Explain quantum computing in a friendly way"
How it works: This script creates three agents: a researcher, a conversational presenter, and a manager. The manager coordinates the other agents to complete your task efficiently.
What you'll learn: How to create a user-friendly chat interface for your agents.
Run it:
python 5_ui.pyAfter running this command, open the link (usually http://127.0.0.1:7860) in your web browser to see your agent's chat interface.
How it works: This script uses a library called Gradio to create a web-based chat interface for your multi-agent system, making it easier to interact with your agents.
What you'll learn: How to enable your agent to browse websites and extract information.
Run it:
python 6_web.pyWhat happens: The agent will open a web browser, navigate to a GitHub repository, read its content, and create a tutorial based on what it finds.
How it works: This script uses Selenium (a web automation tool) to give your agent the ability to control a web browser, allowing it to visit websites and interact with web pages.
What you'll learn: How to run your agents using locally hosted language models instead of cloud APIs.
An agent is an AI assistant that uses a large language model (like Claude) combined with tools to solve problems and complete tasks.
Tools are functions that give your agent abilities beyond just generating text. For example, a tool might let your agent create files, generate images, or search the web.
MCP (Machine-Centric Protocol) is a way for your agent to discover and use tools provided by external services. Think of it as a universal adapter that lets your agent connect to different tools.
A multi-agent system uses multiple specialized agents that work together. For example, one agent might research information while another presents it in a friendly way.
Problem: You see "API key not found" or authentication errors Solution:
- Check that your
.envfile has the correct API keys - Make sure the file is in the main folder of the project
- Verify there are no spaces around the equals sign
Problem: "Cannot connect to MCP server" errors Solution:
- Make sure you've completed the setup steps for the MCP servers
- Check that Node.js is installed properly
- Try restarting the terminal and running the script again
Problem: Browser doesn't launch or Selenium errors appear Solution:
- Install the WebDriver Manager:
pip install webdriver-manager - Make sure Chrome is installed on your computer
- Check that your Python environment has all required packages
Problem: The Gradio UI doesn't appear after running 5_ui.py Solution:
- Make sure Gradio is installed:
pip install gradio - Look for the URL in the terminal output and open it manually
- Try a different browser if the interface doesn't load
After completing this workshop, you can:
- Create your own agent projects using what you've learned
- Develop custom tools for specific tasks you need help with
- Connect to other services like Google Calendar or Slack
- Share your agents with others using web interfaces
If you get stuck or have questions:
- Check the troubleshooting section above
- Read the comments in the example scripts
- Open an issue on the GitHub repository
Happy building! π