An extension of fabricatio
Project description
fabricatio-novel
AI-powered novel generation — outline to publication-ready EPUB.
Installation
pip install fabricatio[novel]
# or
uv pip install fabricatio[novel]
For the CLI tool:
pip install fabricatio-novel[cli]
Pipeline
Novel generation runs as a five-stage sequential pipeline driven by Handlebars templates.
- Draft — Outline text →
NovelDraft(title, genre, synopsis, chapter list, character descriptions, language detection) - Characters —
NovelDraft→CharacterCard[](one per described character) - Scripts —
NovelDraft+CharacterCard[]→Script[](batched; each script is a list ofSceneobjects with per-scene prompts and global writing guidance) - Chapters —
Script[]+CharacterCard[]→ raw chapter text (sequential; each chapter receives a rollingChapterSummaryfrom the previous chapter for narrative continuity) - Assembly — Components assembled into a
Novelobject;NovelBuilder(Rust/PyO3) produces the EPUB
An optional RAG variant (NovelComposeRAG) queries LanceDB for WritingStyleDocument entries and injects them into script-level global_prompt and scene-level prompt fields before chapter generation.
Key Classes
Models
| Class | Description |
|---|---|
NovelDraft |
High-level novel plan: title, genre, synopsis, character descriptions, ordered ChapterDraft list, expected word count |
ChapterDraft |
Per-chapter outline with title, detailed synopsis, and weight (for word-count allocation) |
Script |
Sequence of Scene objects with a global_prompt for chapter-level writing guidance |
Scene |
Basic narrative unit: narrative description, tone/style prompt, tags, weight |
ChapterSummary |
Structured summary of a generated chapter — key events, character states, emotional arc, unresolved threads |
ChapterPlan |
Bundles a ChapterDraft, its Script, and computed word count per chapter |
Chapter |
Final chapter with XHTML content, zero-based index, and word count |
Novel |
Collection of Chapter objects with aggregate word count and compliance ratio |
WritingStyleDocument |
LanceDB-backed document for storing and retrieving writing style references |
NovelConfig |
Frozen dataclass specifying built-in template names for all pipeline stages |
Capabilities (Mixins)
| Class | Description |
|---|---|
NovelCompose |
Full pipeline: create_draft, create_characters, create_scripts, create_chapters, summarize_chapter, assemble_novel, compose_novel |
NovelComposeRAG |
Extends NovelCompose — fetches writing style docs from LanceDB and injects them into script/scene prompts before chapter generation |
Actions (fabricatio-actions)
| Class | Description |
|---|---|
GenerateNovelDraft |
Generate a NovelDraft from an outline |
GenerateCharactersFromDraft |
Generate CharacterCard list from a draft |
GenerateScriptsFromDraftsAndCharacters |
Generate Script list from draft + characters |
GenerateChaptersFromScripts |
Generate chapter text sequentially from scripts + characters |
AssembleNovelFromComponents |
Build final Novel from draft, plans, and chapter contents |
ValidateNovel |
Validate chapter count, word count, and compliance ratio |
GenerateNovel |
Run the full pipeline in one action |
DumpNovel |
Serialize a Novel to disk as EPUB via NovelBuilder |
Workflows (fabricatio-actions)
| Workflow | Description |
|---|---|
WriteNovelWorkflow |
One-step outline → EPUB |
DebugNovelWorkflow |
Step-by-step: draft → characters → scripts → chapters → validation → assembly → dump |
GenerateOnlyCharactersWorkflow |
Draft → characters only, for iterating on character design |
RewriteChaptersOnlyWorkflow |
Reuse existing scripts + characters to regenerate chapter prose |
ValidatedNovelWorkflow |
Full pipeline with quality gates (min chapters, word count, compliance ratio) |
RegenerateWithNewCharactersWorkflow |
A/B test character impact by re-running with fresh character generation |
DumpOnlyWorkflow |
Export a pre-built Novel object to EPUB |
Rust / PyO3
| Symbol | Description |
|---|---|
NovelBuilder |
Builder for EPUB 3.0 novels: set title/description/authors, add chapters (auto-XHTML), cover images, fonts, CSS, inline TOC, export to file |
text_to_xhtml_paragraphs |
Convert plain text with newline-separated paragraphs to <p>-wrapped XHTML |
Usage
CLI
# Generate a novel from an outline
fanvl w "In a world where dreams are currency..."
# Generate with RAG writing style augmentation
fanvl wr "In a world where dreams are currency..."
# Store reference texts as writing style documents in LanceDB
fanvl store-refs ./corpus/*.txt
Programmatic
from fabricatio_novel.workflows.novel import DebugNovelWorkflow
from fabricatio_core import Event
event = Event.instantiate("write")
event.payload["novel_outline"] = "In a world where dreams are currency..."
role = Role.with_bio(name="writer").subscribe(event, DebugNovelWorkflow).dispatch()
EPUB Builder (Rust)
from fabricatio_novel.rust import NovelBuilder, text_to_xhtml_paragraphs
xhtml = text_to_xhtml_paragraphs(raw_chapter_text)
builder = (
NovelBuilder()
.new_novel()
.set_title("My Novel")
.add_author("Author Name")
.add_chapter("Chapter 1", xhtml)
.add_inline_toc()
)
builder.export("output.epub")
Dependencies
fabricatio-core— Core interfaces, template management, LLM capabilitiesfabricatio-character— Character generation and card modelspydantic— Data validation via models- Optional:
fabricatio-lancedb— Writing style RAG,fabricatio-actions— workflow support,questionary+typer— CLI
License
MIT — see LICENSE
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fabricatio_novel-0.6.0-cp314-cp314-win_amd64.whl.
File metadata
- Download URL: fabricatio_novel-0.6.0-cp314-cp314-win_amd64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.14, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4852dd1ea92c7310f2c91a2370abad6e3321906647f1d2e502b9d41b619ade72
|
|
| MD5 |
d67d279bd90a4485aa6b277b01b276ff
|
|
| BLAKE2b-256 |
ba9352f857fdcc897b92db5ff424cf351a9e4232857eabc86a74d973323feadb
|
File details
Details for the file fabricatio_novel-0.6.0-cp314-cp314-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: fabricatio_novel-0.6.0-cp314-cp314-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.14, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8cd064e589580a992cc532d1f916f512aef2eca4e3f46cd23be7dbadeac4360
|
|
| MD5 |
a7558d962516ade6c366251e62102888
|
|
| BLAKE2b-256 |
1265102a09a94e7d5181cb9966836a88e0a2a354a04bbc2df5f5a811c88e6772
|
File details
Details for the file fabricatio_novel-0.6.0-cp314-cp314-manylinux_2_34_aarch64.whl.
File metadata
- Download URL: fabricatio_novel-0.6.0-cp314-cp314-manylinux_2_34_aarch64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.14, manylinux: glibc 2.34+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec9aa5ec20cddef2e90e1cac2ac5f8fe465b56c059d6d28f99eb1e221f22211a
|
|
| MD5 |
0d9d50e4908abbed35a581a6380380d5
|
|
| BLAKE2b-256 |
e4ecb1b843fb72d1c7db04431e580a37ee64f7b08f0bfff14b9c9daea2630219
|
File details
Details for the file fabricatio_novel-0.6.0-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: fabricatio_novel-0.6.0-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e272e0e257f086b5885a31dc15b8c86be96731556d6075d8cf6fd449dc2943b
|
|
| MD5 |
23f5da7ec2957f2492eedff50ca767bc
|
|
| BLAKE2b-256 |
e604448b0f3076a5677521d4ec7d75e39b9a3c105e576274c36e5202fa529988
|
File details
Details for the file fabricatio_novel-0.6.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: fabricatio_novel-0.6.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aae462e9a21f2cba30ef88aa4ffb4af6813ebc549f24651cf792bac0a77c3ae6
|
|
| MD5 |
39363eeebd0916689762e8ee9ad45afb
|
|
| BLAKE2b-256 |
18ac384681d303a0734fa01ddd4b0771cfc58db9707c0fcf953727ea54d3e90f
|
File details
Details for the file fabricatio_novel-0.6.0-cp313-cp313-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: fabricatio_novel-0.6.0-cp313-cp313-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.13, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75aa417f037d365d478e43f403ecaeac7fa6bab5c9c48ee0e40ce8c670a43f7d
|
|
| MD5 |
e94e9631b69cd8701657e003ed00ae78
|
|
| BLAKE2b-256 |
de2daf562dc50549d7f399039440fd1bfe1081c82f21bb4d9a8f0cfb714c1078
|
File details
Details for the file fabricatio_novel-0.6.0-cp313-cp313-manylinux_2_34_aarch64.whl.
File metadata
- Download URL: fabricatio_novel-0.6.0-cp313-cp313-manylinux_2_34_aarch64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.13, manylinux: glibc 2.34+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4668c36800b26965a81b5e8deed943311f9c9c9b9a40c770d9e5ac397fac8b4c
|
|
| MD5 |
d3ad743b6963cd897ecbb58a4230278c
|
|
| BLAKE2b-256 |
117049a6bed36decb39c7c3515bc6b8c637733f4e0d550de38d6c82d80a2ae03
|
File details
Details for the file fabricatio_novel-0.6.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: fabricatio_novel-0.6.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b9e7b916e28dd993f5de96b49505097f3e9b3b7bb8ce6064aca2592a942131b
|
|
| MD5 |
dcfdab0fb2a7173549b6c41c5710c380
|
|
| BLAKE2b-256 |
0e170ea2b4fe4b194c641efe768c8dce5876b8cba2928365d2208c6044e09c99
|
File details
Details for the file fabricatio_novel-0.6.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: fabricatio_novel-0.6.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea06ebe674becef604c86860734fd2b98fd32fb953ba65f6c8eb8914d5545b56
|
|
| MD5 |
4651a31cfe2c9678ad57dd969250f5e7
|
|
| BLAKE2b-256 |
75d9957db72f18399bf16e40df7096575ce7e0273affd1b2afadedc453c91858
|
File details
Details for the file fabricatio_novel-0.6.0-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: fabricatio_novel-0.6.0-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78d047d9b294b795efb649ae657346c617c17b2c51fdb90d6461cff6a3ea6cd0
|
|
| MD5 |
b4c9915fcf5dea18721dd45a988077cd
|
|
| BLAKE2b-256 |
d30d8f41b8a827531cab57ece9478e580ae9a49bcd58b2d60c2a5153d9edab55
|
File details
Details for the file fabricatio_novel-0.6.0-cp312-cp312-manylinux_2_34_aarch64.whl.
File metadata
- Download URL: fabricatio_novel-0.6.0-cp312-cp312-manylinux_2_34_aarch64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.12, manylinux: glibc 2.34+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1d6bfbc92af46c06f82abe8796c4d6981db127fa3247a9b72a3a585780f4029
|
|
| MD5 |
81a194476722f6c8b3fefaf04a4d5ee1
|
|
| BLAKE2b-256 |
83e01843b7146e4af87960f971521c4b3a9f5396b912148a61e59f80d1e97f8a
|
File details
Details for the file fabricatio_novel-0.6.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: fabricatio_novel-0.6.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f746d8701c6a187a9dc36805a370b318d5c28d301d3e06747e9bac243cf0b606
|
|
| MD5 |
6fa86f8c86c7b9a1328782a82a8b8e43
|
|
| BLAKE2b-256 |
5e42ac68bf130642f23ff988ce262e265eb7b39175f2e0cc72ad91496cd6b7b2
|