Skip to content

Examples

The examples/ directory contains twelve runnable scripts that build up from a one-line agent to autonomous, self-improving systems. Each file is self-contained and documents its own install and API-key requirements in the docstring at the top.

Running an Example

pip install buddy-ai
export OPENAI_API_KEY=sk-...
python examples/01_basic_agent.py

Some examples need extra dependencies or keys (noted below and in each file) — for instance web search needs tavily-python and a TAVILY_API_KEY.

The Scripts

Fundamentals

# Script What it shows
01 01_basic_agent.py The minimal agent — a model plus a prompt. See Agents.
02 02_agent_with_tools.py Attaching built-in tools (web search + Python execution). See Tools.
03 03_agent_with_memory.py Persistent memory so the agent recalls earlier turns. See Memory.
10 10_custom_tool.py Turning a plain Python function into an agent tool. See Tools.

Models & Output

# Script What it shows
08 08_multi_model_comparison.py Running one prompt across OpenAI, Anthropic, and Google to compare results. See Models.
09 09_streaming_agent.py Real-time token streaming with run(..., stream=True) — ideal for chat UIs.

Knowledge & Reasoning

# Script What it shows
05 05_rag_with_irag.py Retrieval-Augmented Generation with the built-in iRAG engine (no vector DB). See Knowledge.
06 06_planning_agent.py PlanningAgent decomposing a goal into steps, then executing and monitoring them.

Multi-Agent & Deployment

# Script What it shows
04 04_multi_agent_team.py A Team where a coordinator delegates to specialist agents. See Models & Teams.
07 07_fastapi_deployment.py Serving an agent as a FastAPI REST API. See Quick Start.

Autonomous Systems

# Script What it shows
11 11_pulse_employee.py The PULSE virtual employee: KT sessions, meetings, tasks, and status updates. See PULSE.
12 12_competency_engine.py Scoring competency, deficit-driven learning, and runtime routing. See Competency Engine.

Start small

If you're new, run 010203 in order. They introduce the model, tools, and memory concepts that every later example builds on.