This is a YouTube Q&A Chatbot powered by a Large Language Model (LLM) and FastAPI.
Users can enter a YouTube video URL and ask questions — the system generates accurate answers using the video transcript.
- Ask questions about any YouTube video.
- Extracts video transcript automatically.
- Generates answers using an LLM (Hugging Face API or other supported models).
- Clean and responsive UI similar to ChatGPT:
- Fixed input box at the bottom
- Scrollable chat messages
- Enter key or send button to submit queries
- Frontend built with HTML, CSS, and JavaScript
- Backend built with FastAPI and Python
- CORS enabled for frontend-backend communication
youtube-transcript-rag/ │ ├─ frontend/ │ ├─ index.html # Chatbot UI │ ├─ style.css # Stylesheet │ └─ script.js # JS logic │ ├─ utils/ │ ├─ youtube_utils.py # Functions to extract video ID & transcript │ └─ qa_pipeline.py # Functions to generate answers from transcript │ ├─ model/ │ └─ Youtube_RAG_System.ipynb # Notebook for initial experimentation │ ├─ main.py # FastAPI backend ├─ requirements.txt # Python dependencies └─ .env # Hugging Face API token (local only, not pushed)
- User enters a YouTube URL and their question in the chatbot UI.
- Frontend sends a POST request to the FastAPI backend at
/youtube_qa. - Backend uses
youtube_utils.pyto:- Extract the video ID from the URL
- Fetch the transcript of the video
- The transcript and user query are sent to
qa_pipeline.pywhich:- Uses an LLM to generate a relevant answer
- Backend returns the answer as JSON
- Frontend displays the user question and bot answer in the chat window.
git clone https://github.com/aliahmad552/youtube-transcript-rag.git
cd youtube-transcript-ragpython -m venv myenv
myenv\Scripts\activate # Windowspip install -r requirements.txtHUGGINGFACEHUB_API_TOKEN=hf_your_token_hereuvicorn main:app --reloadOpen the chatbot UI
Paste a YouTube video URL
Type your question
Press Enter or click the send icon
Chatbot generates answer in real-time
Do NOT commit .env or API tokens to GitHub.
Add .env to .gitignore to avoid accidental exposure.
Python 3.10+
FastAPI
JavaScript, HTML, CSS
Hugging Face LLM APIs
YouTube Transcript API
Chatbot UI inspired by ChatGPT ##📌 Future Improvements
Dark mode UI
Multi-language support
Save conversation history
Deploy as a full web application
Support for multiple LLM providers
Ali Ahmad – BS Software Engineering

