This repository contains Jupyter notebooks that demonstrate OpenAI’s conversation flow, tool calling capabilities, and the creation of simple AI agents using the OpenAI Agents SDK. These notebooks were created to accompany the CTO Insights talk presented by Jason Allen, hosted by NextPath and AzTia
Install UV for Python package management:
# On macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# On Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
You'll need an OpenAI API key to run these notebooks. Get one from OpenAI's platform.
-
Clone the repository:
git clone <repository-url> cd ai_agents_explained
-
Install dependencies:
uv sync
-
Create a
.env
file: Create a.env
file in the root directory with your OpenAI API key:OPENAI_API_KEY=sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Replace
sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
with your actual OpenAI API key.
Open the notebooks directly in VSCode or Cursor. The IDE will automatically detect the Python environment managed by UV.
- Open VSCode or Cursor
- Open the project folder
- Click on any
.ipynb
file to open it - Select the Python interpreter from
.venv/bin/python
when prompted - Run the notebook cells directly in the IDE
Demonstrates basic conversation flow with OpenAI's API, showing:
- Single API calls
- How to maintain conversation history
- Memory limitations without context
Shows OpenAI's tool calling (function calling) capabilities:
- Defining function schemas
- Making API calls with tools
- Handling function execution and responses
Interactive chat interface using Gradio that demonstrates:
- Real-time tool calling in a chat UI
- Weather function integration
- Conversation management
Demonstrates single agents and agent chaining patterns:
- Creating and running simple agents
- Chaining multiple agents together
- Agent workflow orchestration
- Using OpenAI traces for monitoring
Shows agent routing and handoff patterns:
- Creating specialized agents (billing, tech support, default)
- Implementing a triage agent for routing
- Agent handoff workflows
- Support ticket routing example
Compares hosted tools vs function tools for agents:
- Custom weather function implementation
- Using hosted web search tools
- OpenAI platform trace monitoring
- Tool integration patterns
Advanced multi-agent research system demonstrating:
- Complex agent orchestration
- Web search planning and execution
- Research report generation
- Email automation with SendGrid integration
- Multi-step workflow coordination
- Open any notebook in Jupyter
- Run all cells in order
- For the Gradio demo, click the generated link to open the chat interface
- Try asking weather-related questions to see tool calling in action
- "What's the weather like in Tampa?"
- "How's the weather in New York and Los Angeles?"
- "Tell me about the weather in Chicago"
- "What should I wear in Seattle today?"
openai
- OpenAI Python SDKpython-dotenv
- Environment variable managementgradio
- Web UI framework for demosipykernel
- Jupyter notebook supportsendgrid
- Email delivery service for agent automation
All dependencies are managed through pyproject.toml
and installed via uv sync
.
The repository includes:
- Custom agent tools (
agent_tools.py
) - Visual diagrams for agent patterns (chaining and routing)
- OpenAI platform trace integration for workflow monitoring
- Examples of both simple and complex agent architectures