aneesqumar commited on
Commit
2ca0e6e
·
verified ·
1 Parent(s): 599b6c7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -380,6 +380,8 @@ def generate_pdf(*inputs):
380
  elements.append(Spacer(1,0.4*inch))
381
 
382
  # ---- DETAILED AI REPORT (Formatted with Headings + Bullets) ----
 
 
383
  if last_llm_report:
384
  elements.append(Paragraph("<b>Detailed AI Report</b>", heading_style))
385
  elements.append(Spacer(1,0.2*inch))
@@ -388,17 +390,26 @@ def generate_pdf(*inputs):
388
 
389
  for line in lines:
390
  line = line.strip()
 
391
  if not line:
392
  continue
393
 
394
- # Detect headings (e.g., lines ending with ":" )
395
- if line.endswith(":"):
 
 
 
 
 
396
  elements.append(Spacer(1,0.2*inch))
397
- elements.append(Paragraph(f"<b>{line}</b>", heading_style))
 
 
398
  else:
 
399
  elements.append(Paragraph(f"• {line}", bullet_style))
400
 
401
- elements.append(Spacer(1,0.5*inch))
402
 
403
  # ---- DISCLAIMER ----
404
  elements.append(Paragraph("Disclaimer", disclaimer_heading_style))
 
380
  elements.append(Spacer(1,0.4*inch))
381
 
382
  # ---- DETAILED AI REPORT (Formatted with Headings + Bullets) ----
383
+ # ---- DETAILED AI REPORT (Formatted with ## Headings) ----
384
+
385
  if last_llm_report:
386
  elements.append(Paragraph("<b>Detailed AI Report</b>", heading_style))
387
  elements.append(Spacer(1,0.2*inch))
 
390
 
391
  for line in lines:
392
  line = line.strip()
393
+
394
  if not line:
395
  continue
396
 
397
+ # ❌ Remove disclaimer coming from LLM
398
+ if "consult a qualified doctor" in line.lower():
399
+ continue
400
+
401
+ # ✅ Detect headings starting with ##
402
+ if line.startswith("##"):
403
+ clean_heading = line.replace("##", "").strip()
404
  elements.append(Spacer(1,0.2*inch))
405
+ elements.append(
406
+ Paragraph(f"<b>{clean_heading}:</b>", heading_style)
407
+ )
408
  else:
409
+ #elements.append(Paragraph(line, styles["Normal"]))
410
  elements.append(Paragraph(f"• {line}", bullet_style))
411
 
412
+ elements.append(Spacer(1,0.5*inch))
413
 
414
  # ---- DISCLAIMER ----
415
  elements.append(Paragraph("Disclaimer", disclaimer_heading_style))