Code used in a custom GPT to generate pptx files based on a template, with summarization and execution by ChatGPT
This guide helps you connect a custom GPT that summarizes content into slides with a Python script that creates a PowerPoint presentation.
- Paste article or source content into GPT, specifying the desired slide count and the target audience.
- GPT summarizes it into structured JSON slide content.
- GPT (or you) passes the JSON into a Python script to generate
output.pptx.
The GPT should output structured JSON like this:
{
"slides": [
{
"type": "title",
"title": "Slide Title",
"subtitle": "Slide Subtitle"
},
{
"type": "content",
"title": "Slide Title",
"bullets": [
"Bullet point 1",
"Bullet point 2"
]
}
]
}The following instruction is then passed to the GPT:
After generating the JSON, save it to a file named slides.json, then run the generator.py script, available in your knowledge files, that reads this file and generates output.pptx.
Example Python snippet to execute:
import json
from generator import build_presentation_from_json
with open("slides.json", "r", encoding="utf-8") as f:
data = json.load(f)
build_presentation_from_json(data, "my_output_deck.pptx")The GPT should:
- Output the JSON and save it as
slides.json - Run this:
python generator.pyOr include this runnable script:
import json
from generator import build_presentation_from_json
with open("slides.json", "r") as f:
slide_data = json.load(f)
build_presentation_from_json(slide_data)| File | Purpose |
|---|---|
generator.py |
Python script that generates the PowerPoint |
slides.json |
Slide content from GPT |
output.pptx |
Final PowerPoint presentation |
- Add
"notes"field to slides for presenter notes. - Add
"duration"or"layout"for advanced control. - Connect to a web form or automation tool.