From 8ecbd884989db61ac6c323c1d2a94be30595fa62 Mon Sep 17 00:00:00 2001 From: "m.dabbagh" Date: Sat, 24 Jan 2026 20:25:34 +0330 Subject: [PATCH] make DocumentSection.title optional --- src/core/domain/models.py | 6 ++++-- src/core/domain/parsers.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/domain/models.py b/src/core/domain/models.py index 10d016b..4bd2914 100644 --- a/src/core/domain/models.py +++ b/src/core/domain/models.py @@ -126,7 +126,7 @@ class DocumentSection(BaseModel): level: Header level (1-6 for h1-h6, 0 for Introduction) content: Section content with preserved Markdown formatting """ - title: str = Field(..., min_length=1, description="Section title") + title: Optional[str] = Field(None, min_length=1, description="Section title") level: int = Field(..., ge=0, le=6, description="Header level (0=intro)") content: str = Field(..., description="Section content with formatting") @@ -138,7 +138,9 @@ class DocumentSection(BaseModel): @classmethod def normalize_title(cls, value: str) -> str: """Normalize title by stripping whitespace.""" - return value.strip() + if value: + return value.strip() + return value def is_introduction(self) -> bool: """Check if this is the introduction section.""" diff --git a/src/core/domain/parsers.py b/src/core/domain/parsers.py index ac24cd8..5bafd3b 100644 --- a/src/core/domain/parsers.py +++ b/src/core/domain/parsers.py @@ -57,7 +57,7 @@ def parse_markdown(text: str) -> List[DocumentSection]: if current_heading is not None or current_content_parts: content = "".join(current_content_parts).strip() if content: # Only add sections with actual content - title = current_heading if current_heading else "Introduction" + title = current_heading sections.append( DocumentSection( title=title,