make DocumentSection.title optional
This commit is contained in:
parent
3aad734140
commit
8ecbd88498
@ -126,7 +126,7 @@ class DocumentSection(BaseModel):
|
|||||||
level: Header level (1-6 for h1-h6, 0 for Introduction)
|
level: Header level (1-6 for h1-h6, 0 for Introduction)
|
||||||
content: Section content with preserved Markdown formatting
|
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)")
|
level: int = Field(..., ge=0, le=6, description="Header level (0=intro)")
|
||||||
content: str = Field(..., description="Section content with formatting")
|
content: str = Field(..., description="Section content with formatting")
|
||||||
|
|
||||||
@ -138,7 +138,9 @@ class DocumentSection(BaseModel):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def normalize_title(cls, value: str) -> str:
|
def normalize_title(cls, value: str) -> str:
|
||||||
"""Normalize title by stripping whitespace."""
|
"""Normalize title by stripping whitespace."""
|
||||||
return value.strip()
|
if value:
|
||||||
|
return value.strip()
|
||||||
|
return value
|
||||||
|
|
||||||
def is_introduction(self) -> bool:
|
def is_introduction(self) -> bool:
|
||||||
"""Check if this is the introduction section."""
|
"""Check if this is the introduction section."""
|
||||||
|
|||||||
@ -57,7 +57,7 @@ def parse_markdown(text: str) -> List[DocumentSection]:
|
|||||||
if current_heading is not None or current_content_parts:
|
if current_heading is not None or current_content_parts:
|
||||||
content = "".join(current_content_parts).strip()
|
content = "".join(current_content_parts).strip()
|
||||||
if content: # Only add sections with actual content
|
if content: # Only add sections with actual content
|
||||||
title = current_heading if current_heading else "Introduction"
|
title = current_heading
|
||||||
sections.append(
|
sections.append(
|
||||||
DocumentSection(
|
DocumentSection(
|
||||||
title=title,
|
title=title,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user