mgbam commited on
Commit
a0f88c0
·
verified ·
1 Parent(s): c0d7423

Update genesis/utils/pdf_export.py

Browse files
Files changed (1) hide show
  1. genesis/utils/pdf_export.py +9 -3
genesis/utils/pdf_export.py CHANGED
@@ -12,12 +12,11 @@ def export_report_to_pdf(filename: str, title: str, summary: str, citations: lis
12
  filename (str): The name of the output PDF file.
13
  title (str): The report title.
14
  summary (str): The report summary text.
15
- citations (list): Optional list of citation strings.
16
 
17
  Returns:
18
  str: Path to the generated PDF file.
19
  """
20
- # Ensure output directory exists
21
  output_dir = "outputs"
22
  os.makedirs(output_dir, exist_ok=True)
23
  file_path = os.path.join(output_dir, filename)
@@ -38,7 +37,14 @@ def export_report_to_pdf(filename: str, title: str, summary: str, citations: lis
38
  if citations:
39
  story.append(Paragraph("<b>Citations:</b>", styles["Heading2"]))
40
  for c in citations:
41
- story.append(Paragraph(c, styles["Normal"]))
 
 
 
 
 
 
 
42
  story.append(Spacer(1, 6))
43
 
44
  # Build PDF
 
12
  filename (str): The name of the output PDF file.
13
  title (str): The report title.
14
  summary (str): The report summary text.
15
+ citations (list): Optional list of citation strings or dicts.
16
 
17
  Returns:
18
  str: Path to the generated PDF file.
19
  """
 
20
  output_dir = "outputs"
21
  os.makedirs(output_dir, exist_ok=True)
22
  file_path = os.path.join(output_dir, filename)
 
37
  if citations:
38
  story.append(Paragraph("<b>Citations:</b>", styles["Heading2"]))
39
  for c in citations:
40
+ if isinstance(c, dict):
41
+ # Build a readable string from citation fields
42
+ citation_str = ", ".join(
43
+ str(c.get(k, "")) for k in ["title", "authors", "year", "journal"] if c.get(k)
44
+ )
45
+ else:
46
+ citation_str = str(c)
47
+ story.append(Paragraph(citation_str, styles["Normal"]))
48
  story.append(Spacer(1, 6))
49
 
50
  # Build PDF