Dependencies Required to Run the AI Agent Book Code: Complete Setup Guide
The AI Agent Book repository requires chapter-specific dependencies, with each of the 10 chapters containing its own requirements.txt file, plus optional top-level dependencies for building the documentation site.
The bojieli/ai-agent-book repository is organized as a collection of 10 chapters, each containing self-contained experiment projects targeting different AI agent domains. Understanding the dependencies required to run the AI agent book code is essential because the repository uses a modular architecture rather than a single monolithic dependency tree.
Dependency Architecture Overview
The repository organizes dependencies into three distinct groups to keep environments lightweight and modular. This design allows you to run specific experiments without installing unnecessary packages from unrelated chapters.
Core Site-Building Tools
These dependencies are only needed if you want to generate the online reading site using MkDocs. According to the source code in [requirements-docs.txt](https://github.com/bojieli/ai-agent-book/blob/main/requirements-docs.txt), the documentation build requires:
- mkdocs-material[imaging] >= 9.5, < 10
- mkdocs-git-revision-date-localized-plugin >= 1.2, < 2
These packages handle Markdown rendering, theme assets, and Git revision date localization for the documentation site.
Common Runtime Libraries
Many coding-agent examples and generic helper scripts share a common base of LLM API clients and utility libraries. The [chapter5/coding-agent/requirements.txt](https://github.com/bojieli/ai-agent-book/blob/main/chapter5/coding-agent/requirements.txt) file serves as the primary reference for these shared dependencies:
- openai >= 1.0.0
- anthropic >= 0.40.0
- python-dotenv >= 1.0.0
- requests >= 2.31.0
- beautifulsoup4 >= 4.12.0
- html2text >= 2020.1.16
- PyPDF2 >= 3.0.0
These packages enable LLM API interactions, environment variable management, and PDF/HTML processing capabilities used across multiple experiments.
Chapter-Specific Stacks
Each chapter may depend on specialized frameworks for model training, reinforcement learning, computer vision, audio processing, or robotics. These are isolated to their respective directories to prevent dependency conflicts:
- Chapter 7 (AdaptThink): Located in
chapter7/AdaptThink-original/requirements.txt, typically includestorch,transformers, andeinopsfor RL experiments. - Chapter 6 (Model Benchmark): Found in
chapter6/model-benchmark/requirements.txt, contains evaluation and benchmarking libraries. - Chapter 9 (Controllable TTS): Located in
chapter9/controllable-tts/requirements.txt, includes audio processing and text-to-speech dependencies.
Installing Documentation Dependencies
To build the MkDocs-based documentation site locally, install the top-level documentation requirements and serve the site:
pip install -r requirements-docs.txt
mkdocs serve
Alternatively, use mkdocs build to generate a static site for offline reading.
Installing Chapter-Specific Dependencies
Since each chapter is deliberately isolated, navigate to the specific experiment directory before installing dependencies. This approach keeps your Python environment lightweight while providing all necessary libraries for the specific AI agent experiment.
Example: Coding Agent (Chapter 5)
The coding-agent demo requires the common runtime libraries specified in chapter5/coding-agent/requirements.txt:
cd chapter5/coding-agent
pip install -r requirements.txt
python demo.py --model openai:gpt-4o-mini --task "Summarize the PDF at ./sample.pdf"
Example: Multivariate RL Experiment (Chapter 7)
For reinforcement learning experiments in the AdaptThink project, install the chapter-specific stack:
cd chapter7/AdaptThink-original
pip install -r requirements.txt
python train.py --config configs/rl.yaml
Both examples assume you have activated a virtual environment before running pip install.
Key Dependency Files
Understanding the repository structure helps locate the correct dependency files:
requirements-docs.txt(repository root): Packages for building the MkDocs-based documentation site, including the Material theme and Git revision plugins.chapter5/coding-agent/requirements.txt: Core libraries used by many examples, including LLM API clients (openai,anthropic) and document processing utilities (PyPDF2,beautifulsoup4).chapter*/requirements.txt(various subdirectories): Chapter-specific stacks that enable training, evaluation, or multimodal interaction. Notable examples includechapter7/AdaptThink-original/requirements.txtfor RL experiments andchapter9/controllable-tts/requirements.txtfor audio agents.scripts/: Helper scripts such asbuild_site.shrely on the top-level documentation dependencies.
Summary
- The AI Agent Book uses a modular dependency structure with isolated
requirements.txtfiles per chapter rather than a single repository-wide dependency list. - Install
requirements-docs.txtonly if you need to build the documentation site using MkDocs. - The
chapter5/coding-agent/requirements.txtfile contains common runtime libraries used by many coding-agent examples, including LLM API clients and PDF processing tools. - Chapter-specific stacks in directories like
chapter7/AdaptThink-original/andchapter9/controllable-tts/contain specialized frameworks such as PyTorch, Transformers, and audio processing libraries. - Always navigate to the specific chapter directory and install its
requirements.txtbefore running experiments to ensure you have the correct dependency versions.
Frequently Asked Questions
Do I need to install all dependencies to run a single chapter?
No. The repository is designed so you only install the dependencies for the specific chapter you want to run. Each chapter is self-contained with its own requirements.txt file, allowing you to maintain lightweight environments without pulling in unrelated packages from other experiments.
Can I run the code examples without building the documentation site?
Yes. The runtime dependencies for the AI agent experiments are completely separate from the documentation build tools. You only need to install requirements-docs.txt if you want to generate the MkDocs site locally using mkdocs serve or mkdocs build.
Where are the dependencies for multimodal and audio agents located?
Multimodal and audio-specific dependencies are located in their respective chapter directories. For example, controllable text-to-speech experiments in Chapter 9 use dependencies specified in chapter9/controllable-tts/requirements.txt, while computer vision and robotics experiments in other chapters maintain their own isolated requirement files.
What is the purpose of the chapter5/coding-agent requirements file?
The chapter5/coding-agent/requirements.txt file serves as a common base for many coding-agent examples throughout the repository. It contains essential packages like openai>=1.0.0, anthropic>=0.40.0, and PyPDF2>=3.0.0 that handle LLM API interactions and document processing, which are frequently reused across different agent implementations.
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 →