CoolFace
Apppublic

Aryan2301/YouTube_RAG_Intelligence

sourceHugging Faceupdated 8h agoView on Hugging Face
0likes
App README

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 .txt or .md

Tech Stack

LayerTechnology
LLMopenai/gpt-oss-120b (via Groq API)
OrchestrationLangGraph & LangChain
EmbeddingsGoogle Gemini-embedding-2
Vector StoreHybrid ChromaDB + BM25
TranscriptsSupadata API
UIStreamlit
RuntimePython 3.11

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.py

Local Setup

1. Clone

bash
git clone https://github.com/Aryanupadhyay23/Youtube-RAG-Intelligence.git
cd Youtube-RAG-Intelligence

2. Create Virtual Environment

bash
python -m venv venv

# Linux / Mac
source venv/bin/activate

# Windows
venv\Scripts\activate

3. Install Dependencies

bash
pip install -r requirements.txt

4. Create .env

Create a .env file in the root of the project:

env
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_here
Never commit .env to 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):

bash
fastapi dev api.py
# OR
uvicorn api:app --reload --port 8000

Terminal 2 (Frontend UI):

bash
streamlit run app.py

Open http://localhost:8501 in your browser.


HuggingFace Spaces Deployment

Step 1 - Create a New Space

  1. 1.Go to https://huggingface.co/new-space
  2. 2.Fill in:
  3. 3.Space name: youtube-rag-intelligence (or your choice)
  4. 4.License: MIT
  5. 5.SDK: Docker <-- important, NOT Streamlit SDK
  6. 6.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:

Secret NameRequiredWhere to Get It
GROQ_API_KEYRequiredhttps://console.groq.com
SUPADATA_KEY_1Requiredhttps://supadata.ai
SUPADATA_KEY_2OptionalFallback if key 1 hits rate limit
SUPADATA_KEY_3OptionalFallback if key 2 hits rate limit
SUPADATA_KEY_4OptionalFallback if key 3 hits rate limit
GOOGLE_API_KEYRequiredhttps://aistudio.google.com
TAVILY_API_KEYOptionalhttps://tavily.com

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-wal

Required 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:

  1. 1.Open the Space URL
  2. 2.Check the sidebar - it shows:
  3. 3."Running on HuggingFace Spaces"
  4. 4."GROQAPIKEY loaded"
  5. 5."SUPADATA_KEY (N keys loaded)"
  6. 6.If any key shows missing, go back to Settings -> Secrets and verify the name matches exactly

Environment Variables Reference

VariableLocal (.env)HuggingFace (Secrets)Required
GROQ_API_KEYYesYesRequired
SUPADATA_KEY_1YesYesRequired
SUPADATA_KEY_2YesYesOptional
SUPADATA_KEY_3YesYesOptional
SUPADATA_KEY_4YesYesOptional
GOOGLE_API_KEYYesYesRequired
TAVILY_API_KEYYesYesOptional

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 cases

Common Errors

ErrorCauseFix
GROQ_API_KEY is not setSecret not added or wrong nameSettings -> Secrets, check key is named exactly GROQ_API_KEY
No Supadata API keys configuredSUPADATA_KEY_1 missingAdd it in Settings -> Secrets
Space failed to buildDependency version conflictCheck requirements.txt versions are pinned exactly
Empty transcript returnedVideo has no captionsTry a video with auto-generated or manual captions enabled
Invalid YouTube URLWrong URL formatUse https://youtube.com/watch?v=VIDEO_ID format

License

MIT License