- Time to complete: 15-20 minutes
- What you’ll build: A basic chat agent with RAG and file discovery
- What you’ll learn: Agent architecture, RAG integration, and the tool system
- Platform: Runs locally on AI PCs with Ryzen AI (NPU/iGPU acceleration)
Why Build This Agent?
Privacy-First AI: This agent runs entirely on your AI PC with Ryzen AI. All processing happens locally—document content never leaves your machine.
- Finds relevant documents on your drive
- Indexes them with vector embeddings (NPU-accelerated on Ryzen AI)
- Searches semantically using cosine similarity
- Returns specific information with source citations
- Runs completely locally—no cloud, no data leaving your machine
- Agent reasoning - LLM-based tool selection and orchestration
- RAG (Retrieval-Augmented Generation) - Vector search over document chunks
- File discovery - Automated search across common directories
- File monitoring - Watches folders and re-indexes on changes
- Session persistence - Saves indexed state across restarts
- Local execution - Runs entirely on your AI PC using Ryzen AI NPU/iGPU acceleration
The Architecture (What You’re Building)
Flow:- User query → ChatAgent (orchestrator)
- Agent selects tool → RAGToolsMixin
- RAGToolsMixin calls → RAG SDK
- RAG SDK retrieves chunks from vector index → back to Agent
- Agent synthesizes answer → User receives response
Quick Start (5 Minutes)
Get a working agent running to understand the basic flow.1
Set up your project
Choose your installation path:
- PyPI (Recommended)
- Developer (Editable Install)
Create a new project folder and install from PyPI:
This is the recommended path for most users. You’ll create your agent scripts in this folder. The
agent-chat extra pulls in the standalone gaia-agent-chat wheel that provides ChatAgent; rag adds the document-processing dependencies (faiss, PyMuPDF).2
Start Lemonade Server
Lemonade Server provides AMD-optimized inference for AI PCs with Ryzen AI. Models run on your NPU or iGPU for fast, private processing.
3
Create your first agent
Create
my_chat_agent.py in your project folder:my_chat_agent.py
4
Run it
- PDF text extraction (PyMuPDF)
- Chunking into 500-token segments
- Embedding generation (EmbeddingGemma 300M running on NPU/iGPU)
- FAISS index creation
- Query processing via vector search
- LLM generates answer using retrieved chunks (Ryzen AI acceleration)
If you don’t have a PDF, the agent operates in general conversation mode using the LLM’s training data.
no_documents.py
Understanding the Components
Before we build step-by-step, let’s understand what each piece does under the hood.1. The Agent Base Class
- Code
- Purpose
process_query():
Trade-off: You delegate control flow to the LLM. This is flexible but less deterministic than traditional programming.
2. The Tool Decorator
- Code
- What It Does
- How LLM Sees It
3. RAG SDK (Document Retrieval)
- Import
- Configuration
- Usage
- LLMs have context window limits (e.g., 4096 tokens)
- Smaller chunks enable more precise semantic matching
- Overlap preserves context at chunk boundaries and reduces information loss
AMD Hardware Acceleration: Embedding generation runs on the Ryzen AI NPU/iGPU, enabling fast document indexing with minimal CPU usage on AI PCs.
4. Tool Mixins
Mixins are classes that provide reusable tool sets via Python multiple inheritance.
- Usage
- Available Mixins
- Benefits
Building It: The Step-by-Step Journey
Now let’s build this agent incrementally, understanding each piece as we go.Step 1: The Simplest Possible Agent
Start with a minimal agent implementation to understand the core structure.- Implementation
- Run
- What You Have
step1_basic.py
Under the Hood: Execution Flow
Under the Hood: Execution Flow
Initialization:Query processing:Limitations:
- No tools = no ability to execute actions
- Cannot access external data sources
- Relies solely on LLM training data
Step 2: Add RAG (Document Understanding)
Add RAG capability to enable document search and retrieval.- Implementation
- Usage
- Output Example
step2_with_rag.py
Under the Hood: Indexing and Retrieval
Under the Hood: Indexing and Retrieval
Indexing phase (Query phase (Key benefit: Grounding LLM responses in actual document text reduces hallucination for domain-specific content.
__init__):On AI PCs with Ryzen AI, the embedding model runs on the NPU for efficient processing.
process_query):What you have: Document retrieval via vector search. The agent can answer questions using your specific documents rather than general knowledge.
Step 3: Add Smart File Discovery
Add file discovery to avoid hardcoding document paths.Under the Hood: Smart Discovery Pattern
Under the Hood: Smart Discovery Pattern
Example query: “Find the oil manual and tell me about safety”LLM orchestration (automatic):Implementation note: You define Python functions. The LLM decides when to call them based on tool schemas and user intent.
What you have: File discovery without hardcoded paths. The agent can locate, index, and query documents based on pattern matching.
Next Steps
You’ve built a functional document Q&A agent with RAG and file discovery! Continue with Part 2 to add more capabilities:Part 2: Advanced Features & Customization
Add tool mixins, file monitoring, session persistence, and learn how to customize your agent for specific use cases.