Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -140,9 +140,17 @@ Create a complete, professionally formatted project proposal that could be prese
|
|
140 |
|
141 |
def extract_title(proposal):
|
142 |
"""Extract the title from the proposal"""
|
|
|
143 |
title_match = re.search(r"\*\*Project Proposal: (.*?)\*\*", proposal)
|
144 |
if title_match:
|
145 |
return title_match.group(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
return "Project Proposal"
|
147 |
|
148 |
def create_pdf(proposal, output_path="proposal.pdf"):
|
@@ -154,7 +162,8 @@ def create_pdf(proposal, output_path="proposal.pdf"):
|
|
154 |
styles = getSampleStyleSheet()
|
155 |
|
156 |
# Create custom styles
|
157 |
-
styles
|
|
|
158 |
parent=styles['Heading1'],
|
159 |
fontSize=16,
|
160 |
alignment=TA_CENTER,
|
@@ -179,7 +188,7 @@ def create_pdf(proposal, output_path="proposal.pdf"):
|
|
179 |
story = []
|
180 |
|
181 |
# Add title
|
182 |
-
story.append(Paragraph(f"<b>Project Proposal: {title}</b>", styles['
|
183 |
story.append(Spacer(1, 0.25*inch))
|
184 |
|
185 |
# Process sections
|
|
|
140 |
|
141 |
def extract_title(proposal):
|
142 |
"""Extract the title from the proposal"""
|
143 |
+
# Try to match the exact format first
|
144 |
title_match = re.search(r"\*\*Project Proposal: (.*?)\*\*", proposal)
|
145 |
if title_match:
|
146 |
return title_match.group(1)
|
147 |
+
|
148 |
+
# Fallback pattern for more flexibility
|
149 |
+
title_match = re.search(r"\*\*\s*(?:Project Proposal|Proposal|Title):\s*(.*?)\s*\*\*", proposal, re.IGNORECASE)
|
150 |
+
if title_match:
|
151 |
+
return title_match.group(1)
|
152 |
+
|
153 |
+
# If no title found, use a generic one
|
154 |
return "Project Proposal"
|
155 |
|
156 |
def create_pdf(proposal, output_path="proposal.pdf"):
|
|
|
162 |
styles = getSampleStyleSheet()
|
163 |
|
164 |
# Create custom styles
|
165 |
+
# Use a different name to avoid collision with existing styles
|
166 |
+
styles.add(ParagraphStyle(name='ProposalTitle',
|
167 |
parent=styles['Heading1'],
|
168 |
fontSize=16,
|
169 |
alignment=TA_CENTER,
|
|
|
188 |
story = []
|
189 |
|
190 |
# Add title
|
191 |
+
story.append(Paragraph(f"<b>Project Proposal: {title}</b>", styles['ProposalTitle']))
|
192 |
story.append(Spacer(1, 0.25*inch))
|
193 |
|
194 |
# Process sections
|