Skip to content

Latest commit

Β 

History

History
108 lines (83 loc) Β· 3.92 KB

File metadata and controls

108 lines (83 loc) Β· 3.92 KB

Python License Steps Beginner

πŸ€– Agent Builder

Build an AI Agent from Scratch Β· 6-Step Progressive Tutorial

No frameworks. No magic. Just you, Python, and an LLM API.

πŸ“– δΈ­ζ–‡η‰ˆ README


What Is This?

A hands-on tutorial that guides you through building a working AI agent β€” step by step, concept by concept. Each step is a standalone Python script that introduces exactly one new idea.

The Four Building Blocks

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  🧠 Brain (LLM API)   β”‚  ← Call the model
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  πŸ”§ Hands (Tools)     β”‚  ← Function Calling
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  πŸ’Ύ Memory (Context)  β”‚  ← Messages list
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  πŸ”„ Engine (ReAct)    β”‚  ← Think β†’ Act β†’ Observe
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Roadmap

# File What You Learn New Concept
1 step01_hello_llm.py Call the LLM API system/user/assistant roles
2 step02_tool_system.py Function Calling Tool definitions, two-call pattern
3 step03_memory.py Conversation memory Messages list, token budget
4 step04_react_loop.py ReAct loop Think β†’ Act β†’ Observe cycle
5 step05_full_agent.py Complete agent All components + interactive CLI
6 step06_plugin_system.py Plugin system + HTTP Hot-loading plugins, REST APIs

Quick Start

# 1. Install dependencies
pip install -r requirements.txt

# 2. Set your API key (DeepSeek recommended β€” cheap, fast)
export OPENAI_API_KEY="sk-your-key"
export OPENAI_BASE_URL="https://api.deepseek.com/v1"

# 3. Run step by step
python step01_hello_llm.py
python step02_tool_system.py
python step03_memory.py
python step04_react_loop.py
python step05_full_agent.py
python step06_plugin_system.py

πŸ’‘ Stuck? β†’ TROUBLESHOOTING.md

API Providers

This tutorial uses the OpenAI-compatible interface. Any provider that supports chat/completions and Function Calling works:

Provider Model Base URL
OpenAI gpt-4o-mini (default)
DeepSeek deepseek-chat https://api.deepseek.com/v1
Qwen qwen-turbo (Alibaba Cloud)
GLM glm-4-flash (Zhipu AI)
Ollama (local) llama3 http://localhost:11434/v1

What's Next?

After mastering the basics, level up with:

πŸš€ Agent Builder Pro β€” Shell executor, streaming output, RAG knowledge base, multi-agent collaboration, persistent memory, and Web UI.

Project Structure

agent-builder/
β”œβ”€β”€ step01_hello_llm.py        ← Call the LLM
β”œβ”€β”€ step02_tool_system.py      ← Function Calling
β”œβ”€β”€ step03_memory.py           ← Memory management
β”œβ”€β”€ step04_react_loop.py       ← ReAct loop
β”œβ”€β”€ step05_full_agent.py       ← Complete agent
β”œβ”€β”€ step06_plugin_system.py    ← Plugin system
β”œβ”€β”€ tools/                     ← Built-in tools
β”œβ”€β”€ plugins/                   ← Drop plugins here
β”œβ”€β”€ exercises/                 ← Practice exercises
β”œβ”€β”€ outputs/                   ← Example outputs
β”œβ”€β”€ CHEATSHEET.md              ← Quick reference
β”œβ”€β”€ ARCHITECTURE.md            ← Deep dive
└── TROUBLESHOOTING.md         ← Error fixes

License

MIT Β© 2026