Spaces:
Sleeping
Sleeping
File size: 1,942 Bytes
0897b0a da2c28a b5b5722 da2c28a b5b5722 da2c28a 0897b0a b5b5722 0897b0a b5b5722 0897b0a b5b5722 0897b0a b5b5722 0897b0a b5b5722 0897b0a b5b5722 0897b0a b5b5722 0897b0a b5b5722 0897b0a b5b5722 da2c28a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
import os
from reportlab.lib.pagesizes import letter
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
from reportlab.lib.styles import getSampleStyleSheet
def export_report_to_pdf(query, summary, citations, structures, funding_data, regulation_data, filename="output.pdf"):
"""Export research report to PDF."""
filepath = os.path.join(os.getcwd(), filename)
doc = SimpleDocTemplate(filepath, pagesize=letter)
styles = getSampleStyleSheet()
story = []
# Title
story.append(Paragraph(f"GENESIS-AI Research Report", styles["Title"]))
story.append(Spacer(1, 12))
# Query
story.append(Paragraph(f"<b>Query:</b> {query}", styles["Normal"]))
story.append(Spacer(1, 12))
# Summary
story.append(Paragraph("<b>Summary:</b>", styles["Heading2"]))
story.append(Paragraph(summary, styles["Normal"]))
story.append(Spacer(1, 12))
# Citations
if citations:
story.append(Paragraph("<b>Citations:</b>", styles["Heading2"]))
for c in citations:
story.append(Paragraph(f"{c.get('type', '')}: {c.get('url', '')}", styles["Normal"]))
story.append(Spacer(1, 12))
# Structures
if structures:
story.append(Paragraph("<b>Structures:</b>", styles["Heading2"]))
for s in structures:
story.append(Paragraph(str(s), styles["Normal"]))
story.append(Spacer(1, 12))
# Funding
if funding_data:
story.append(Paragraph("<b>Funding Data:</b>", styles["Heading2"]))
for f in funding_data:
story.append(Paragraph(str(f), styles["Normal"]))
story.append(Spacer(1, 12))
# Regulation
if regulation_data:
story.append(Paragraph("<b>Regulatory Info:</b>", styles["Heading2"]))
for r in regulation_data:
story.append(Paragraph(str(r), styles["Normal"]))
story.append(Spacer(1, 12))
doc.build(story)
return filepath
|