fabricatio_novel.actions.enrich

Action for storing LLM-enriched text chunks in the LanceDB vector store.

Mirrors StoreWritingStyleTexts: reads text files, processes them, and indexes the resulting documents under a dedicated LanceDB table. Here the processing step is EnrichChunkTextNovel.enrich, which produces question-answer pairs from each source file. Each pair is flattened into a short text string and stored as one EnrichedDocument.

Classes

EnrichedNovelComposeRAG

MRO anchor combining enrichment, semantic chunking, and LanceDB storage.

StoreEnrichedTexts

Store LLM-enriched text chunks from files into LanceDB.

Module Contents

class fabricatio_novel.actions.enrich.EnrichedNovelComposeRAG(/, **data: Any)

Bases: fabricatio_novel.capabilities.enrich.EnrichChunkTextNovel, fabricatio_rag.capabilities.chunk.PreciseChunkText, fabricatio_lancedb.capabilities.lancedb.LancedbRAG[fabricatio_novel.models.novel_enrich.EnrichedDocument, fabricatio_novel.models.novel_enrich.EnrichedAddConfig, fabricatio_novel.models.novel_enrich.EnrichedFetchConfig], abc.ABC

MRO anchor combining enrichment, semantic chunking, and LanceDB storage.

Pulls together: - EnrichChunkTextNovel.enrich for QA-pair generation per chunk - PreciseChunkText.precise_chunk for LLM-guided semantic splitting of source files

(each input file is split into coherent chunks before enrichment, since naive whole-file enrichment degrades on long texts)

  • LancedbRAG for add_document / rebuild_index machinery over EnrichedDocument

class fabricatio_novel.actions.enrich.StoreEnrichedTexts(/, **data: Any)

Bases: fabricatio_core.Action, EnrichedNovelComposeRAG, abc.ABC

Store LLM-enriched text chunks from files into LanceDB.

Each input file is read, semantically split into coherent chunks via PreciseChunkText.precise_chunk, fed chunk-by-chunk to EnrichChunkTextNovel.enrich to produce question-answer pairs, and each pair is indexed as a separate EnrichedDocument. Document count is stored under output_key (default “stored_count”).

enrich_guideline: str = ''

Guidance passed to EnrichChunkTextNovel.enrich for QA generation.

chunk_guideline: str = ''

Guidance passed to PreciseChunkText.precise_chunk for semantic splitting.

text_files: List[pathlib.Path] | None = None

Files to read, chunk, enrich, and store. Provided by the workflow runtime.

output_key: str = 'stored_count'

Key under which the number of stored documents is stored in context.

store_config: fabricatio_novel.models.novel_enrich.EnrichedAddConfig | None = None

Optional LanceDB add-config override (table_name, batch sizes, rebuild flag).

chunk_max_size: int = 5

Maximum mini-chunks per output chunk (passed to precise_chunk).

chunk_min_size: int = 2

Minimum mini-chunks per output chunk (passed to precise_chunk).

mini_chunk_size: int | None = None

Mini-chunk character size override (defaults to rag_config.mini_chunk_size).

ctx_override: ClassVar[bool] = True

Whether to override the instance attr by the context variable.