make DocumentSection.title optional

This commit is contained in:
m.dabbagh 2026-01-24 20:25:34 +03:30
parent 3aad734140
commit 8ecbd88498
2 changed files with 5 additions and 3 deletions

View File

@ -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."""

View File

@ -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,