Skip to content

Anay-jo/SlidesAgent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Presentation Generator By Group 28 (Anay Joshi, Stephen He, Joshua Chen, Lorry Luo)

Overview

AI Presentation Generator is a chatbot that builds Google Slides from natural language. A LangChain / DeepAgents backend uses OpenAI (gpt-4o-mini) for reasoning, Tavily for web search and image URLs, and the Google Slides and Drive APIs to edit decks. Chat history and sessions live in Supabase. The UI is React (Vite) and talks to a FastAPI backend.


What you need to run the stack

Credential / service Purpose
OpenAI API key LLM for the slide agent
Tavily API key TavilySearchResults tool (facts + image URLs)
Google Cloud OAuth (Desktop client) User OAuth for Slides + Drive (path to client JSON via env)
Supabase SUPABASE_URL + SUPABASE_KEY for messages/sessions

Optional: GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET / GOOGLE_REDIRECT_URI only if you use the separate web OAuth routes under backend/googleauth/ (not required for the main chat + SlideAgent flow).


Prerequisites

  • Python 3.12+ (CI uses 3.12)
  • Node.js and npm
  • Git

0. Clone the repo

git clone https://github.com/Anay-jo/SlidesAgent.git
cd Team-26.028

1. OpenAI API key

  1. Sign in at the OpenAI Platform.
  2. Go to API keys and create a new secret key.
  3. Add billing / credits if your account requires it.

Add to backend/.env:

OPEN_AI_API_KEY=sk-...

The backend reads OPEN_AI_API_KEY (with underscores as shown)—see backend/agents/slide_agent.py.


2. Tavily API key

  1. Create an account at Tavily.
  2. Open the developer/API dashboard and create an API key.

The Tavily client used by LangChain expects:

TAVILY_API_KEY=tvly-...

3. Google credentials (Slides + Drive)

The chat endpoint loads user OAuth credentials with the Desktop app flow (InstalledAppFlow in backend/api/v1/users.py). You do not paste a bare “client id” string for that path; you download Google’s OAuth client JSON, which contains client_id and client_secret inside the file.

3.1 Google Cloud Console

  1. Open Google Cloud Console and select or create a project.
  2. Enable Google Slides API and Google Drive API for that project.
  3. Open APIs & Services → OAuth consent screen, configure it (External or Internal as appropriate), and add these scopes:
    • https://www.googleapis.com/auth/presentations
    • https://www.googleapis.com/auth/drive.file

3.2 Create a Desktop OAuth client and download JSON

  1. Go to APIs & Services → Credentials.
  2. Create credentials → OAuth client ID.
  3. Application type: Desktop app.
  4. Create, then download the JSON (often named like client_secret_….json).

Put the downloaded file in backend/secrets/ (create the folder if it doesn't exist — it's gitignored), then point to it in backend/.env:

GOOGLE_OAUTH_CREDENTIAL=secrets/client_secret_....json

Optional: where to store the refreshed user token (default shown below):

GOOGLE_OAUTH_TOKEN_PATH=secrets/google_oauth_token.json

Path gotcha: both of these are resolved as plain relative paths (via Python's open()), relative to whatever directory you actually launch the server from — not relative to backend/.env or to the source file that reads them. As long as you always start the server with cd backend first (see Run locally), secrets/... resolves correctly. If you ever run uvicorn/python main.py from a different working directory, use an absolute path instead.

The first time the backend needs Google access, a browser window opens for consent; after that, the token file is reused and refreshed when possible. If you ever see a RefreshError: invalid_grant, the cached token has expired or was tied to an old/rotated OAuth client — delete backend/secrets/google_oauth_token.json and retry to re-run the consent flow.

3.3 Optional: fixed Drive folder for new decks

GOOGLE_SLIDES_PARENT_FOLDER_ID=your_drive_folder_id

3.4 Web OAuth (GOOGLE_CLIENT_ID / secret / redirect)

If you use backend/googleauth/’s web callback flow, create a Web application OAuth client in the same Google project and set:

GOOGLE_CLIENT_ID=your_client_id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=...
GOOGLE_REDIRECT_URI=http://localhost:8000/auth/google

These are separate from the Desktop JSON used by GOOGLE_OAUTH_CREDENTIAL for the slide agent.


4. Supabase

  1. Create a project at Supabase.
  2. Under Project Settings → API, copy the Project URL and a secret key (often the service_role key for a trusted local backend).
SUPABASE_URL=https://xxxx.supabase.co
SUPABASE_KEY=your_supabase_secret_key

The code in backend/db/client.py expects tables including sessions, messages, and memory compatible with that client (UUID session_id, message rows with role / content, etc.). Align RLS and keys with your team schema.


5. Backend .env template

Create backend/.env (gitignored):

# OpenAI (required)
OPEN_AI_API_KEY=sk-...

# Tavily (required for search tool)
TAVILY_API_KEY=tvly-...

# Supabase (required)
SUPABASE_URL=https://xxxx.supabase.co
SUPABASE_KEY=your_supabase_secret_key

# Google — Desktop OAuth JSON path (required for slide generation)
GOOGLE_OAUTH_CREDENTIAL=/absolute/path/to/client_secret_....json
# GOOGLE_OAUTH_TOKEN_PATH=secrets/google_oauth_token.json
# GOOGLE_SLIDES_PARENT_FOLDER_ID=

# Optional — web OAuth only (googleauth routes)
# GOOGLE_CLIENT_ID=
# GOOGLE_CLIENT_SECRET=
# GOOGLE_REDIRECT_URI=http://localhost:8000/auth/google

Running tests locally / CI

Pytest uses a separate Supabase test project when configured:

TEST_SUPABASE_URL=https://yyyy.supabase.co
TEST_SUPABASE_KEY=your_test_key

RESPAN_API_KEY appears in .github/workflows/ci.yml secrets but is not read by application code; omit locally unless you add usage.


6. Run locally

Backend

cd backend
python3 -m venv venv && source venv/bin/activate   # or use conda / your preferred env manager
pip install -r requirements.txt
python main.py

API default: http://localhost:8000 (see backend/main.py). Always launch this from inside backend/ — the code uses flat imports (from db.client import ..., from agents.slide_agent import ...) that only resolve correctly when backend/ itself is the working directory.

Frontend

cd frontend
npm install
npm run dev

Use the URL Vite prints (usually http://localhost:5173). The chat UI calls:

  • POST http://localhost:8000/api/v1/users/request
  • GET http://localhost:8000/api/v1/messages/history?session_id=...

CORS gotcha: backend/main.py hardcodes allow_origins=["http://localhost:5173"]. If another project's Vite dev server is already running on your machine and occupying port 5173, Vite will silently bump this frontend to the next free port (5174, 5175, ...) — the browser tab will still load, but every API request will fail preflight with a 400 Bad Request ("Disallowed CORS origin"), since the actual origin no longer matches. Check the port Vite printed in your terminal matches 5173, or update allow_origins in backend/main.py to match whatever port you're actually on.

Running tests

cd backend
pytest

backend/conftest.py adds backend/ to sys.path so the flat imports resolve the same way they do at runtime.


7. Using the app

  1. Start backend and frontend.
  2. Complete Google consent when the local OAuth flow opens (first run).
  3. Ask for a deck (topic, audience, slide count, style). The assistant reply should include presentation details and a link when generation finishes.

Features

  • Chat UI with session history
  • Agent-driven Slides generation with Tavily-backed research
  • Supabase-backed persistence
  • Full-stack layout for demos and coursework

About

SlidesAgent project

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages