PitchForge_AI / app /deck.py
MSivasandeep's picture
Upload 7 files
a189123 verified
Raw History Blame Contribute Delete
2.57 kB
from pathlib import Path
from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.enum.text import PP_ALIGN
from pptx.enum.shapes import MSO_SHAPE
from pptx.dml.color import RGBColor
OUT = Path("/tmp/pitchforge")
SLIDES = [
("Problem", "problem"),
("Solution", "solution"),
("Product", "product"),
("Market", "market"),
("Business Model", "business_model"),
("Technology", "technology"),
("Competition", "competition"),
("Advantage", "advantage"),
("Roadmap", "roadmap"),
("Team", "team"),
("Funding Ask", "funding_ask"),
]
def _add_text(slide, text, x, y, w, h, size=24, bold=False):
box = slide.shapes.add_textbox(Inches(x), Inches(y), Inches(w), Inches(h))
tf = box.text_frame
tf.word_wrap = True
p = tf.paragraphs[0]
p.text = text
p.font.size = Pt(size)
p.font.bold = bold
p.font.name = "Aptos"
p.font.color.rgb = RGBColor(245, 247, 250)
return box
def _add_base(slide, title, index):
bg = slide.background.fill
bg.solid()
bg.fore_color.rgb = RGBColor(11, 16, 32)
bar = slide.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, 0, Inches(0.14), Inches(7.5))
bar.fill.solid()
bar.fill.fore_color.rgb = RGBColor(79, 70, 229)
bar.line.fill.background()
_add_text(slide, title, 0.7, 0.55, 11.8, 0.65, 30, True)
_add_text(slide, f"PITCHFORGE AI • {index:02d}", 10.2, 7.05, 2.4, 0.25, 9, False)
def create_deck(data: dict) -> str:
OUT.mkdir(parents=True, exist_ok=True)
path = OUT / "pitchforge_pitch_deck.pptx"
prs = Presentation()
prs.slide_width = Inches(13.333)
prs.slide_height = Inches(7.5)
title = prs.slides.add_slide(prs.slide_layouts[6])
_add_base(title, data.get("title", "PitchForge AI"), 1)
_add_text(title, data.get("tagline", "Investor-ready pitch deck"), 0.8, 2.25, 11.6, 1.1, 34, True)
_add_text(title, "Generated from project source material", 0.8, 3.55, 8.5, 0.5, 18)
_add_text(title, "Algorand TestNet • x402 • Hugging Face AI", 0.8, 6.35, 8.5, 0.35, 12)
for i, (title_text, key) in enumerate(SLIDES, start=2):
slide = prs.slides.add_slide(prs.slide_layouts[6])
_add_base(slide, title_text, i)
section = data.get(key, {})
_add_text(slide, section.get("headline", ""), 0.8, 1.55, 11.6, 0.65, 21, True)
bullets = section.get("bullets", [])[:5]
y = 2.45
for bullet in bullets:
_add_text(slide, "• " + str(bullet), 1.0, y, 11.0, 0.72, 17)
y += 0.82
prs.save(path)
return str(path)