Spaces:
Running

16.6 kB
baffon's picture
from reportlab.lib.pagesizes import A4 from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle from reportlab.lib.units import inch from reportlab.pdfgen import canvas from reportlab.lib.utils import ImageReader import os # Output path for the new PDF output_path = "/mnt/data/AGI_vs_Current_AI_with_AI_Background.pdf" # Define styles styles = getSampleStyleSheet() title_style = styles['Title'] subtitle_style = styles['Heading2'] normal_style = styles['BodyText'] # Create the document doc = SimpleDocTemplate(output_path, pagesize=A4) story = [] # Add title story.append(Paragraph("AGI vs. Current AI (like ChatGPT)", title_style)) story.append(Spacer(1, 12)) # Add table-like text data = [ ("Aspect", "Narrow AI (Now)", "AGI (Future Goal)"), ("Scope", "Task-specific", "General purpose"), ("Flexibility", "Limited", "Highly adaptable"), ("Learning", "Needs retraining", "Can learn continuously"), ("Creativity", "Simulated", "Possibly original"), ("Autonomy", "Controlled", "Fully autonomous"), ] # Format as paragraphs for row in data: aspect = f"<b>{row[0]}</b>: {row[1]} β†’ <i>{row[2]}</i>" story.append(Paragraph(aspect, normal_style)) story.append(Spacer(1, 6)) # Background function with AI image def draw_background(canvas, doc): bg_path = "/mnt/data/ai_background.jpg" if os.path.exists(bg_path): canvas.drawImage(ImageReader(bg_path), 0, 0, width=A4[0], height=A4[1], mask='auto') # Download a placeholder AI background image import requests img_url = "https://cdn.pixabay.com/photo/2019/10/15/08/47/artificial-intelligence-4550604_1280.jpg" img_path = "/mnt/data/ai_background.jpg" with open(img_path, "wb") as f: f.write(requests.get(img_url).content) # Build the PDF with background doc.build(story, onFirstPage=draw_background, onLaterPages=draw_background) output_path - Initial Deployment
d80de63 verified