Spaces:
Sleeping
Sleeping
| def parse_plan_sections(content: str) -> dict: | |
| """Parse the generated plan content into structured sections.""" | |
| sections = { | |
| "executive_summary": "No content generated", | |
| "scope_objectives": "No content generated", | |
| "architecture_overview": "No content generated", | |
| "component_design": "No content generated", | |
| "security_compliance": "No content generated", | |
| "deployment_testing": "No content generated", | |
| "team_roles": "No content generated", | |
| "cost_estimates": "No content generated", | |
| "project_phases": "No content generated" | |
| } | |
| current_section = None | |
| lines = content.split('\n') | |
| section_content = [] | |
| for line in lines: | |
| line = line.strip() | |
| if not line: | |
| continue | |
| # Check for section headers | |
| if line.lower().startswith('1. executive summary') or line.lower().startswith('executive summary'): | |
| if current_section and section_content: | |
| sections[current_section] = '\n'.join(section_content) | |
| current_section = 'executive_summary' | |
| section_content = [] | |
| continue | |
| elif line.lower().startswith('2. project scope') or line.lower().startswith('scope'): | |
| if current_section and section_content: | |
| sections[current_section] = '\n'.join(section_content) | |
| current_section = 'scope_objectives' | |
| section_content = [] | |
| continue | |
| elif line.lower().startswith('3. architecture') or line.lower().startswith('architecture'): | |
| if current_section and section_content: | |
| sections[current_section] = '\n'.join(section_content) | |
| current_section = 'architecture_overview' | |
| section_content = [] | |
| continue | |
| elif line.lower().startswith('4. component') or line.lower().startswith('component'): | |
| if current_section and section_content: | |
| sections[current_section] = '\n'.join(section_content) | |
| current_section = 'component_design' | |
| section_content = [] | |
| continue | |
| elif line.lower().startswith('5. security') or line.lower().startswith('security'): | |
| if current_section and section_content: | |
| sections[current_section] = '\n'.join(section_content) | |
| current_section = 'security_compliance' | |
| section_content = [] | |
| continue | |
| elif line.lower().startswith('6. deployment') or line.lower().startswith('deployment'): | |
| if current_section and section_content: | |
| sections[current_section] = '\n'.join(section_content) | |
| current_section = 'deployment_testing' | |
| section_content = [] | |
| continue | |
| elif line.lower().startswith('7. team') or line.lower().startswith('team'): | |
| if current_section and section_content: | |
| sections[current_section] = '\n'.join(section_content) | |
| current_section = 'team_roles' | |
| section_content = [] | |
| continue | |
| elif line.lower().startswith('8. cost') or line.lower().startswith('cost'): | |
| if current_section and section_content: | |
| sections[current_section] = '\n'.join(section_content) | |
| current_section = 'cost_estimates' | |
| section_content = [] | |
| continue | |
| elif line.lower().startswith('9. project') or line.lower().startswith('project'): | |
| if current_section and section_content: | |
| sections[current_section] = '\n'.join(section_content) | |
| current_section = 'project_phases' | |
| section_content = [] | |
| continue | |
| elif current_section: | |
| section_content.append(line) | |
| # Add the last section's content | |
| if current_section and section_content: | |
| sections[current_section] = '\n'.join(section_content) | |
| # Clean up empty sections | |
| for key, value in sections.items(): | |
| if not value or value.isspace(): | |
| sections[key] = "No content generated for this section." | |
| return sections |