feat(writer): add Phase5 data models (ContentBlock/ChapterContent/GenerationContext/ChapterSpec)
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
"""Writer 子系统数据模型(Phase 5)。"""
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Literal
|
||||
|
||||
|
||||
@dataclass
|
||||
class ContentBlock:
|
||||
"""LLM 生成的内容块。注意:table.headers/caption、list.items/style 在渲染至
|
||||
DocxInjector.Block 时显式丢弃(renderer 中声明并测试)。"""
|
||||
|
||||
block_id: str
|
||||
type: Literal["paragraph", "heading", "table", "list", "note"]
|
||||
level: int | None = None
|
||||
text: str | None = None
|
||||
caption: str | None = None
|
||||
headers: list[str] | None = None
|
||||
rows: list[list[str]] | None = None
|
||||
items: list[str] | None = None
|
||||
style: str | None = None
|
||||
source_uris: list[str] = field(default_factory=list)
|
||||
|
||||
|
||||
@dataclass
|
||||
class ChapterContent:
|
||||
chapter_id: str
|
||||
version: int
|
||||
title: str
|
||||
blocks: list[ContentBlock]
|
||||
|
||||
|
||||
@dataclass
|
||||
class ChapterSpec:
|
||||
"""template_mapper 产出:驱动 WriterAgent 串行顺序。"""
|
||||
|
||||
chapter_id: str
|
||||
title: str
|
||||
section_placeholder: str | None = None # 如 "{{section:db_design}}",无则 None
|
||||
|
||||
|
||||
@dataclass
|
||||
class GenerationContext:
|
||||
chapter_id: str
|
||||
title: str
|
||||
template_marker: ChapterSpec
|
||||
structured_source: object | None
|
||||
write_rules: list[str]
|
||||
design_rules: list[str]
|
||||
template_styles: set[str]
|
||||
prior_state: object | None = None # WriterState,避免循环 import 用 object
|
||||
Reference in New Issue
Block a user