Skip to main content

An extension of fabricatio

Project description

fabricatio-novel

MIT Python Versions PyPI Version PyPI Downloads PyPI Downloads Bindings: PyO3 Build Tool: uv + maturin

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.

  1. Draft — Outline text → NovelDraft (title, genre, synopsis, chapter list, character descriptions, language detection)
  2. CharactersNovelDraftCharacterCard[] (one per described character)
  3. ScriptsNovelDraft + CharacterCard[]Script[] (batched; each script is a list of Scene objects with per-scene prompts and global writing guidance)
  4. ChaptersScript[] + CharacterCard[] → raw chapter text (sequential; each chapter receives a rolling ChapterSummary from the previous chapter for narrative continuity)
  5. Assembly — Components assembled into a Novel object; 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 -o "In a world where dreams are currency..."

# Generate with RAG writing style augmentation
fanvl wr -o "In a world where dreams are currency..." -rq "Hemingway terse prose style"

# Generate with mental state tracking (character psychology)
fanvl wm -o "In a world where dreams are currency..."

# Generate with RAG + mental state tracking
fanvl wrm -o "In a world where dreams are currency..." -rq "Hemingway terse prose style"

# Generate with mental state tracking + illustrations
fanvl wmi -o "In a world where dreams are currency..."

# Generate with RAG + mental state tracking + illustrations
fanvl wrmi -o "In a world where dreams are currency..." -rq "Hemingway terse prose style"

# 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 capabilities
  • fabricatio-character — Character generation and card models
  • pydantic — Data validation via models
  • Optional: fabricatio-lancedb — Writing style RAG, fabricatio-actions — workflow support, questionary + typer — CLI

License

MIT — see LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

fabricatio_novel-0.8.0-cp314-cp314-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.14Windows x86-64

fabricatio_novel-0.8.0-cp314-cp314-manylinux_2_34_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

fabricatio_novel-0.8.0-cp314-cp314-manylinux_2_34_aarch64.whl (2.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ ARM64

fabricatio_novel-0.8.0-cp314-cp314-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

fabricatio_novel-0.8.0-cp313-cp313-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.13Windows x86-64

fabricatio_novel-0.8.0-cp313-cp313-manylinux_2_34_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

fabricatio_novel-0.8.0-cp313-cp313-manylinux_2_34_aarch64.whl (2.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ ARM64

fabricatio_novel-0.8.0-cp313-cp313-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

fabricatio_novel-0.8.0-cp312-cp312-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.12Windows x86-64

fabricatio_novel-0.8.0-cp312-cp312-manylinux_2_34_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

fabricatio_novel-0.8.0-cp312-cp312-manylinux_2_34_aarch64.whl (2.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ ARM64

fabricatio_novel-0.8.0-cp312-cp312-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file fabricatio_novel-0.8.0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: fabricatio_novel-0.8.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.24 {"installer":{"name":"uv","version":"0.11.24","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

Hashes for fabricatio_novel-0.8.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 8a643bad66ab2417ca6c578adbcd16f5455f2fc832af6aed93e0d2650d25714d
MD5 92918975869dbdafae3cb5c1c50ddfdc
BLAKE2b-256 98f22cb988a9aa67af0bd8de4e69e40fdca00aa907b4b7cdbe8839c74aff6d83

See more details on using hashes here.

File details

Details for the file fabricatio_novel-0.8.0-cp314-cp314-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: fabricatio_novel-0.8.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.24 {"installer":{"name":"uv","version":"0.11.24","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

Hashes for fabricatio_novel-0.8.0-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 7b7c4e52d95cf2bf67f6cb4cfeb68acd66125c198a91f8a36a3146d5db2131ba
MD5 52c225c514e6820c95e7eec7dfa55115
BLAKE2b-256 afc2abb29fd2f0aaabb9f7e49c55e62227ba2378a3e7165a0580524a47634915

See more details on using hashes here.

File details

Details for the file fabricatio_novel-0.8.0-cp314-cp314-manylinux_2_34_aarch64.whl.

File metadata

  • Download URL: fabricatio_novel-0.8.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.24 {"installer":{"name":"uv","version":"0.11.24","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

Hashes for fabricatio_novel-0.8.0-cp314-cp314-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 818208163833a316c416d9d1becd5c9f3f63e2a4c4f2f78b92a80e45a6fb44ae
MD5 649f3cc203e49ca126d971ed5ef5ecbe
BLAKE2b-256 0206e199d48f38dab3411a535c50ab0b85d95f0081fb5011dd96f9f42647d9ce

See more details on using hashes here.

File details

Details for the file fabricatio_novel-0.8.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

  • Download URL: fabricatio_novel-0.8.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.24 {"installer":{"name":"uv","version":"0.11.24","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

Hashes for fabricatio_novel-0.8.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 58e96ed142e37a49f746911bb404fd507dcbe2e6387a9dbb5e6b5d4cd6053691
MD5 271d224cf285e84a5e1bd44a5e7801e6
BLAKE2b-256 fe0be159112d3771d973beaabff650adf8827a89a842dddf76d90e34bc4cd8ca

See more details on using hashes here.

File details

Details for the file fabricatio_novel-0.8.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: fabricatio_novel-0.8.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.24 {"installer":{"name":"uv","version":"0.11.24","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

Hashes for fabricatio_novel-0.8.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 1a98ad55385ee0c45b259e4c5daf2195abccbc81dea4cb47c4004ff6b9432439
MD5 2e24c6eb3985aaf4e931ce6f82c659ea
BLAKE2b-256 2e7fdc37f27b06286e16ebf5f8d8ad773eaa3233f2d092e4bcb4e5bc3fea7272

See more details on using hashes here.

File details

Details for the file fabricatio_novel-0.8.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: fabricatio_novel-0.8.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.24 {"installer":{"name":"uv","version":"0.11.24","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

Hashes for fabricatio_novel-0.8.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 899bfc1def9ba4c2667f2f3ec642bb24939c781cc63da1917000d9805ffebde9
MD5 11281377754b7fc688b064c061689f7b
BLAKE2b-256 a5364a44509d8e79bd84956f5f2dcd30b1265ef0da9c28f3f762a2f8b4a75427

See more details on using hashes here.

File details

Details for the file fabricatio_novel-0.8.0-cp313-cp313-manylinux_2_34_aarch64.whl.

File metadata

  • Download URL: fabricatio_novel-0.8.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.24 {"installer":{"name":"uv","version":"0.11.24","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

Hashes for fabricatio_novel-0.8.0-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 ffd41781642f190a0a3ba413b322a16b17acf6b2bcc175bff3e237f9f7a3413b
MD5 586575e8cd4b26366c2e3ad9184429e0
BLAKE2b-256 8efe025122c64d5ccfa312bc7dc7a5fc735bbbc8f3179a61bcd1762251ef5e89

See more details on using hashes here.

File details

Details for the file fabricatio_novel-0.8.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

  • Download URL: fabricatio_novel-0.8.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.24 {"installer":{"name":"uv","version":"0.11.24","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

Hashes for fabricatio_novel-0.8.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 03a900b76c5a36b90e1b1331b36ac15098215dccc954c146e9d97f7eda800627
MD5 486afde759871ac6b88364ac2a8efe07
BLAKE2b-256 9300546bdd5e055fa745b60ea5121814623234d3f69c8829b2e6044f8a7fbf88

See more details on using hashes here.

File details

Details for the file fabricatio_novel-0.8.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: fabricatio_novel-0.8.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.24 {"installer":{"name":"uv","version":"0.11.24","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

Hashes for fabricatio_novel-0.8.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0aa7a9e5c1e60627a6d340f5196d34a599c881e90ab9f82ba4c0d6fdfb4b797a
MD5 a99156ada216d429a0f3a19ab74210fd
BLAKE2b-256 01d8ad3bce794f3f15aa096c29d9102d6e09a726fa793cc80ce1f3ae23e6c18d

See more details on using hashes here.

File details

Details for the file fabricatio_novel-0.8.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: fabricatio_novel-0.8.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.24 {"installer":{"name":"uv","version":"0.11.24","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

Hashes for fabricatio_novel-0.8.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c94607d4e3eb021c01065601dd04a5d88953216328ad99cf85aba3d630e184fe
MD5 a4038d4211107d527f70c87819acc4ff
BLAKE2b-256 bbbb5b94a62cb4c92e4a59e888097939728b6c5c8684b4abd7f21ed9abe14480

See more details on using hashes here.

File details

Details for the file fabricatio_novel-0.8.0-cp312-cp312-manylinux_2_34_aarch64.whl.

File metadata

  • Download URL: fabricatio_novel-0.8.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.24 {"installer":{"name":"uv","version":"0.11.24","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

Hashes for fabricatio_novel-0.8.0-cp312-cp312-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 e06f1a6ec31fce31da112a246686509eba56ffef8fb925e4b2e7ecb59fa1477b
MD5 5ff0d8260071bffc32a681c3ee519892
BLAKE2b-256 3edd2752a68b9a307957f884f78c06509b2fe83a636ee02c98bff4d8ff7c5e41

See more details on using hashes here.

File details

Details for the file fabricatio_novel-0.8.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

  • Download URL: fabricatio_novel-0.8.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.24 {"installer":{"name":"uv","version":"0.11.24","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

Hashes for fabricatio_novel-0.8.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 abfff0f4e5c753ee297dbff0b89495174e6b0c10978e798ee1cae72aa714cb03
MD5 2d7527d70255c7cff3673f6bc8cd6cac
BLAKE2b-256 dfc57c4708da6bf60844cfc9f63ca1dc81211f74bd2835dfdf6ac3e970d0bbb8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page