BookGenerator AI is an open-source multi-agent engine that plans, drafts, edits and packages full-length books (80,000 words by default), then tells you honestly whether each one is ready.
What it can and cannot promise. The engine aims for the craft of commercial publishing, and refuses to call a book ready until it passes measurable and editorial checks. No software can guarantee sales. Readers buy on concept, cover, reviews and marketing too, and final quality still depends on your concept, your chosen model, and the human editing listed in every book's release report.
Standard LLM wrappers fail catastrophically when tasked with long-form writing:
- Context degradation & Token Exhaustion: Context windows overflow around 2,000β4,000 words, causing models to forget previous character developments, plot arcs, and established world constraints.
- Repetitive Tropes ("AI Slop"): Models default to repetitive filler phrases ("a testament to", "tapestry of", "shivers down her spine", "a palpable tension") and forced moralizing summary conclusions.
- Hallucinatory Drift: Without strict state isolation, characters swap voice patterns, break world rules, or solve major plot points prematurely.
BookGeneratorAI implements an enterprise-grade multi-agent architecture featuring:
- Hierarchical State Isolation & Dynamic Knowledge Graph: The drafting agent receives only the current scene micro-beat, active character living state, epistemic rules, active plot loops, and a rolling memory summaryβnever the full 80,000-word history.
- Foreshadowing & Clue Tracking Engine: Tracks planted narrative clues, suspense hooks, and target payoff chapters. Audits chapters so scheduled payoffs are never omitted or prematurely revealed.
- Dynamic Character Relationship Network: Models evolving interpersonal tension, alliances, debts, and affinity scores (-10 to +10) that adapt dynamically as dramatic beats resolve.
- Portable Lorebooks & Character Cards: Import and export standardized Character Cards and World Lorebooks (JSON/Markdown) across books and projects via
CardManager. - Causal Chapter DAG & Surgical Invalidation: Models chapter-to-chapter dependencies to allow surgical regeneration of specific chapters and downstream story branches without corrupting unrelated arcs.
- Scene & Sequel Dramatic Beat Sheets: Chapters are decomposed into 6 micro-beats adhering to Dwight Swain's dramatic patterns (Goal β Conflict β Disaster Reversal β Emotional Reaction β Dilemma β Pivotal Decision) with explicit micro-tension curves (1-10) and internal POV subtext.
- Gary Provost Sentence Cadence & Deep POV Engine: The adversarial critic intercepts repetitive mid-length sentence runs (the 15-word AI drone), enforces staccato (<5 words) and sweeping (>26 words) variety, and purges perceptual filter words ("she noticed that", "he felt that").
- Dual-Format Compilation: Compiles to a 6x9 print interior DOCX with mirrored margins, running heads and a live table of contents, and an EPUB 3 with semantic navigation. Run EPUBCheck and your retailer's previewer before upload.
Standard LLMs default to generic clichΓ©s and preachy summary endings. BookGeneratorAI's AntiSlopEditorAgent actively intercepts and rewrites prose:
- RAW UNCHECKED OLLAMA PROSE:
- "The quiet night was a testament to their unshakeable bond. Shivers ran down Clara's spine as a palpable tension filled the courtyard. Little did they know, their journey had only just begun. In conclusion, they learned that love conquers all."
+ ADVERSARIAL CRITIC REFINED PROSE:
+ "The courtyard fell quiet under the cold starlight. Clara gripped the stone archway, her knuckles pale against the damp granite. Julian didn't step back; he closed the distance between them until his breathing matched her own." βββββββββββββββββββββββββββ
β User Seed Concept β
ββββββββββββββ¬βββββββββββββ
β
ββββββββββββββββββββββ΄βββββββββββββββββββββ
βΌ βΌ
βββββββββββββββββββββββββ βββββββββββββββββββββββββ
β World Builder Agent β β Character Architect β
β (Rules & Bible) β β (Voice Fingerprints) β
βββββββββββββ¬ββββββββββββ βββββββββββββ¬ββββββββββββ
β β
ββββββββββββββββββββββ¬βββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββ
β Master Outliner Agent β
β (Bespoke Book Plan) β
ββββββββββββββ¬βββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Iterative Execution Loop β
β β
β βββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ β
β β Prose Drafter Agent βββββββββββββ>β Adversarial Critic Loop β β
β β (Beat-by-Beat Scene) β β (Continuity & Anti-Slop) β β
β βββββββββββββββββββββββββββ βββββββββββββββ¬ββββββββββββββ β
β β² β β
β β Revision Directive β β
β ββββββββββββββββββββββββββββββββββββββββββ β
β β β
β Approved β β
β βΌ β β
β βββββββββββββββββββββββββββββ β β
β β State Memory Engine β β β
β β (Rolling Memory Update) β β β
β βββββββββββββββββββββββββββββ β β
ββββββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββ
β Commercial Export Bridgeβ
β (DOCX + Validated EPUB3)β
βββββββββββββββββββββββββββ
Reasoning models like DeepSeek-R1 output extensive inner-monologue reasoning blocks (<think>...</think>) before generating response content. LlmClient._clean_llm_output() strips reasoning traces and a leading meta preamble ("Here is the scene:") while leaving real opening lines of prose intact.
All intermediate state (brief, world, cast, outline, scenes as they are written, chapters and editor reports) is persisted to the book's own SQLite file (books/<title>/state.db). Interrupted runs resume at the next unwritten scene.
To prevent infinite revision loops when an LLM struggles with a complex constraint, the revision loop is bounded by --max-revisions. If a chapter still fails, its strongest version is kept and the failure becomes a blocker in the release report.
| Phase | Agent | Output |
|---|---|---|
| 0 | Book Strategist | Target reader, promise, hook, ending, voice guide |
| 1 | World Builder, Character Architect, Master Outliner | Bespoke world, cast and a book-specific chapter and scene plan with setups and payoffs |
| 2 | Prose Drafter | Scene-by-scene prose; the book's first scene competes among several drafts |
| 3 | Developmental Editor + mechanical critics | Rubric scores; only flagged scenes are rewritten, and the best version is kept |
| 3 | Memory Engine | Recaps, threads, character state, relationships, secrets and clue status, read from the full chapter |
| 4 | Book Reviewer | release_report.md: PASS or NOT READY with every blocker |
| 5 | Publishing Kit | Store blurb, keywords, categories, cover brief, launch plan, 6x9 print DOCX, EPUB 3 |
Non-fiction gets no invented cast. Uncertain facts are marked [VERIFY: ...], and every checkable claim is listed in fact_check.md.
Nothing is fabricated: no fake reviews, bestseller labels, prices or credentials. An ISBN, publisher, dedication or bio appears only if you supply it. If a model cannot produce valid output, the run stops instead of inserting stock content, and it resumes where it stopped.
Each book lives in its own folder:
books/<title>/
βββ <title>.docx, <title>.epub
βββ manuscript/chapter_01.md ...
βββ publishing/release_report.md, listing.md, metadata.json, fact_check.md
βββ state.db
git clone https://github.com/apravint/BookGeneratorAI.git
cd BookGeneratorAI
pip install -r requirements.txtThe concept matters more than any setting. Give it something specific and original:
python3 main.py \
--title "The Ledger of the Drowned" \
--concept "A river ferryman finds a waterlogged ledger recording every drowning in his town, including tomorrow's" \
--genre thriller \
--author "Your Name" \
--provider anthropicTry two chapters first to judge quality before paying for a full book:
python3 main.py -t "Sample Run" -c "Your concept" -n 2 --target-words 5000 --provider ollamaSet ANTHROPIC_API_KEY, OPENAI_API_KEY or GEMINI_API_KEY for cloud providers. Local models are free, but small ones will rarely clear the editorial bar. Run the same command again to resume.
To add real endorsements, put permissioned quotes in books/<title>/manuscript/praise.md.
| Flag | Short | Default | Description |
|---|---|---|---|
--title |
-t |
Required | Book title; also identifies the book's folder |
--concept |
-c |
title | Seed concept |
--genre |
-g |
auto |
Genre, detected from the title when auto |
--author |
-a |
Pravin Tamilan |
Author name |
--language |
-l |
english |
english or tamil |
--tamil |
off | Shortcut for --language tamil |
|
--provider |
-p |
auto-detected | ollama, gemini, openai, anthropic, jev |
--model |
-m |
provider default | Model name |
--ollama-url |
http://localhost:11434 |
Ollama endpoint | |
--chapters |
-n |
24 |
Number of chapters |
--scenes-per-chapter |
4 |
Scenes per chapter | |
--target-words |
80000 |
Whole-book word target | |
--max-revisions |
2 |
Revision passes per chapter | |
--opening-candidates |
3 |
Competing drafts of the first scene | |
--output / --epub |
-o |
book folder | Output paths |
--cover |
none | Cover .jpg for the EPUB |
|
--subtitle --isbn --publisher --year --dedication --author-bio |
none | Printed only when supplied | |
--reset |
-r |
off | Restart this book only |
--export-cards / --import-lorebook |
none | Portable character cards and lorebooks |
Run a modern, multi-tab Streamlit dashboard:
pip install -r requirements.txt
streamlit run streamlit_app.pyLaunch at
http://localhost:8501to generate books, monitor the pipeline, and download the DOCX, EPUB and release report.
Run a zero-dependency local REST API web server:
python3 server.pyAccess at
http://localhost:8080. It listens on this computer only, because the API starts paid LLM jobs and has no authentication.
We are actively expanding BookGenerator AI into an enterprise-grade manuscript generation platform:
- Phase 1 (Current Engine): Multi-agent beat-by-beat scene drafting, context isolation, adversarial anti-slop critics, and local Ollama REST integration.
- Phase 2 (Semantic Vector Memory & MCP Server): Local vector memory (ChromaDB / FAISS) and a native Model Context Protocol (MCP) server interface for IDE/agent integration.
- Phase 3 (Enterprise UI & Streaming): Web-based authoring dashboard (Angular) powered by real-time event streaming (Apache Kafka / IBM MQ) for multi-user generation jobs.
- Phase 4 (Enterprise Persistence & Multi-Format Exporters): Oracle DB enterprise state persistence alongside native
.epuband publication-ready.pdfcompilers.
This repository follows modern AI contribution standards.
- Human Contributors: Please review
CONTRIBUTING.mdfor local setup, fast single-chapter test flags, and PR guidelines. - Autonomous AI Agents: Please inspect
AGENTS.mdfor operational boundaries, mandatory verification commands, and safety rules.
Distributed under the MIT License. See LICENSE for details.
Pravin Tamilan
Vice President & Lead AI Systems Architect β Chennai, India
Pravin is a technology leader specializing in agentic AI orchestration, Model Context Protocol (MCP) tool design, distributed microservices, and enterprise Spring Boot & Angular architectures.
- GitHub: @apravint
- Specialization: Enterprise AI Architecture, Multi-Agent Systems, Local Inference Engineering, High-Throughput Stream Processing.