Merge pull request #68 from presenton/docs
docs(mintlify): adds setup for using OpenAI Compatible API and tutorials
This commit is contained in:
commit
a6f0bce85e
12 changed files with 874 additions and 42 deletions
|
|
@ -1,43 +1,114 @@
|
|||
---
|
||||
title: "Environment Variables"
|
||||
description: "Configure Presenton using environment variables."
|
||||
description: "Presenton can be customized and secured using environment variables. These variables control access, integrations, and model providers."
|
||||
---
|
||||
|
||||
Presenton can be customized and secured using environment variables. Below are the key variables you can set when running the app:
|
||||
### 🔧 Core Configuration
|
||||
|
||||
- **`CAN_CHANGE_KEYS`**\
|
||||
Controls whether users can modify API keys through the app interface.\
|
||||
Set to `"false"` to keep keys hidden and unchangeable, or `"true"` to allow changes.\
|
||||
_Example:_ `CAN_CHANGE_KEYS="false"`
|
||||
* **`CAN_CHANGE_KEYS`**
|
||||
Controls whether users can view or modify API keys via the interface.
|
||||
Set to `"false"` to keep keys hidden and locked, or `"true"` to allow modification.
|
||||
*Example:*
|
||||
|
||||
- **`LLM`**\
|
||||
Select which Large Language Model provider Presenton should use.\
|
||||
Supported values: `"openai"`, `"google"`, `"ollama"`.\
|
||||
_Example:_ `LLM="openai"`
|
||||
```bash
|
||||
CAN_CHANGE_KEYS="false"
|
||||
```
|
||||
|
||||
- **`OPENAI_API_KEY`**\
|
||||
Your OpenAI API key. Required if `LLM` is set to `"openai"`.\
|
||||
_Example:_ `OPENAI_API_KEY="sk-xxxxxxxxxxxxxxxx"`
|
||||
* **`LLM`**
|
||||
Select the Large Language Model (LLM) provider to use.
|
||||
Supported values: `"openai"`, `"google"`, `"ollama"`, `"custom"`
|
||||
*Example:*
|
||||
|
||||
- **`GOOGLE_API_KEY`**\
|
||||
Your Google API key. Required if `LLM` is set to `"google"`.\
|
||||
_Example:_ `GOOGLE_API_KEY="AIzaSyXXXXXXXXXXXX"`
|
||||
```bash
|
||||
LLM="openai"
|
||||
```
|
||||
|
||||
- **`OLLAMA_MODEL`**\
|
||||
The Ollama model name to use. Required if `LLM` is set to `"ollama"`.\
|
||||
_Example:_ `OLLAMA_MODEL="llama3.2:3b"`
|
||||
|
||||
- **`PEXELS_API_KEY`**\
|
||||
API key for the Pexels image service. Optional but recommended when using Ollama models to enhance image search.\
|
||||
_Example:_ `PEXELS_API_KEY="vzXXXXXXXXXXXXXX"`
|
||||
### 🧠 Model Provider Specific Variables
|
||||
|
||||
### Example: Running Presenton with Environment Variables
|
||||
#### 🔹 OpenAI
|
||||
|
||||
* **`OPENAI_API_KEY`**
|
||||
Required if `LLM="openai"`
|
||||
*Example:*
|
||||
|
||||
```bash
|
||||
OPENAI_API_KEY="sk-xxxxxxxxxxxxxxxx"
|
||||
```
|
||||
|
||||
#### 🔹 Google
|
||||
|
||||
* **`GOOGLE_API_KEY`**
|
||||
Required if `LLM="google"`
|
||||
*Example:*
|
||||
|
||||
```bash
|
||||
GOOGLE_API_KEY="AIzaSyXXXXXXXXXXXX"
|
||||
```
|
||||
> ⚠️ Image generation is not supported in EU regions with Google.
|
||||
|
||||
#### 🔹 Ollama
|
||||
|
||||
* **`OLLAMA_URL`**
|
||||
(Optional) URL of your custom Ollama server. Useful if you're self-hosting.
|
||||
*Example:*
|
||||
|
||||
```bash
|
||||
OLLAMA_URL="http://localhost:11434"
|
||||
```
|
||||
|
||||
* **`OLLAMA_MODEL`**
|
||||
Required if `LLM="ollama"`
|
||||
*Example:*
|
||||
|
||||
```bash
|
||||
OLLAMA_MODEL="llama3.2:3b"
|
||||
```
|
||||
|
||||
#### 🔹 Custom (OpenAI-compatible LLMs)
|
||||
|
||||
* **`CUSTOM_LLM_URL`**
|
||||
Required if `LLM="custom"`
|
||||
*Example:*
|
||||
|
||||
```bash
|
||||
CUSTOM_LLM_URL="https://api.your-custom-llm.com/v1"
|
||||
```
|
||||
|
||||
* **`CUSTOM_LLM_API_KEY`**
|
||||
Required if `LLM="custom"`
|
||||
*Example:*
|
||||
|
||||
```bash
|
||||
CUSTOM_LLM_API_KEY="your_custom_key"
|
||||
```
|
||||
|
||||
* **`CUSTOM_MODEL`**
|
||||
Required if `LLM="custom"`
|
||||
*Example:*
|
||||
|
||||
```bash
|
||||
CUSTOM_MODEL="llama3.2:3b"
|
||||
```
|
||||
|
||||
### 🖼️ Image Enhancement
|
||||
|
||||
* **`PEXELS_API_KEY`**
|
||||
(Optional) Used to fetch high-quality stock images when using `ollama` or `custom` models.
|
||||
*Example:*
|
||||
|
||||
```bash
|
||||
PEXELS_API_KEY="vzXXXXXXXXXXXXXX"
|
||||
```
|
||||
|
||||
### 🐳 Docker Example
|
||||
|
||||
```bash
|
||||
docker run -it --name presenton -p 5000:80 \
|
||||
-e LLM="openai" \
|
||||
-e OPENAI_API_KEY="your_openai_api_key" \
|
||||
-e LLM="ollama" \
|
||||
-e OLLAMA_MODEL="llama3.2:3b" \
|
||||
-e OLLAMA_URL="http://localhost:11434" \
|
||||
-e CAN_CHANGE_KEYS="false" \
|
||||
-e PEXELS_API_KEY="your_pexels_key" \
|
||||
-v "./user_data:/app/user_data" \
|
||||
ghcr.io/presenton/presenton:v0.3.0-beta
|
||||
ghcr.io/presenton/presenton:latest
|
||||
```
|
||||
30
docs/configurations/using-custom-llm.mdx
Normal file
30
docs/configurations/using-custom-llm.mdx
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
---
|
||||
title: 'Using OpenAI-Compatible APIs'
|
||||
description: 'Presenton supports OpenAI-compatible APIs, allowing you to connect to any custom LLM backend that follows the OpenAI API format.'
|
||||
---
|
||||
|
||||
### 🌐 Example: Run Presenton with a Custom LLM
|
||||
|
||||
```bash
|
||||
docker run -it --name presenton -p 5000:80 \
|
||||
-e LLM="custom" \
|
||||
-e CUSTOM_LLM_URL="http://XXXXXXXXXXX/v1" \
|
||||
-e CUSTOM_LLM_API_KEY="your_custom_api_key" \
|
||||
-e CUSTOM_MODEL="your-model-name" \
|
||||
-e CAN_CHANGE_KEYS="false" \
|
||||
-v "./user_data:/app/user_data" \
|
||||
ghcr.io/presenton/presenton:latest
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 🔧 Environment Variables for Custom LLM
|
||||
|
||||
| Variable | Description |
|
||||
| -------------------- | ----------------------------------------------------------------------- |
|
||||
| `LLM="custom"` | Use the `custom` value to enable OpenAI-compatible API support |
|
||||
| `CUSTOM_LLM_URL` | Base URL of your OpenAI-compatible API (e.g. `http://XXXXXXXXXXX/v1`) |
|
||||
| `CUSTOM_LLM_API_KEY` | API key used for authorization (`Bearer` header) |
|
||||
| `CUSTOM_MODEL` | ID of the model to use (as defined by your API provider) |
|
||||
| `PEXELS_API_KEY` | *(Optional)* Used to fetch high-quality images to enhance presentations |
|
||||
| `CAN_CHANGE_KEYS` | Set to `false` to hide API keys from the frontend |
|
||||
|
|
@ -33,5 +33,5 @@ docker run -it --name presenton --gpus=all -p 5000:80 \
|
|||
-e PEXELS_API_KEY="your_pexels_api_key" \
|
||||
-e CAN_CHANGE_KEYS="false" \
|
||||
-v "./user_data:/app/user_data" \
|
||||
ghcr.io/presenton/presenton:v0.3.0-beta
|
||||
ghcr.io/presenton/presenton:latest
|
||||
```
|
||||
|
|
@ -3,13 +3,11 @@ title: "Using Ollama Models"
|
|||
description: "Follow these steps to generate presentations using Ollama"
|
||||
---
|
||||
|
||||
Presenton supports running fully offline using open-source models via [Ollama](https://ollama.com/). This allows you to generate presentations without relying on cloud APIs — keeping your data private and costs low.
|
||||
## 🔌 Run Presenton with an Ollama Model (Fully Offline)
|
||||
|
||||
### 🚀 Run Presenton with an Ollama Model
|
||||
Presenton supports fully offline operation using open-source models via [Ollama](https://ollama.com/). This allows you to generate presentations without relying on cloud APIs — keeping your data private and costs low.
|
||||
|
||||
Make sure you have [Ollama installed](https://ollama.com/download) and models downloaded if running them outside Docker.
|
||||
|
||||
To run Presenton with an Ollama model:
|
||||
### 🚀 Example: Run Presenton with Ollama
|
||||
|
||||
```bash
|
||||
docker run -it --name presenton -p 5000:80 \
|
||||
|
|
@ -18,10 +16,53 @@ docker run -it --name presenton -p 5000:80 \
|
|||
-e PEXELS_API_KEY="your_pexels_api_key" \
|
||||
-e CAN_CHANGE_KEYS="false" \
|
||||
-v "./user_data:/app/user_data" \
|
||||
ghcr.io/presenton/presenton:v0.3.0-beta
|
||||
ghcr.io/presenton/presenton:latest
|
||||
```
|
||||
|
||||
> 💡 **Note:** A valid **Pexels API key is required** for image generation when using Ollama models.
|
||||
### 🚀 Example: Run Presenton with you own Ollama server
|
||||
|
||||
```bash
|
||||
docker run -it --name presenton -p 5000:80 \
|
||||
-e LLM="ollama" \
|
||||
-e OLLAMA_MODEL="llama3.2:3b" \
|
||||
-e OLLAMA_URL="http://XXXXXXXXXXXXX" \
|
||||
-e PEXELS_API_KEY="your_pexels_api_key" \
|
||||
-e CAN_CHANGE_KEYS="false" \
|
||||
-v "./user_data:/app/user_data" \
|
||||
ghcr.io/presenton/presenton:latest
|
||||
```
|
||||
|
||||
|
||||
### 🧾 Ollama Environment Variables
|
||||
|
||||
* **`LLM="ollama"`**
|
||||
Select Ollama as the LLM backend.
|
||||
|
||||
* **`OLLAMA_MODEL`**
|
||||
Required. The Ollama model to use (e.g., `llama3.2:3b`, `mistral`, `phi3`, etc.).
|
||||
*Example:*
|
||||
|
||||
```bash
|
||||
OLLAMA_MODEL="llama3.2:3b"
|
||||
```
|
||||
|
||||
* **`OLLAMA_URL`**
|
||||
Optional. Set this if you're running Ollama outside Docker or on a custom host.
|
||||
*Example:*
|
||||
|
||||
```bash
|
||||
OLLAMA_URL="http://XXXXXXXXXXXX"
|
||||
```
|
||||
|
||||
* **`PEXELS_API_KEY`**
|
||||
Optional but recommended. Used to fetch stock images for enhanced visuals.
|
||||
*Example:*
|
||||
|
||||
```bash
|
||||
PEXELS_API_KEY="vzXXXXXXXXXXXXXX"
|
||||
```
|
||||
|
||||
> 💡 **Note:** Provide a valid **Pexels API key** for image generation when using Ollama models.
|
||||
> You can get a free API key at https://www.pexels.com/api/
|
||||
|
||||
> ✅ Add `--gpus=all` to enable GPU acceleration (see [Using GPU](/docs/configurations/using-gpu)).
|
||||
|
|
|
|||
|
|
@ -19,9 +19,15 @@ cd presenton
|
|||
|
||||
Build and start the development environment using Docker Compose:
|
||||
|
||||
- Without GPU
|
||||
|
||||
```bash
|
||||
docker compose up development --build
|
||||
```
|
||||
- With GPU
|
||||
```bash
|
||||
docker compose up development-gpu --build
|
||||
```
|
||||
|
||||
This command will build the development container and start the app. Once running, you can access Presenton at:
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
"pages": [
|
||||
"index",
|
||||
"quickstart",
|
||||
"development"
|
||||
"development",
|
||||
"using-presenton-api"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -26,8 +27,17 @@
|
|||
"pages": [
|
||||
"configurations/environment-variables",
|
||||
"configurations/using-ollama-models",
|
||||
"configurations/using-custom-llm",
|
||||
"configurations/using-gpu"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Tutorials",
|
||||
"pages": [
|
||||
"tutorial/generate-presentation-over-api",
|
||||
"tutorial/generate-presentation-from-csv",
|
||||
"tutorial/create-data-reports-using-ai"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
title: "Introduction"
|
||||
description: "Welcome to Presenton — your AI presentation generator"
|
||||
description: "Welcome to Presenton, your AI presentation generator"
|
||||
---
|
||||
|
||||
**Presenton** is an open-source AI presentation generator that runs entirely on your local machine. Built as a powerful alternative to cloud-based tools like Gamma, Presenton offers you complete ownership of your data and full control over how presentations are generated.
|
||||
|
|
@ -10,11 +10,9 @@ With seamless support for multiple large language models (LLMs)—including **Op
|
|||
Presenton is designed around three core principles:
|
||||
|
||||
- **Simplicity** – No complex setup or vendor-specific tooling.
|
||||
|
||||
- **Flexibility** – Choose your preferred LLM, define your own themes, and fine-tune the generation workflow.
|
||||
|
||||
- **Transparency** – No telemetry, no vendor lock-in, and no hidden costs.
|
||||
|
||||
Whether you're building technical presentations, summarizing reports, or creating educational materials, Presenton empowers you to work **securely**, **efficiently**, and **on your own terms**—with complete freedom over your infrastructure, APIs, and data.
|
||||
|
||||
Join the open-source movement and redefine how presentations are made—\*\*your slides, your way.\*\*
|
||||
Join the open-source movement and redefine how presentations are made—**your slides, your way.**
|
||||
|
|
@ -8,13 +8,13 @@ description: "Follow these steps to get Presenton up and running using Docker"
|
|||
#### 🔧 On Linux or macOS (Bash/Zsh):
|
||||
|
||||
```bash
|
||||
docker run -it --name presenton -p 5000:80 -v "./user_data:/app/user_data" ghcr.io/presenton/presenton:v0.3.0-beta
|
||||
docker run -it --name presenton -p 5000:80 -v "./user_data:/app/user_data" ghcr.io/presenton/presenton:latest
|
||||
````
|
||||
|
||||
#### 🪟 On Windows (PowerShell):
|
||||
|
||||
```bash
|
||||
docker run -it --name presenton -p 5000:80 -v "${PWD}\user_data:/app/user_data" ghcr.io/presenton/presenton:v0.3.0-beta
|
||||
docker run -it --name presenton -p 5000:80 -v "${PWD}\user_data:/app/user_data" ghcr.io/presenton/presenton:latest
|
||||
```
|
||||
|
||||
> ✅ You can replace `5000` with any other available port to avoid conflicts.
|
||||
|
|
|
|||
225
docs/tutorial/create-data-reports-using-ai.mdx
Normal file
225
docs/tutorial/create-data-reports-using-ai.mdx
Normal file
|
|
@ -0,0 +1,225 @@
|
|||
---
|
||||
title: "Create Data Reports Using AI"
|
||||
description: "Step-by-step guide to generating company sales reports from a CSV file"
|
||||
---
|
||||
|
||||
In this tutorial, we will generate detailed, multi-slide sales data reports for multiple companies using a self-hosted Presenton's API and a Python script.
|
||||
|
||||
This tutorial extends [Generate a PPT via API in 5 Minutes](./generate-presentation-over-api) and shows you how to automate the creation of structured sales reports from a CSV file using Python.
|
||||
|
||||
So, do check it before continuing with this and make sure you have Presenton running locally or on any server, and you are able to generate presentations with it.
|
||||
|
||||
---
|
||||
|
||||
## 1. Prepare Your CSV File
|
||||
|
||||
Save your sales data as `sales_data.csv`:
|
||||
|
||||
```csv
|
||||
Company,Month,Region,Total Sales,Product A Sales,Product B Sales,Product C Sales,Quarter Target Achieved,Top Sales Rep,New Clients,Client Churn Rate,Growth vs Last Quarter,Marketing Spend,Customer Satisfaction,Notable Events
|
||||
AcmeCorp,2024-03,North,98000,45000,37000,16000,Yes,Sarah Dee,13,2%,5.5%,11500,8.9,"Launched B2B platform"
|
||||
AcmeCorp,2024-03,South,76800,30000,39000,7800,Yes,John Lee,9,3%,4.5%,9200,8.3,"New partnership established"
|
||||
BetaBiz,2024-03,West,82000,22000,47000,13000,No,Monica Tai,7,4%,-1.0%,10900,7.3,"Ad campaign underperformed"
|
||||
BetaBiz,2024-03,East,94500,40000,41000,13500,Yes,Derek Shah,11,2.2%,7.2%,12400,8.6,"Exceeded upsell targets"
|
||||
ZenithLtd,2024-03,Central,101300,38000,51200,12000,Yes,Rita Ganesh,14,1.1%,9.6%,13800,9.2,"Record-high client retention"
|
||||
ZenithLtd,2024-03,East,85450,25000,47000,13450,No,Marcus Bell,8,3.8%,-2.8%,10100,7.9,"Sales dip in Product C"
|
||||
GammaInc,2024-03,North,91200,39000,43000,9200,Yes,Emily Jones,10,1.5%,6.2%,11800,8.8,"Employee incentive program"
|
||||
GammaInc,2024-03,Sales Ops,79000,31000,39000,9000,No,David Yu,6,5.5%,-3.2%,8700,7.1,"System migration delayed"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. Install Python Requirements
|
||||
|
||||
You’ll need the `requests` and `pandas` libraries:
|
||||
|
||||
```bash
|
||||
pip install requests pandas
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Write the Python Script
|
||||
|
||||
Let’s build the script step by step.
|
||||
|
||||
### a. Import Libraries
|
||||
|
||||
```python
|
||||
import os
|
||||
import pandas as pd
|
||||
import requests
|
||||
```
|
||||
|
||||
### b. Create reports directory
|
||||
|
||||
```python
|
||||
os.makedirs('reports', exist_ok=True)
|
||||
```
|
||||
|
||||
### c. Load the CSV
|
||||
|
||||
```python
|
||||
df = pd.read_csv("sales_data.csv")
|
||||
```
|
||||
|
||||
### d. Group Data by Company
|
||||
|
||||
```python
|
||||
company_groups = df.groupby("Company")
|
||||
```
|
||||
|
||||
### e. Define a Function to Build the Prompt
|
||||
|
||||
```python
|
||||
def build_prompt(company, group):
|
||||
"""
|
||||
Build a markdown prompt with data summary, chart instructions, and slide structure.
|
||||
"""
|
||||
summary = []
|
||||
regions = group['Region'].unique()
|
||||
total_sales = group['Total Sales'].sum()
|
||||
total_clients = group['New Clients'].sum()
|
||||
churn = group['Client Churn Rate'].mean()
|
||||
satisfaction = group['Customer Satisfaction'].mean()
|
||||
growth = group['Growth vs Last Quarter'].mean()
|
||||
marketing = group['Marketing Spend'].sum()
|
||||
notable = "; ".join(group['Notable Events'].unique())
|
||||
|
||||
# Markdown-structured prompt
|
||||
prompt = f"""
|
||||
## Sales Report for {company}
|
||||
|
||||
### 1. Executive Summary
|
||||
- Total sales: **${total_sales:,.0f}**
|
||||
- Average client churn: **{churn:.2f}%**
|
||||
- Customer satisfaction: **{satisfaction:.2f}/10**
|
||||
- Notable events: _{notable}_
|
||||
|
||||
### 2. Regional Performance
|
||||
**Bar Chart:** Regional Total Sales
|
||||
|
||||
| Region | Sales |
|
||||
|---|---|
|
||||
"""
|
||||
for region in regions:
|
||||
reg_sales = group[group['Region'] == region]['Total Sales'].sum()
|
||||
prompt += f"| {region} | ${reg_sales:,.0f} |\n"
|
||||
|
||||
prompt += """
|
||||
|
||||
### 3. Product Performance
|
||||
**Bar Chart:** Sales by Product per Region
|
||||
|
||||
| Region | Product A | Product B | Product C |
|
||||
|---|---|---|---|
|
||||
"""
|
||||
for region in regions:
|
||||
gr = group[group['Region'] == region]
|
||||
a = gr['Product A Sales'].sum()
|
||||
b = gr['Product B Sales'].sum()
|
||||
c = gr['Product C Sales'].sum()
|
||||
prompt += f"| {region} | ${a:,.0f} | ${b:,.0f} | ${c:,.0f} |\n"
|
||||
|
||||
prompt += f"""
|
||||
|
||||
### 4. Key Metrics & Trends
|
||||
- Aggregate new clients this month: **{total_clients}**
|
||||
- Mean growth vs last quarter: **{growth:.2f}%**
|
||||
- Total marketing spend: **${marketing:,.0f}**
|
||||
|
||||
### 5. Top Performers
|
||||
| Region | Top Sales Rep | New Clients |
|
||||
|---|---|---|
|
||||
"""
|
||||
for region in regions:
|
||||
gr = group[group['Region'] == region]
|
||||
rep = gr['Top Sales Rep'].iloc[0]
|
||||
clients = gr['New Clients'].iloc[0]
|
||||
prompt += f"| {region} | {rep} | {clients} |\n"
|
||||
|
||||
prompt += """
|
||||
|
||||
---
|
||||
|
||||
**Instructions:**
|
||||
- Create 1 slide per section (5 total).
|
||||
- Use clean, professional visuals.
|
||||
- For charts, display the specified bar chart with given data.
|
||||
- Use summary bullet points before every chart or table for clarity.
|
||||
**Do exactly as in said here.**
|
||||
"""
|
||||
|
||||
return prompt
|
||||
```
|
||||
|
||||
### f. Loop Over Each Company and Generate a Report
|
||||
|
||||
```python
|
||||
for company, group in company_groups:
|
||||
print(f"Generating report for {company}")
|
||||
prompt = build_prompt(company, group)
|
||||
data = {
|
||||
"prompt": prompt,
|
||||
"n_slides": "5",
|
||||
"language": "English",
|
||||
"theme": "light_red",
|
||||
"export_as": "pdf"
|
||||
}
|
||||
response = requests.post(
|
||||
"http://localhost:5000/api/v1/ppt/generate/presentation",
|
||||
data=data
|
||||
)
|
||||
if response.ok:
|
||||
result = response.json()
|
||||
print("Downloading report...")
|
||||
download_url = f"http://localhost:5000{result['path']}"
|
||||
filename = f"reports/{company}_Sales_Report.pdf"
|
||||
file_response = requests.get(download_url)
|
||||
if file_response.ok:
|
||||
with open(filename, 'wb') as f:
|
||||
f.write(file_response.content)
|
||||
print(f"Report for {company} saved as {filename}")
|
||||
else:
|
||||
print(f"Failed to download report for {company}: {file_response.status_code}")
|
||||
else:
|
||||
print(f"Failed to generate report for {company}: {response.text}")
|
||||
```
|
||||
|
||||
Generated reports will be saved in the `reports` directory.
|
||||
|
||||
You may change the URL `http://localhost:5000` to the URL of your Presenton instance.
|
||||
|
||||
---
|
||||
|
||||
## 4. Run the Script
|
||||
|
||||
Save your script as `generate_sales_reports.py` and run:
|
||||
|
||||
```bash
|
||||
python generate_sales_reports.py
|
||||
```
|
||||
|
||||
Each company will get a detailed, multi-slide sales report, and you’ll see the download path for each file in your terminal.
|
||||
|
||||
---
|
||||
|
||||
## 5. How It Works
|
||||
|
||||
- The script reads and groups your CSV by company.
|
||||
- It builds a well-structured markdown prompt for Presenton’s API (see [API Reference](./generate-presentation-over-api)).
|
||||
- It sends a POST request to generate a report for each company.
|
||||
- The API returns a download path for each generated PDF.
|
||||
- The file is downloaded and saved in the `reports` folder.
|
||||
|
||||
---
|
||||
|
||||
## 6. Next Steps
|
||||
|
||||
- You can further customize the prompt or number of slides as needed.
|
||||
- For more on API options, see [Generate a PPT via API in 5 Minutes](./generate-presentation-over-api).
|
||||
- For advanced configuration (for example, using Ollama or GPU), see [Environment Variables](../configurations/environment-variables), [Using GPU](../configurations/using-gpu), and [Using Ollama Models](../configurations/using-ollama-models).
|
||||
|
||||
<Info>
|
||||
Need help? See the [full documentation](./index) or open an issue on GitHub.
|
||||
</Info>
|
||||
150
docs/tutorial/generate-presentation-from-csv.mdx
Normal file
150
docs/tutorial/generate-presentation-from-csv.mdx
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
---
|
||||
title: "Create Presentations from CSV using AI"
|
||||
description: "Step-by-step guide to generating presentations from a CSV file"
|
||||
---
|
||||
|
||||
In this tutorial, we will generate personalized student report presentations using self hosted Presenton's API and a Python script.
|
||||
|
||||
This tutorial extends [Generate a PPT via API in 5 Minutes](./generate-presentation-over-api) and shows you how to automate the creation of personalized student report presentations from a CSV file using Python.
|
||||
|
||||
So, do check it before continuing with this and make sure you have Presenton running locally or any server and you are able to generate presentations with it.
|
||||
|
||||
---
|
||||
|
||||
## 1. Prepare Your CSV File
|
||||
|
||||
Save your student data as `students.csv`:
|
||||
|
||||
```csv
|
||||
Name,Final Grade,ECA Participation,Sports Involvement,Quiz Scores,Class Behavior,Comment
|
||||
Anaya Sharma,88,High,Moderate,92,Excellent,"Balanced performer with high curiosity"
|
||||
Rohan Mehta,73,Low,None,75,Good,"Needs motivation beyond academics"
|
||||
Meera Kapoor,94,Moderate,High,96,Excellent,"Academic excellence and team spirit"
|
||||
Aarav Patel,62,None,None,58,Average,"Struggling across areas, needs focused help"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. Install Python Requirements
|
||||
|
||||
You’ll need the `requests` and `pandas` libraries:
|
||||
|
||||
```bash
|
||||
pip install requests pandas
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Write the Python Script
|
||||
|
||||
Let’s build the script step by step.
|
||||
|
||||
### a. Import Libraries
|
||||
|
||||
```python
|
||||
import os
|
||||
import pandas as pd
|
||||
import requests
|
||||
```
|
||||
|
||||
### b. Creat presentations directory
|
||||
|
||||
```python
|
||||
os.makedirs('presentations', exist_ok=True)
|
||||
```
|
||||
|
||||
### c. Load the CSV
|
||||
|
||||
```python
|
||||
df = pd.read_csv("students.csv")
|
||||
```
|
||||
|
||||
### d. Define a Function to Build the Prompt
|
||||
|
||||
```python
|
||||
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."
|
||||
)
|
||||
```
|
||||
|
||||
### e. Loop Over Each Student and Generate a Presentation
|
||||
|
||||
```python
|
||||
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()
|
||||
print("Downloading presentation...")
|
||||
# Prepend the host to the path
|
||||
download_url = f"http://localhost:5000{result['path']}"
|
||||
filename = f"presentations/{result['path'].split('/')[-1]}"
|
||||
# Download and save the file
|
||||
file_response = requests.get(download_url)
|
||||
if file_response.ok:
|
||||
with open(filename, 'wb') as f:
|
||||
f.write(file_response.content)
|
||||
print(f"Presentation for {row['Name']} saved as {filename}")
|
||||
else:
|
||||
print(f"Failed to download presentation for {row['Name']}: {file_response.status_code}")
|
||||
else:
|
||||
print(f"Failed to generate presentation for {row['Name']}: {response.text}")
|
||||
```
|
||||
|
||||
Generated presentations will be saved in `presentations` directory.
|
||||
|
||||
You may change the URL `http://localhost:5000` to the URL of your Presenton instance.
|
||||
|
||||
---
|
||||
|
||||
## 4. Run the Script
|
||||
|
||||
Save your script as `generate_reports.py` and run:
|
||||
|
||||
```bash
|
||||
python generate_reports.py
|
||||
```
|
||||
|
||||
Each student will get a personalized presentation, and you’ll see the download path for each file in your terminal.
|
||||
|
||||
---
|
||||
|
||||
## 5. How It Works
|
||||
|
||||
- The script reads each row from your CSV.
|
||||
- It builds a detailed prompt for Presenton’s API (see [API Reference](./generate-presentation-over-api)).
|
||||
- It sends a POST request to generate a presentation for each student.
|
||||
- The API returns a download path for each generated PPTX.
|
||||
- The presentation file is downloaded and saved in `presentations` folder.
|
||||
|
||||
---
|
||||
|
||||
## 6. Next Steps
|
||||
|
||||
- You can customize the prompt or number of slides as needed.
|
||||
- For more on API options, see [Generate a PPT via API in 5 Minutes](./generate-presentation-over-api).
|
||||
- For advanced configuration (e.g., using Ollama or GPU), see [Environment Variables](../configurations/environment-variables), [Using GPU](../configurations/using-gpu), and [Using Ollama Models](../configurations/using-ollama-models).
|
||||
|
||||
<Info>
|
||||
Need help? See the [full documentation](./index) or open an issue on GitHub.
|
||||
</Info>
|
||||
195
docs/tutorial/generate-presentation-over-api.mdx
Normal file
195
docs/tutorial/generate-presentation-over-api.mdx
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
---
|
||||
title: "Generate Presentations via API in 5 minutes"
|
||||
description: "Steps to generate professional AI presentations via self hosted Presenton's API in just 5 minutes. "
|
||||
---
|
||||
|
||||
In this guide, I'll walk you through a simple, straightforward way to host and use Presenton’s API for generating presentations. If you're a developer or someone building tools or automation around presentations, this approach will save you some valuable time.
|
||||
|
||||
Before we start, I'm assuming you've already set up Presenton. If not, just quickly check out the [Quickstart](../quickstart) or [Development guide](../development).
|
||||
|
||||
---
|
||||
|
||||
## Step 1: Ensure Docker is Installed
|
||||
|
||||
Presenton runs in Docker, making it easy to set up across different environments.
|
||||
|
||||
- Don't have Docker yet? Just grab it from [here](https://www.docker.com/get-started).
|
||||
|
||||
---
|
||||
|
||||
## Step 2: Run Presenton Locally with Docker
|
||||
|
||||
You're now ready to run Presenton's docker image to start generating presentations. First, you will have to decide upon the LLM provider you're going to use to generate presentations. You can go for either `OPENAI`, `GOOGLE`or `OLLAMA` . `GOOGLE` is free to start with but if you want complete control and privacy `OLLAMA` allows you to host your own model, but also requires `PEXELS`(free image library) API key.
|
||||
|
||||
We will go with `GOOGLE` in this guide as it's relatively simpler to configure and free to start with. You will have to grab its API Key from [Google AI Studio](https://aistudio.google.com/apikey).
|
||||
|
||||
You can find details to run with other providers in [Environment Variables](../configurations/environment-variables).
|
||||
|
||||
Now, open your command line and execute the relevant command based on your OS:
|
||||
|
||||
### Linux/macOS:
|
||||
|
||||
```bash
|
||||
docker run -it --name presenton -p 5000:80 -e LLM="google" -e GOOGLE_API_KEY="***" -e CAN_CHANGE_KEYS="false" -v "./user_data:/app/user_data" ghcr.io/presenton/presenton:v0.3.0-beta
|
||||
```
|
||||
|
||||
### Windows (PowerShell):
|
||||
|
||||
```powershell
|
||||
docker run -it --name presenton -p 5000:80 -e LLM="google" -e GOOGLE_API_KEY="***" -e CAN_CHANGE_KEYS="false" -v "${PWD}\user_data:/app/user_data" ghcr.io/presenton/presenton:v0.3.0-beta
|
||||
```
|
||||
|
||||
> If port `5000` is already occupied or you prefer a different port, feel free to change it.
|
||||
|
||||
Once this step is done, you can access Presenton locally at http://localhost:5000.
|
||||
|
||||
---
|
||||
|
||||
## Step 3: (Optional) Configure Environment Variables
|
||||
|
||||
Presenton supports several environment variables for customization (such as using OpenAI or local models).
|
||||
|
||||
Typical use-cases you might encounter:
|
||||
|
||||
- **External APIs**: [Using OpenAI or Gemini](./configurations/environment-variables).
|
||||
- **GPU Acceleration**: [Using GPUs with Presenton](./configurations/using-gpu).
|
||||
- **Local Models**: [Using Ollama and local models](./configurations/using-ollama-models).
|
||||
|
||||
If you don't need to change anything right now, it's safe to skip this step. Return to it when you need more customization.
|
||||
|
||||
---
|
||||
|
||||
## Step 4: Understanding the API Endpoint
|
||||
|
||||
Generating presentations via Presenton's API is straightforward. It has one primary endpoint:
|
||||
|
||||
```
|
||||
POST /api/v1/ppt/generate/presentation
|
||||
```
|
||||
|
||||
For a deeper dive later, check the full [API documentation](../index).
|
||||
|
||||
---
|
||||
|
||||
## Step 5: Making your first API Call
|
||||
|
||||
Here's how you'd quickly generate a presentation called "Introduction to Machine Learning":
|
||||
|
||||
<CodeGroup>
|
||||
|
||||
```bash bash
|
||||
curl -X POST http://localhost:5000/api/v1/ppt/generate/presentation \
|
||||
-F "prompt=Introduction to Machine Learning" \
|
||||
-F "n_slides=5" \
|
||||
-F "language=English" \
|
||||
-F "theme=light" \
|
||||
-F "export_as=pptx"
|
||||
```
|
||||
|
||||
|
||||
```python python
|
||||
import requests
|
||||
|
||||
response = requests.post(
|
||||
"http://localhost:5000/api/v1/ppt/generate/presentation",
|
||||
data={
|
||||
"prompt": "Introduction to Machine Learning",
|
||||
"n_slides": "5",
|
||||
"language": "English",
|
||||
"theme": "light",
|
||||
"export_as": "pptx"
|
||||
}
|
||||
)
|
||||
|
||||
print(response.json())
|
||||
```
|
||||
|
||||
|
||||
```javascript javascript
|
||||
const axios = require("axios");
|
||||
const FormData = require("form-data");
|
||||
|
||||
const form = new FormData();
|
||||
form.append("prompt", "Introduction to Machine Learning");
|
||||
form.append("n_slides", "5");
|
||||
form.append("language", "English");
|
||||
form.append("theme", "light");
|
||||
form.append("export_as", "pptx");
|
||||
|
||||
axios.post("http://localhost:5000/api/v1/ppt/generate/presentation", form, {
|
||||
headers: form.getHeaders()
|
||||
})
|
||||
.then(res => console.log(res.data))
|
||||
.catch(err => console.error("Error:", err.response?.data || err.message));
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
---
|
||||
|
||||
## Step 6: API Request Parameters Explained
|
||||
|
||||
Here's a quick reference for the key parameters you can set:
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| ----------- | ------ | -------- | ---------------------------------------------------------- |
|
||||
| `prompt` | string | Yes | Topic/title of your presentation |
|
||||
| `n_slides` | int | No | Number of slides (default: 8; min: 5, max: 15) |
|
||||
| `language` | string | No | Language you'd like the presentation in (default: English) |
|
||||
| `theme` | string | No | Optional styling (e.g.: "light", "dark", "royal_blue") |
|
||||
| `documents` | file[] | No | Additional supporting documents (PDF/PPTX/DOCX/TXT) |
|
||||
| `export_as` | string | No | "pptx" or "pdf" (default: pptx) |
|
||||
|
||||
Yes, it can generate presentations directly from most popular file formats. Make sure you understand the context window of model you're using with respect to file size.
|
||||
|
||||
For now, these should be enough to get you going. Later, you can reference the [API docs](../index) if needed.
|
||||
|
||||
---
|
||||
|
||||
## Step 7: API Response in Practice
|
||||
|
||||
Here's what a normal, successful response looks like:
|
||||
|
||||
```json
|
||||
{
|
||||
"presentation_id": "d3000f96-096c-4768-b67b-e99aed029b57",
|
||||
"path": "/static/user_data/d3000f96-096c-4768-b67b-e99aed029b57/Introduction_to_Machine_Learning.pptx",
|
||||
"edit_path": "/presentation?id=d3000f96-096c-4768-b67b-e99aed029b57"
|
||||
}
|
||||
```
|
||||
|
||||
- **`presentation_id`**: Keep this handy if you want to refer back later.
|
||||
- **`path`**: This is your generated PPT file. Download from here.
|
||||
- `edit_path`: A convenient URL that lets you edit your slides directly from Presenton’s built-in editor.
|
||||
|
||||
> Note: Make sure to prepend your server's root URL to the path and edit_path fields in the response to construct valid links.
|
||||
|
||||
---
|
||||
|
||||
## Step 8: Built-in Presentation Themes
|
||||
|
||||
Presenton provides easy-to-use themes for quick styling:
|
||||
|
||||
- `light` (default, clean/professional look)
|
||||
- `dark` (ideal for coding tutorials or tech seminars)
|
||||
- `cream` (suitable for detailed reviews, proposals)
|
||||
- `royal_blue` (great for presenting to clients or external stakeholders)
|
||||
- `faint_yellow` (easy on eyes, educational slides)
|
||||
- `light_red` (highlight warnings or critical presentations)
|
||||
- `dark_pink` (marketing, creative slide decks)
|
||||
|
||||
---
|
||||
|
||||
## Step 9 (Optional): Advanced Customization
|
||||
|
||||
Once you're comfortable and ready for more:
|
||||
|
||||
- Integrate your preferred LLMS: [Environment Variables](../configurations/environment-variables).
|
||||
- Leverage GPU performance: [GPU Guide](../configurations/using-gpu).
|
||||
- Run local AI models with Ollama: [Local Models](../configurations/using-ollama-models).
|
||||
|
||||
---
|
||||
|
||||
**That's it\!** You've successfully generated a professional-looking presentation through an easy-to-use API endpoint.
|
||||
|
||||
If you have more questions or want to explore further, the [complete documentation](../index) is always here to help you.
|
||||
106
docs/using-presenton-api.mdx
Normal file
106
docs/using-presenton-api.mdx
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
---
|
||||
title: "Using Presenton API"
|
||||
description: "You can use Presenton’s API to generate presentations programmatically. This is great for integrating Presenton into your own apps or workflows."
|
||||
---
|
||||
|
||||
### 🎯 Endpoint
|
||||
|
||||
```
|
||||
POST /api/v1/ppt/generate/presentation
|
||||
```
|
||||
|
||||
Use this endpoint to generate a presentation from a prompt, outline, or uploaded documents.
|
||||
|
||||
### 🧾 Request Format
|
||||
|
||||
**Content-Type:** `multipart/form-data`
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
| ----------- | -------- | -------- | --------------------------------------------------------------------- |
|
||||
| `prompt` | `string` | Yes | The main topic or subject for the presentation |
|
||||
| `n_slides` | `int` | No | Number of slides (default: 8, min: 5, max: 15) |
|
||||
| `language` | `string` | No | Language of the presentation (default: `English`) |
|
||||
| `theme` | `string` | No | Theme of the presentation (e.g., `light`, `dark`, `royal_blue`, etc.) |
|
||||
| `documents` | `file[]` | No | Optional files (PDF, PPTX, DOCX, TXT) to include |
|
||||
| `export_as` | `string` | No | Export format: `pptx` or `pdf` (default: `pptx`) |
|
||||
|
||||
### 📤 Example Request
|
||||
|
||||
<CodeGroup>
|
||||
|
||||
```bash bash
|
||||
curl -X POST http://localhost:5000/api/v1/ppt/generate/presentation \
|
||||
-F "prompt=Introduction to Machine Learning" \
|
||||
-F "n_slides=5" \
|
||||
-F "language=English" \
|
||||
-F "theme=light" \
|
||||
-F "export_as=pptx"
|
||||
```
|
||||
|
||||
|
||||
```python python
|
||||
import requests
|
||||
|
||||
url = "http://localhost:5000/api/v1/ppt/generate/presentation"
|
||||
data = {
|
||||
"prompt": "Introduction to Machine Learning",
|
||||
"n_slides": "5",
|
||||
"language": "English",
|
||||
"theme": "light",
|
||||
"export_as": "pptx"
|
||||
}
|
||||
|
||||
response = requests.post(url, data=data)
|
||||
print(response.json())
|
||||
```
|
||||
|
||||
|
||||
```javascript javascript
|
||||
const axios = require("axios");
|
||||
const FormData = require("form-data");
|
||||
|
||||
const form = new FormData();
|
||||
form.append("prompt", "Introduction to Machine Learning");
|
||||
form.append("n_slides", "5");
|
||||
form.append("language", "English");
|
||||
form.append("theme", "light");
|
||||
form.append("export_as", "pptx");
|
||||
|
||||
axios.post("http://localhost:5000/api/v1/ppt/generate/presentation", form, {
|
||||
headers: form.getHeaders()
|
||||
})
|
||||
.then(response => {
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error("Error:", error.response?.data || error.message);
|
||||
});
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
### 📥 Example Response
|
||||
|
||||
```json
|
||||
{
|
||||
"presentation_id": "d3000f96-096c-4768-b67b-e99aed029b57",
|
||||
"path": "/static/user_data/d3000f96-096c-4768-b67b-e99aed029b57/Introduction_to_Machine_Learning.pptx",
|
||||
"edit_path": "/presentation?id=d3000f96-096c-4768-b67b-e99aed029b57"
|
||||
}
|
||||
```
|
||||
|
||||
- `presentation_id`: Unique ID of the presentation
|
||||
- `path`: File path for downloading the presentation
|
||||
- `edit_path`: Link to open the presentation in the editor
|
||||
|
||||
---
|
||||
|
||||
### ✅ Supported Themes
|
||||
|
||||
- `light` (default)
|
||||
- `dark`
|
||||
- `cream`
|
||||
- `royal_blue`
|
||||
- `faint_yellow`
|
||||
- `light_red`
|
||||
- `dark_pink`
|
||||
Loading…
Add table
Reference in a new issue