metadata
title: Video Rag
emoji: π₯
colorFrom: blue
colorTo: indigo
sdk: docker
app_port: 7860
pinned: false
Video RAG System Project
This FastAPI-based Video RAG (Retrieval-Augmented Generation) system provides endpoints to:
- Register & Authenticate users
- Transcribe YouTube or uploaded videos
- Query the RAG system
- Manage sessions (list, view, delete)
Endpoint Flow
graph TD
A[POST /register] --> B[POST /token]
B --> C[POST /transcribe]
B --> D[POST /upload]
C --> E[Start RAG session]
D --> E
E --> F[POST /query]
E --> G[GET /sessions]
G --> H[GET /sessions/{session_id}]
H --> F
G --> I[DELETE /sessions/{session_id}]
User Registration & Login
- POST /register: Create a new user.
- POST /token: Obtain JWT access token.
Video Transcription
- POST /transcribe (YouTube URL): Transcribe via Google GenAI β split & store chunks β initialize chat history β return
session_id. - POST /upload (Multipart Form Video): Upload & transcribe file β split & store chunks β initialize chat history β return
session_id.
- POST /transcribe (YouTube URL): Transcribe via Google GenAI β split & store chunks β initialize chat history β return
Query RAG System
- POST /query with
{ session_id, query }:
β’ Rebuild FAISS retriever from MongoDB chunks
β’ Invoke ConversationalRetrievalChain
β’ Append messages to chat history
β’ Return{ answer, session_id, source_documents }
- POST /query with
Session Management
- GET /sessions: List all sessions for current user.
- GET /sessions/{session_id}: Get full transcription & Q&A history.
- DELETE /sessions/{session_id}: Remove metadata, chunks, chat history, and video files.
README.md
# Video RAG System
## Overview
A FastAPI application that:
- Authenticates users (JWT)
- Transcribes videos (YouTube or upload) via Google GenAI
- Stores transcription chunks in MongoDB
- Builds a FAISS retriever on demand
- Provides a conversational retrieval endpoint
- Manages sessions and associated data
## API Endpoints
| Method | Path | Auth Required | Description |
|--------|----------------------------|---------------|-----------------------------------------------|
| POST | /register | No | Create a new user |
| POST | /token | No | Login and return JWT token |
| POST | /transcribe | Yes | Transcribe YouTube video and init session |
| POST | /upload | Yes | Upload & transcribe video file |
| POST | /query | Yes | Run Q&A against a session |
| GET | /sessions | Yes | List all user sessions |
| GET | /sessions/{session_id} | Yes | Get session transcription & chat history |
| DELETE | /sessions/{session_id} | Yes | Delete session & all associated data |
## Usage
1. Clone repo & install dependencies:
```bash
pip install -r requirements.txt
- Create
.envwith your credentials (MongoDB, JWT secret, API keys). - Run the app:
uvicorn app.main:app --reload - Interact via HTTP clients (curl, Postman) following the flow above.
Folder Structure
rag_system/
βββ app/
β βββ main.py
β βββ config.py
β βββ dependencies.py
β βββ models/
β βββ db/
β βββ services/
β βββ routes/
β βββ utils/
βββ temp_videos/
βββ .env
βββ requirements.txt
βββ README.md