How Python Dependencies Are Managed in the AI-Agent-Book Repository
The bojieli/ai-agent-book repository manages Python dependencies through a decentralized, chapter-specific structure that isolates documentation build tools from runtime code examples using multiple requirements files alongside modern lock-file tools.
Unlike monolithic Python projects that rely on a single requirements.txt, this repository organizes Python dependencies by functional scope. The approach separates core documentation generators from per-chapter execution environments, allowing contributors to install only the packages necessary for their specific task.
Core Documentation Dependencies
The root-level requirements-docs.txt file declares all packages required to build and render the book itself. According to the repository structure, this file includes tooling such as MkDocs, Pandoc, and Mermaid for documentation generation and diagram rendering.
To install these core build dependencies:
pip install -r requirements-docs.txt
This command installs the exact versions used by the original authors, ensuring that documentation builds remain reproducible across different machines.
Chapter-Specific Runtime Dependencies
Each chapter maintains its own isolated environment through dedicated requirements.txt files located within chapter subdirectories. For example, chapter1/web-search-agent/requirements.txt contains only the libraries needed to run the web search agent examples from that specific chapter.
This granular approach prevents dependency conflicts between chapters that might use incompatible versions of the same library. To set up an environment for a specific chapter:
cd chapter1/web-search-agent
pip install -r requirements.txt
The repository structure indicates that every chapter with executable code follows this pattern, keeping the runtime footprint minimal and targeted.
Lightweight Variants for Rapid Testing
Some chapters provide alternative requirements-lite.txt files for scenarios requiring minimal installations. The file chapter9/gaia-experience/requirements-lite.txt demonstrates this pattern, offering a reduced dependency set optimized for continuous integration pipelines or quick experiments.
Use the lightweight variant when you need faster installation times or want to verify code logic without pulling heavy machine learning frameworks:
cd chapter9/gaia-experience
pip install -r requirements-lite.txt
Lock-File Reproducibility with uv and Poetry
For deterministic environment reconstruction, the repository includes a uv.lock file at the root compatible with the uv package manager. After installing uv (pip install uv), you can recreate the exact dependency tree with a single command:
uv sync
The lock file guarantees that every contributor uses identical package versions, eliminating "works on my machine" issues.
Additionally, the root pyproject.toml file supports Poetry workflows. Contributors preferring Poetry can run:
poetry install
This reads the TOML configuration and installs the same dependencies declared in requirements-docs.txt, allowing flexibility in package management tooling.
Practical Installation Workflows
The following patterns demonstrate the typical workflows for different contribution types:
For documentation editing:
pip install -r requirements-docs.txt
For chapter-specific development:
cd chapter5/coding-agent
pip install -r requirements.txt
For reproducible research environments:
pip install uv
uv sync
Summary
- The repository uses
requirements-docs.txtat the root for documentation build tools like MkDocs and Pandoc. - Each chapter contains its own
requirements.txtto isolate runtime dependencies (e.g.,chapter1/web-search-agent/requirements.txt). - Optional
requirements-lite.txtfiles provide minimal dependency sets for faster testing. - The
uv.lockfile enables deterministic installations via the uv package manager usinguv sync. - The
pyproject.tomlsupports Poetry as an alternative to pip-based workflows.
Frequently Asked Questions
Where are the main Python dependencies defined in the AI-Agent-Book repository?
The main Python dependencies are split between the root-level requirements-docs.txt for documentation tooling and individual requirements.txt files within each chapter directory for runtime code examples. There is no single global requirements file; instead, dependencies are scoped to their specific use case.
How do I install dependencies for a specific chapter?
Navigate to the chapter directory and install its local requirements file. For example, run cd chapter1/web-search-agent && pip install -r requirements.txt to install only the packages needed for Chapter 1's web search agent examples, keeping your environment isolated from other chapters.
What is the difference between requirements.txt and requirements-lite.txt?
The standard requirements.txt contains the full set of libraries needed to run all examples in a chapter, while requirements-lite.txt provides a minimal subset for quick tests or CI environments. For instance, chapter9/gaia-experience/requirements-lite.txt omits heavy dependencies that are not essential for basic validation.
Can I use Poetry or uv instead of pip to manage dependencies?
Yes. The repository supports multiple workflows: use pip install -r for traditional requirements files, uv sync to leverage the uv.lock file for exact reproducibility, or poetry install to read from the root pyproject.toml. All three methods install the same underlying package versions.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →