Hey there, fellow developers! If you've ever had to manually create personalized reports or presentations you'll know it quickly becomes a laborious task.
But no worries, today I'll show you an easy, step-by-step way to automate this. We'll use Presenton, an open source self-hosted service you can run locally in Docker, combined with a simple Python script to seamlessly generate personalized presentations. You can check its github here.
Our goal? Take a simple CSV file containing student data and automatically generate engaging presentations tailored to each student's performance and feedback.
Let's get started!
First: Getting Presenton Ready with Docker
To get your Presenton service running in no time, we'll use Docker for ease and speed.
1. Install Docker (If you haven't already)
First, make sure Docker is installed on your machine. If you haven't installed it yet, it's easy and quick:
When installed, you can quickly verify it. Open your terminal/command prompt and run:
docker --version
If your version number pops up, you’re golden!
2. Run Presenton Locally
Presenton is nifty—it lets you use different LLM providers like GOOGLE, OPENAI, or your own local model via OLLAMA. For simplicity’s sake here, we’ll go with Google's API, which is beginner-friendly and easy on your wallet (in fact it's free to start with!).
Grab your Google API key quickly from Google AI Studio.
Then, start Presenton locally by running this command on your terminal/command line:
For Linux/Mac
docker run -it --name presenton -p 5000:80 -e LLM="google" -e GOOGLE_API_KEY="YOUR_API_KEY_HERE" -e CAN_CHANGE_KEYS="false" -v "./user_data:/app/user_data" ghcr.io/presenton/presenton:latest
For Windows (PowerShell)
docker run -it --name presenton -p 5000:80 -e LLM="google" -e GOOGLE_API_KEY="YOUR_API_KEY_HERE" -e CAN_CHANGE_KEYS="false" -v "${PWD}\user_data:/app/user_data" ghcr.io/presenton/presenton:latest
Replace YOUR_API_KEY_HERE with the API key you generated earlier.
Once the service is running, you should now see Presenton's UI at:
http://localhost:5000
Next Up: Creating Our Student CSV
Alright, Presenton is ready to roll, let's create a simple CSV file named students.csv with our student’s data:
Name,Final Grade,ECA Participation,Sports Involvement,Quiz Scores,Class Behavior,Comment
Jordan Hahn,88,High,Moderate,92,Excellent,"Balanced performer with high curiosity"
John Doe,73,Low,None,75,Good,"Needs motivation beyond academics"
Harry Stein,94,Moderate,High,96,Excellent,"Academic excellence and team spirit"
Arya Munt,62,None,None,58,Average,"Struggling across areas, needs focused help"
Put this file in your working directory (where your Python script will be).
Now: Preparing Our Python Script
We'll automate presentations using Python. First, install the packages we’ll need:
pip install requests pandas
Create a Python script called generate_reports.py. Below, I'll slowly guide you through creating the script clearly.
Step 1: Required Libraries and Folders
import os
import pandas as pd
import requests
# This creates a folder named 'presentations'
os.makedirs('presentations', exist_ok=True)
Step 2: Read Student Data from CSV 📄
df = pd.read_csv("students.csv")
Step 3: Define Custom Prompt 📝
To ensure the AI generates sensible presentations, we craft a complete prompt from CSV info.
def build_prompt(row):
return (
f"Student Name: {row['Name']}\n"
f"Final Grade: {row['Final Grade']}\n"
f"ECA Participation: {row['ECA Participation']}\n"
f"Sports Involvement: {row['Sports Involvement']}\n"
f"Quiz Scores: {row['Quiz Scores']}\n"
f"Class Behavior: {row['Class Behavior']}\n"
f"Teacher's Comment: {row['Comment']}\n\n"
"Generate a parent-friendly presentation summarizing this student's academic and extracurricular performance, "
"highlighting strengths, areas for improvement, and any special notes from the teacher."
)
Step 4: Generate and Download Presentations via API
for idx, row in df.iterrows():
print(f"Generating presentation for {row['Name']}")
prompt = build_prompt(row)
data = {
"prompt": prompt,
"n_slides": "8",
"language": "English",
"theme": "light",
"export_as": "pdf"
}
response = requests.post(
"http://localhost:5000/api/v1/ppt/generate/presentation",
data=data
)
if response.ok:
result = response.json()
# Construct URL to download presentation
download_url = f"http://localhost:5000{result['path']}"
filename = f"presentations/{result['path'].split('/')[-1]}"
file_response = requests.get(download_url)
if file_response.ok:
with open(filename, 'wb') as f:
f.write(file_response.content)
print(f"Presentation saved for {row['Name']} -> {filename}")
else:
print(f"Oops, couldn't download presentation for {row['Name']} (Error {file_response.status_code})")
else:
print(f"Uh-oh, failed to generate presentation for {row['Name']} (Response: {response.text})")
This script loops through each student's data, builds a detailed prompt for Presenton's API, fetches the generated presentation, and downloads it.
Finally: Run the Magic!
Ensure everything is set:
- Presenton service running in Docker
- CSV file ready
- Python dependencies installed.
Then simply run your script:
python generate_reports.py
And within a few minutes, your personalized presentations will neatly appear inside the presentations/ folder!
How it Works:
- Presenton is running locally in Docker, waiting for API requests.
- The Python script:
- Reads each student’s data from CSV.
- Crafts precise & detailed prompts.
- Interacts with Presenton to auto-generate tailored presentations.
- Downloads presentations to your disk.
Automagically generating individualized presentations has never been easier!
What's next?
- Experiment with prompts for different reporting scenarios or customizing slide count/themes.
And that's your complete run-through from setup to fully automated personalized presentations! Want more hands-on learning or got stuck along the way? The Official Documentation is always here to help. Or better yet, drop comments below!
Top comments (0)