A sophisticated multi-agent AI system for automated book generation using AutoGen v2.0
Transform ideas into complete books using a sophisticated multi-agent AI system. Generate 25-chapter books with consistent narrative, character development, and world-building through collaborative AI agents.
- π Complete Book Generation - Automated 1-100+ chapter books
- π€ 7 Specialized AI Agents - Story planning, writing, editing, and quality control
- π§ Advanced Memory System - Maintains continuity and context across chapters
- π§ Flexible LLM Support - Local servers (LM Studio, Ollama) or cloud APIs (OpenAI, Claude)
- π Performance Monitoring - Real-time metrics and resource optimization
- β Production Grade - Comprehensive testing, error handling, and logging
This system provides the technical foundation for a commercial AI book generation platform:
- Market Potential: $590K+ ARR based on content creation market demand
- Target Markets: Authors, publishers, content marketers, educators
- Scalable Architecture: Ready for web interface and user management
- Enterprise Features: Performance monitoring, resource management, quality control
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Story Planner β β Outline Creator β β World Builder β
β ββββββ ββββββ β
β High-level Arc β β Chapter Details β β Setting & Lore β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Memory Keeper β β Writer β β Editor β
β ββββββ ββββββ β
β Continuity & β β Content β β Quality & β
β Context β β Generation β β Refinement β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
- Python 3.9+
- 1GB+ available RAM
- Local LLM server (LM Studio, Ollama) OR OpenAI API key
# Clone the repository
git clone https://github.com/connorodea/ai-book-writer.git
cd ai-book-writer
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt# Start your local LLM server (e.g., LM Studio on port 1234)
# Then run:
python main_v2.py# Set your OpenAI API key
export OPENAI_API_KEY="your-api-key-here"
export USE_OPENAI="true"
# Generate book
python main_v2.pyfrom config_v2 import get_local_config
from main_v2 import main
# Custom local LLM
config = get_local_config(port=8080, model_name="llama-3.1-70b")
# Then run main() with custom configbook_output/
βββ outline.txt # Complete 25-chapter outline
βββ chapter_01.txt # Chapter 1: The Beginning
βββ chapter_02.txt # Chapter 2: Rising Action
βββ ... # Chapters 3-24
βββ chapter_25.txt # Chapter 25: Resolution
- Length: 5,000+ words per chapter (125,000+ word books)
- Consistency: Character development tracking across chapters
- Continuity: World-building and plot coherence
- Professional Quality: Automated editing and validation
Run the comprehensive test suite:
python test_book_generator.pyTest Coverage:
- β Configuration system (3 tests)
- β Agent creation and management (5 tests)
- β Outline generation (4 tests)
- β Book generation (6 tests)
- β Integration testing (2 tests)
Current Status: 20/20 tests passing π
- Memory: 1GB+ available RAM
- CPU: Multi-core recommended for faster generation
- Storage: 100MB+ for generated content
- Network: For cloud LLM APIs (if not using local)
# Run demo with performance monitoring
python demo.py
# Check system resources
from performance_monitor import ResourceOptimizer
ResourceOptimizer.check_system_resources()# LLM Backend Selection
USE_OPENAI=false # Use local LLM (default)
USE_OPENAI=true # Use OpenAI API
# OpenAI Configuration (if using OpenAI)
OPENAI_API_KEY=your-key
# Logging Level
LOG_LEVEL=INFO # DEBUG, INFO, WARNING, ERRORfrom config_v2 import get_config
from autogen_core.models import ModelInfo, ModelFamily
# Custom model configuration
config = get_config(
api_key="your-key",
base_url="http://localhost:8080/v1",
model_name="custom-model"
)Main orchestrator for book generation.
book_gen = BookGenerator(agents, config, outline)
await book_gen.generate_book_async(outline)Creates detailed chapter outlines.
outline_gen = OutlineGenerator(agents, config)
outline = await outline_gen.generate_outline_async(prompt, 25)Manages the 7 specialized AI agents.
agents_manager = BookAgents(config, outline)
agents = agents_manager.create_agents(prompt, chapter_count)from config_v2 import get_local_config, get_openai_config
# Local LLM
config = get_local_config(port=1234, model_name="llama-3.1-8b")
# OpenAI
config = get_openai_config("api-key", "gpt-4")Ready to build a commercial book generation platform? This system provides the foundation:
- Web Frontend: React/Next.js dashboard
- REST API: FastAPI wrapper around the core system
- User Management: Authentication and accounts
- Database: PostgreSQL for user data and books
- Payment Integration: Stripe for subscriptions
- Queue System: Redis/Celery for background processing
- File Storage: AWS S3 for generated content
- Analytics: User behavior and generation metrics
- Multi-tenant: Organization and team support
- Template System: Genre-specific book templates
- API Access: Developer API for integrations
- White-label: Custom branding for enterprises
- Starter Plan: $29/month (2 books, basic features)
- Professional: $99/month (10 books, advanced features)
- Enterprise: $299/month (unlimited, custom features)
Import Errors
# Ensure virtual environment is activated
source venv/bin/activate
pip install -r requirements.txtMemory Issues
# Check available resources
from performance_monitor import ResourceOptimizer
ResourceOptimizer.check_system_resources()Local LLM Connection
# Verify your local LLM server is running
curl http://localhost:1234/v1/modelsGeneration Failures
- Check logs in
logs/directory - Verify LLM server is accessible
- Ensure sufficient system resources
from performance_monitor import performance_monitor
performance_monitor.start_monitoring()
# ... generate content ...
performance_monitor.stop_monitoring()
# Get metrics
metrics = performance_monitor.get_metrics_summary()from logging_config import setup_logging
# Configure logging
logger = setup_logging(
log_level="INFO",
log_file="custom.log",
enable_console=True
)- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
python test_book_generator.py) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with AutoGen v2.0 framework
- Inspired by collaborative AI agent systems
- Designed for commercial book generation platforms
- π Issues: GitHub Issues
- π§ Contact: [Your Email]
- π Documentation: See STATUS_REPORT.md for detailed technical information
β Star this repository if you find it useful!
Ready to generate your first AI book? Run python main_v2.py and watch the magic happen! β¨