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