fabricatio_novel.capabilities.novel_rag

Novel RAG capabilities combining novel composition with retrieval-augmented generation.

Classes

NovelComposeRAG

Novel composition capability extended with writing style RAG support.

Module Contents

class fabricatio_novel.capabilities.novel_rag.NovelComposeRAG

Bases: fabricatio_lancedb.capabilities.lancedb.LancedbRAG[fabricatio_novel.models.novel_rag.WritingStyleDocument, fabricatio_lancedb.capabilities.lancedb.LancedbAddRAGConfig, fabricatio_novel.models.novel_rag.WritingStyleFetchConfig], fabricatio_novel.capabilities.novel.NovelCompose, abc.ABC

Novel composition capability extended with writing style RAG support.

async fetch_and_rerank(query: str, config: fabricatio_novel.models.novel_rag.WritingStyleFetchConfig, use_reranker: bool) List[fabricatio_novel.models.novel_rag.WritingStyleDocument]

Fetch writing style documents, optionally reranking the results.

When use_reranker=True, embedding search fetches limit * rerank_scale_factor docs, then the reranker filters down to the original limit.

async create_chapters(draft: fabricatio_novel.models.draft.NovelDraft, chapter_plans: List[fabricatio_novel.models.plan.ChapterPlan], characters: List[fabricatio_character.models.character.CharacterCard], guidance: str | None = None, **kwargs: Unpack[fabricatio_novel.models.kwargs_types.NovelRAGKwargs[str]]) List[str]

Generate chapters with writing style augmentation via RAG.

Between script generation and chapter generation, retrieves writing style references from LanceDB and injects them into script/scene prompts.

When writing_style_query is provided AND WritingStyleFetchConfig.use_refined_query=True, the raw query is refined into multiple variants by the LLM and each variant is searched. Otherwise retrieval uses the script-level and scene-level prompts as queries.