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.10.2-cp314-cp314-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.14Windows x86-64

fabricatio_novel-0.10.2-cp314-cp314-manylinux_2_34_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.14manylinux: glibc 2.34+ ARM64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

fabricatio_novel-0.10.2-cp313-cp313-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.13Windows x86-64

fabricatio_novel-0.10.2-cp313-cp313-manylinux_2_34_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.34+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

fabricatio_novel-0.10.2-cp312-cp312-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.12Windows x86-64

fabricatio_novel-0.10.2-cp312-cp312-manylinux_2_34_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.34+ ARM64

fabricatio_novel-0.10.2-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.10.2-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: fabricatio_novel-0.10.2-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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.10.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 66f7e55b78dde1cddb7182760af07476ff5acc0a69a7312668ffa0d2093e08ca
MD5 e8b145d05446db50ea483d6c3b0f65dd
BLAKE2b-256 54798e8adfffa740c46d2dc92649f719507185dbc766fd4a6686c895dc6c9504

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_novel-0.10.2-cp314-cp314-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.14, manylinux: glibc 2.34+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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.10.2-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 aa8163ece9754547f74e1a97fa0f1e41a192510e5630a625f81012d61fa600dd
MD5 7701c0ef6f152b8897b064249daec63f
BLAKE2b-256 e71e4db2dafe9adfba18230c93cadfbf6ea9beb43dc65eb3be827296f1679374

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_novel-0.10.2-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.26 {"installer":{"name":"uv","version":"0.11.26","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.10.2-cp314-cp314-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 591e0577c273f41722697f54d2f1da1d5a4ff6289b6d6afab36c5766c1da132d
MD5 1a82c865e2ea25533f28fd8b742eb377
BLAKE2b-256 d9705d8c25311b477aa0086811dd0ad3462356365ccc0405cf6390f255177109

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_novel-0.10.2-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.26 {"installer":{"name":"uv","version":"0.11.26","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.10.2-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bf8aac3b96343c1227320e9b60e6c0dc758f125cd5a153d571ce67f31df0fb94
MD5 0c977e87c0d7f2c8b1ebbde7357d8b68
BLAKE2b-256 e24f80478e507616ded235fed83523beb59412b3e74271dc8d42dbee5ca4d7db

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_novel-0.10.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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.10.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7f873146379055da78c3147864aeab4fb6a711335f162bc2b0dfcb7b48f0cc8d
MD5 93359b4d45ca5b4e6e19a3a8b15adcf1
BLAKE2b-256 eca5dfd50c51edd5fbd336f557d9716f4165f093fa0d8a9386edf4fa79e08620

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_novel-0.10.2-cp313-cp313-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.13, manylinux: glibc 2.34+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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.10.2-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 de6723726a122526b076870f8a5914beb18710c4b8da5df6ebc8d11fe4d2d95a
MD5 17eae1278fa6f860a553561a7da6ca51
BLAKE2b-256 30320812b76aca35a98bc324394b5880124531c72f6b7e71215007ca2356bda0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_novel-0.10.2-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.26 {"installer":{"name":"uv","version":"0.11.26","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.10.2-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 0eed6eeb9604b579ff888203ca057dce9d57f63c9fa09d525ac9be98aaaef590
MD5 9f9e21b7815741589a1ecb9935794a58
BLAKE2b-256 759667be82e34d93fad4b571c70e0331ad3ae3175c03c5dac20c8721af033dea

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_novel-0.10.2-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.26 {"installer":{"name":"uv","version":"0.11.26","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.10.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8db4b2d00b7ac8de91394774878ec878f66cec60dab2b505d64e5b79b578eeb7
MD5 373e2bfc31449aa0432376759058232c
BLAKE2b-256 4c1e0ad17ed26cca681bdbbaff07b3d163dfe5ff084d23b799cca133e7c3860d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_novel-0.10.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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.10.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6a866a038db080e5eac7f709592c042a156e44473508bf98978f39ddd44d852e
MD5 b9e5bf40e3c6d1ecebac4fe4cf01de4b
BLAKE2b-256 d484e1a87a8917ddf74c5d0801a5c4fec4555a1dd8bf229f954e53321a052ba1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_novel-0.10.2-cp312-cp312-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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.10.2-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 6caff2214873761648786a60181fe209b51abd74f22bb62c240cbb20b19ce1a3
MD5 c9bdb50741e2d6bc21983a8a0ce7d60a
BLAKE2b-256 c8cb2afc0f119a47670ac221e3e5752ab2a8411790adf04db37e6283b65786ae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_novel-0.10.2-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.26 {"installer":{"name":"uv","version":"0.11.26","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.10.2-cp312-cp312-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 55788c2e7b81771ddf8af5d5fd813cfc77c6da84eecc49a122276c157873f466
MD5 e035192197d343964ada667d5cbf09d5
BLAKE2b-256 41e2a4dc6cb8000b999d6085f23896084de8298dfe1398bf1655072921962ed0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_novel-0.10.2-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.26 {"installer":{"name":"uv","version":"0.11.26","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.10.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9289bf161a28675a930eb65df2dd01ed0ddc7b3447289d07b7e216b89e4b5d63
MD5 4898fa4fd2878d8e4c23b5599c9dd451
BLAKE2b-256 0f0cae644c65cee92782856e93b60dd46a51c40dbc035ee588ac36dc32aba328

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