diff --git a/src/core/models.py b/src/core/models.py index a1e0a45..9d997ba 100644 --- a/src/core/models.py +++ b/src/core/models.py @@ -8,12 +8,11 @@ from pydantic import BaseModel, Field class StrategyName(str, Enum): """Canonical identifiers for each chunking strategy.""" - - CONTEXTUAL_STRUCTURE = "contextual_structure" - PARENT_CHILD = "parent_child" - SEMANTIC = "semantic" - MARKDOWN_STRUCTURE = "markdown_structure" RECURSIVE = "recursive" + FIXED_SIZE = "fixed_size" + SEMANTIC = "semantic" + CONTEXTUAL_RETRIEVAL = "contextual_retrieval" + SEMANTIC_PARENT_CHILD = "semantic_parent_child" class Chunk(BaseModel): @@ -56,4 +55,41 @@ def chunk_to_metadata(chunk: Chunk) -> ChunkMetadata: token_count=chunk.token_count, character_count=chunk.character_count, parent_id=chunk.parent_id, - ) \ No newline at end of file + ) + + +# ── Document Tree ────────────────────────────────────────────────── + +class NodeType(str, Enum): + DOCUMENT = "document" + SECTION = "section" + ARTICLE = "article" + PARAGRAPH = "paragraph" + + +class DocumentTreeNode(BaseModel): + """A node in the hierarchical document tree extracted by python-docx. + + Tree shape: Document > Section > Article > Paragraph. + All nodes are serialisable to JSON for SQLite storage. + """ + node_type: NodeType + text: str = "" + heading: Optional[str] = None # heading label, e.g. "Article 15" + heading_level: Optional[int] = None # 1, 2, 3 … + children: list["DocumentTreeNode"] = Field(default_factory=list) + + +class DocumentTree(BaseModel): + """Root wrapper for a parsed document's hierarchy.""" + root: DocumentTreeNode + + +# ── Pagination helper ────────────────────────────────────────────── + +class PaginatedResponse(BaseModel): + """Generic paginated list wrapper.""" + items: list = Field(default_factory=list) + total: int = 0 + offset: int = 0 + limit: int = 50 \ No newline at end of file