Skip to main content

Module style

Module style 

Source
Expand description

Style sheets — per-book/series/global rendering hints injected into the translation prompt.

A style sheet captures the per-book stylistic decisions that --prompt-extra was a thin proxy for: narrative register, dialogue formality, loanword policy, and free-form custom instructions. Several sheets at different scopes can be active simultaneously; they merge book > series > global with the same precedence as glossary terms (see merge_style_sheets).

The merged sheet renders as a single prompt block; the prompt template references it via {{style_guide_block}}. When no sheet is active, the block renders to an empty string.

Structs§

DoNotFields
RegisterFields
Narrative register: maps to source-language → target-language voice conventions. Values are strings so the user can pick conventions outside this enum (passato_remoto etc.) without us pre-enumerating every target-language idiom.
StyleSheet
VoiceFields

Functions§

merge_style_sheets
Merge multiple style sheets following book > series > global precedence (mirrors crate::glossary::merge_scope_terms). For scalar Optional fields, the highest-priority non-None wins. For do_not.translate_terms and do_not.preserve_punctuation, vectors concatenate with deduplication. free_text_instructions concatenates global-first → book-last so book-level instructions appear most prominently to the model. Returns None if no input sheets carry any content.
render_style_block
Render the merged style sheet as a prompt block. Empty input returns an empty string so the placeholder substitutes to nothing in templates that don’t reference style guides.
style_fingerprint
Stable fingerprint of the merged style sheet for cache namespacing and snapshot integrity. When merged is None, returns the fingerprint of the empty payload — stable across runs and across upgrades, so users without --style see no cache invalidation.