Aryan2301/YouTube_RAG_Intelligence
YouTube RAG Intelligence
An AI-powered YouTube video assistant built with LangGraph, LangChain, openai/gpt-oss-120b, Google Gemini embeddings, LangChain native EnsembleRetriever, and ChromaDB. Chat with any video, generate summaries, and explore transcripts.
Transcripts in any language are automatically answered in English.
Live Demo
YouTube RAG Intelligence on HuggingFace
Features
- Corrective RAG Chat - Ask questions grounded strictly in transcript context with hybrid search (BM25 + Semantic), RRF fusion, and web fallback.
- Smart Summary - Map-reduce summarisation for any video length
- Transcript Explorer - Search keywords and jump to YouTube timestamps
- Multi-language - Transcripts in any language; responses always in English
- Multi-chat - Create, switch, and delete multiple chat sessions
- Export - Download chat history and summaries as
.txtor.md
Tech Stack
Project Structure
app.py <- Streamlit entry point
config.py <- API keys + environment detection
requirements.txt
Dockerfile
assets/
styles.css
core/
__init__.py
chunking.py
embeddings.py
graph.py
llm.py
prompts/
retrieval.py
summary.py
vectorstore.py
exports/
__init__.py
export_chat.py
export_summary.py
services/
__init__.py
chat_service.py
transcript_service.py
web_search_service.py
youtube_service.py
ui/
__init__.py
chat_ui.py
landing.py
sidebar.py
summary_ui.py
transcript_ui.py
utils/
__init__.py
constants.py
formatting.py
helpers.py
session.py
timestamp.pyLocal Setup
1. Clone
git clone https://github.com/Aryanupadhyay23/Youtube-RAG-Intelligence.git
cd Youtube-RAG-Intelligence2. Create Virtual Environment
python -m venv venv
# Linux / Mac
source venv/bin/activate
# Windows
venv\Scripts\activate3. Install Dependencies
pip install -r requirements.txt4. Create .env
Create a .env file in the root of the project:
GROQ_API_KEY=your_groq_api_key_here
SUPADATA_KEY_1=your_supadata_key_here
SUPADATA_KEY_2=your_second_supadata_key_here
SUPADATA_KEY_3=your_third_supadata_key_here
SUPADATA_KEY_4=your_fourth_supadata_key_here
GOOGLE_API_KEY=your_google_api_key_here
TAVILY_API_KEY=your_tavily_api_key_hereNever commit.envto git. It is already listed in.gitignore.
5. Run the Application
The application consists of a FastAPI backend and a Streamlit frontend. You need to run both for the application to work correctly.
Terminal 1 (Backend API):
fastapi dev api.py
# OR
uvicorn api:app --reload --port 8000Terminal 2 (Frontend UI):
streamlit run app.pyOpen http://localhost:8501 in your browser.
HuggingFace Spaces Deployment
Step 1 - Create a New Space
- Go to https://huggingface.co/new-space
- Fill in:
- Space name:
youtube-rag-intelligence(or your choice) - License:
MIT - SDK:
Docker<-- important, NOT Streamlit SDK - Visibility: Public or Private
Step 2 - Add Secrets
Do NOT put API keys in code or README. Use HuggingFace Secrets only.
Go to your Space -> Settings -> Variables and Secrets -> New Secret
Add each of the following:
Secrets are injected into os.environ automatically before the app starts. The app detects HuggingFace via the SPACE_ID env variable and skips .env loading entirely.
Step 3 - Upload Project Files
Upload all files and folders EXCEPT:
.env
venv/
__pycache__/
*.pyc
*.pyo
.DS_Store
*.sqlite
*.sqlite3
*.sqlite-shm
*.sqlite-walRequired files to upload:
app.py
config.py
requirements.txt
Dockerfile
README.md
assets/
core/
exports/
services/
ui/
utils/Step 4 - Verify Deployment
Once the Space builds and starts:
- Open the Space URL
- Check the sidebar - it shows:
- "Running on HuggingFace Spaces"
- "GROQAPIKEY loaded"
- "SUPADATA_KEY (N keys loaded)"
- If any key shows missing, go back to Settings -> Secrets and verify the name matches exactly
Environment Variables Reference
How Environment Detection Works
App starts
|
|-- SPACE_ID in os.environ?
| |
| |-- YES -> HuggingFace Spaces
| | Secrets already in os.environ
| | load_dotenv() is skipped
| |
| |-- NO -> Local machine
| load_dotenv() reads .env file
| Keys loaded into os.environ
|
|-- os.environ.get("GROQ_API_KEY") works the same in both casesCommon Errors
License
MIT License
