Spaces:
Paused
Paused
Commit
·
f8bfc75
1
Parent(s):
6088c8f
updated report
Browse files
backend/services/report_generator.py
CHANGED
|
@@ -148,47 +148,89 @@ def generate_llm_interview_report(application) -> str:
|
|
| 148 |
|
| 149 |
|
| 150 |
def create_pdf_report(report_text: str) -> BytesIO:
|
| 151 |
-
"""
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
|
| 194 |
__all__ = ['generate_llm_interview_report', 'create_pdf_report']
|
|
|
|
| 148 |
|
| 149 |
|
| 150 |
def create_pdf_report(report_text: str) -> BytesIO:
|
| 151 |
+
"""
|
| 152 |
+
Alternative implementation using reportlab for better PDF generation.
|
| 153 |
+
Install with: pip install reportlab
|
| 154 |
+
"""
|
| 155 |
+
try:
|
| 156 |
+
from reportlab.lib.pagesizes import A4
|
| 157 |
+
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
|
| 158 |
+
from reportlab.lib.units import inch
|
| 159 |
+
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, PageBreak
|
| 160 |
+
from reportlab.lib.colors import HexColor
|
| 161 |
+
|
| 162 |
+
buffer = BytesIO()
|
| 163 |
+
doc = SimpleDocTemplate(
|
| 164 |
+
buffer,
|
| 165 |
+
pagesize=A4,
|
| 166 |
+
rightMargin=0.75*inch,
|
| 167 |
+
leftMargin=0.75*inch,
|
| 168 |
+
topMargin=1*inch,
|
| 169 |
+
bottomMargin=1*inch
|
| 170 |
+
)
|
| 171 |
+
|
| 172 |
+
# Create custom styles
|
| 173 |
+
styles = getSampleStyleSheet()
|
| 174 |
+
|
| 175 |
+
question_style = ParagraphStyle(
|
| 176 |
+
'Question',
|
| 177 |
+
parent=styles['Heading2'],
|
| 178 |
+
fontSize=12,
|
| 179 |
+
textColor=HexColor('#2C3E50'),
|
| 180 |
+
spaceAfter=6,
|
| 181 |
+
spaceBefore=12
|
| 182 |
+
)
|
| 183 |
+
|
| 184 |
+
answer_style = ParagraphStyle(
|
| 185 |
+
'Answer',
|
| 186 |
+
parent=styles['Normal'],
|
| 187 |
+
fontSize=10,
|
| 188 |
+
textColor=HexColor('#34495E'),
|
| 189 |
+
leftIndent=20,
|
| 190 |
+
spaceAfter=3
|
| 191 |
+
)
|
| 192 |
+
|
| 193 |
+
score_style = ParagraphStyle(
|
| 194 |
+
'Score',
|
| 195 |
+
parent=styles['Normal'],
|
| 196 |
+
fontSize=10,
|
| 197 |
+
textColor=HexColor('#27AE60'),
|
| 198 |
+
leftIndent=20,
|
| 199 |
+
fontName='Helvetica-Bold'
|
| 200 |
+
)
|
| 201 |
+
|
| 202 |
+
feedback_style = ParagraphStyle(
|
| 203 |
+
'Feedback',
|
| 204 |
+
parent=styles['Normal'],
|
| 205 |
+
fontSize=10,
|
| 206 |
+
textColor=HexColor('#E74C3C'),
|
| 207 |
+
leftIndent=20,
|
| 208 |
+
spaceAfter=6
|
| 209 |
+
)
|
| 210 |
+
|
| 211 |
+
# Build document content
|
| 212 |
+
story = []
|
| 213 |
+
lines = report_text.split('\n')
|
| 214 |
+
|
| 215 |
+
for line in lines:
|
| 216 |
+
stripped = line.strip()
|
| 217 |
+
|
| 218 |
+
if stripped.startswith('Question'):
|
| 219 |
+
story.append(Paragraph(stripped, question_style))
|
| 220 |
+
elif stripped.startswith('Answer:'):
|
| 221 |
+
story.append(Paragraph(stripped, answer_style))
|
| 222 |
+
elif stripped.startswith('Score:'):
|
| 223 |
+
story.append(Paragraph(stripped, score_style))
|
| 224 |
+
elif stripped.startswith('Feedback:'):
|
| 225 |
+
story.append(Paragraph(stripped, feedback_style))
|
| 226 |
+
elif stripped:
|
| 227 |
+
story.append(Paragraph(stripped, styles['Normal']))
|
| 228 |
+
else:
|
| 229 |
+
story.append(Spacer(1, 12))
|
| 230 |
+
|
| 231 |
+
# Build PDF
|
| 232 |
+
doc.build(story)
|
| 233 |
+
buffer.seek(0)
|
| 234 |
+
return buffer
|
| 235 |
|
| 236 |
__all__ = ['generate_llm_interview_report', 'create_pdf_report']
|