fabricatio_novel.capabilities.illustration

IllustratedNovelCompose — NovelCompose subclass for image-enriched novel generation.

Three-phase pipeline:

Phase 1: allocate image budget across chapters → {chapter_index: image_count} Phase 2: per chapter, select paragraphs to illustrate → [paragraph_index, …] Phase 3: per selected paragraph, generate image prompt with character context → image_prompt string

Then: ComfyUI generates images, <img> tags injected directly into raw text.

Classes

IllustrationOptions

User-facing configuration for the illustration pipeline.

IllustrationContext

Shared state for the illustration pipeline, constant across all chapters.

IllustratedNovelCompose

NovelCompose subclass that enriches chapters with LLM-selected illustrations.

Module Contents

class fabricatio_novel.capabilities.illustration.IllustrationOptions

User-facing configuration for the illustration pipeline.

workflow_template: pathlib.Path | None = None

Path to a ComfyUI API-format JSON workflow file. Defaults to bundled demo.

budget: int = 5

Total number of images to generate across all chapters.

language: str = 'en'

Language for illustration prompt generation.

guideline: str | None = None

Optional extra guideline for paragraph selection.

prompt_guideline: str | None = None

Optional extra guideline for image prompt wording.

comfyui_timeout: float | None = None

Absolute ComfyUI timeout in seconds. None uses budget-scaled default from config.

comfyui_base_url: str | None = None

8188).

Type:

ComfyUI server base URL override. None uses config default (http

Type:

//localhost

class fabricatio_novel.capabilities.illustration.IllustrationContext

Shared state for the illustration pipeline, constant across all chapters.

novel: fabricatio_novel.models.novel.Novel
image_root: pathlib.Path
base_wf: fabricatio_comfyui.models.workflow.Workflow
language: str
guideline: str | None
prompt_guideline: str | None
base_looks: dict[str, str]
comfyui_timeout_per_image: float

Per-image ComfyUI timeout in seconds. Multiply by chapter budget for total timeout.

comfyui_base_url: str | None = None

ComfyUI server base URL override. None uses config default.

class fabricatio_novel.capabilities.illustration.IllustratedNovelCompose

Bases: fabricatio_novel.capabilities.novel.NovelCompose, fabricatio_comfyui.capabilities.comfyui.Comfyui

NovelCompose subclass that enriches chapters with LLM-selected illustrations.

Usage:

novel = await self.compose_novel(outline, language) novel = await self.inject_chapter_images(

novel, image_root, IllustrationOptions(workflow_template=…, budget=5, guideline=”High tension moments.”,

prompt_guideline=”Cinematic lighting, painterly style.”),

) DumpNovel(novel=novel, output_path=…, image_root=image_root).execute()

async inject_chapter_images(novel: fabricatio_novel.models.novel.Novel, image_root: pathlib.Path, opts: IllustrationOptions | None = None, **kwargs: Unpack[fabricatio_core.models.kwargs_types.ValidateKwargs[None]]) fabricatio_novel.models.novel.Novel

Two-phase image injection pipeline.