Skip to content

Muhammad-Talha4k/Youtube-Chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

20 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฌ YouTube Transcript Chatbot

An intelligent multilingual chatbot that enables natural conversations with YouTube videos in 50+ languages using RAG (Retrieval Augmented Generation).

Streamlit Python Docker LangChain

๐Ÿ“‹ Table of Contents

๐ŸŒŸ Overview

YouTube Transcript Chatbot is an AI-powered application that allows users to have natural language conversations with YouTube videos. The system extracts video transcripts, processes them using advanced NLP techniques, and enables semantic search and question-answering in multiple languages.

๐Ÿ“ Project Structure

youtube-chatbot/
โ”œโ”€โ”€ app.py                      # Main application file
โ”œโ”€โ”€ requirements.txt            # Python dependencies
โ”œโ”€โ”€ .gitignore                 # Git ignore rules
โ”‚
โ”œโ”€โ”€ docker/
โ”‚   โ”œโ”€โ”€ Dockerfile             # Docker container configuration
โ”‚   โ””โ”€โ”€ .dockerignore          # Docker ignore rules
โ””โ”€โ”€ README.md                  # Readme file

Key Highlights

  • ๐ŸŒ Multilingual Support: Works seamlessly with videos in English, Hindi, Urdu, Arabic, Spanish, and 50+ other languages
  • ๐Ÿš€ No Translation Required: Uses original transcripts for maximum accuracy and preserves cultural context
  • ๐Ÿ’ฌ Natural Conversations: Powered by state-of-the-art LLMs from OpenRouter
  • ๐ŸŽฏ Smart Retrieval: Employs RAG with vector embeddings for precise context retrieval
  • โšก Fast & Efficient: Cloud-based embeddings with no local model downloads

โœจ Features

Core Functionality

  • ๐Ÿ“บ YouTube Integration: Automatic transcript extraction from any YouTube video
  • ๐Ÿ” Semantic Search: Intelligent context retrieval using vector similarity
  • ๐Ÿ’ก Conversational AI: Natural dialogue with multiple LLM options
  • ๐ŸŒ Cross-lingual Queries: Ask questions in any language, get relevant answers

Technical Features

  • ๐ŸŽฏ RAG Architecture: Retrieval Augmented Generation for accurate responses
  • ๐Ÿ”„ Streaming Responses: Real-time token streaming for better UX
  • ๐Ÿ” Automatic Retry Logic: Handles API rate limits and timeouts gracefully
  • ๐Ÿ“Š Vector Database: Persistent storage with Qdrant Cloud
  • ๐Ÿง  Multiple LLM Support: Choose from Mistral & LLaMA
# Quick start
streamlit run app.py

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Youtube Video URL  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Transcript Extractorโ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Text Splitter     โ”‚ (600 char chunks)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  HuggingFace API    โ”‚ (Multilingual Embeddings)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Qdrant Vector DB  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ–ผ
    User Query
         โ”‚
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Semantic Search    โ”‚ (MMR Retrieval)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  OpenRouter LLM     โ”‚ (Generate Response)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ–ผ
    Streamed Answer

๐Ÿ› ๏ธ Tech Stack

Frontend

  • Streamlit - Interactive web application framework

Backend & AI

  • LangChain - LLM orchestration framework
  • OpenRouter - Unified LLM API gateway
  • HuggingFace - Multilingual embeddings API
  • Qdrant - Vector database for Maximal Marginal Relevance Retrieval (MMR)

Core Libraries

  • youtube-transcript-api - YouTube transcript extraction
  • sentence-transformers - Multilingual embeddings model
  • langchain-openai - OpenRouter integration
  • langchain-qdrant - Qdrant vector store integration

๐Ÿ“ฆ Prerequisites

  • Python 3.10 or higher
  • pip or conda package manager
  • API keys (see Configuration Options)

๐Ÿš€ Installation

Method 1: Local Installation

# Clone the repository
git clone https://github.com/yourusername/youtube-chatbot.git
cd youtube-chatbot

# Create virtual environment
python -m venv venv

# Activate virtual environment
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Create .env file
cp .env.example .env
# Edit .env with your API keys

# Run the application
streamlit run app.py

Method 2: Docker

# Build the image
docker build -t youtube-chatbot .

# Run the container
docker run -d \
  --name yt-chatbot \
  -p 8501:8501 \
  --env-file .env \
  youtube-chatbot

โš™๏ธ Configuration

Create a .env file in the root directory:

# OpenRouter API Key (for LLM generation)
OPENROUTER_API_KEY=sk-or-v1-xxxxx

# Qdrant Cloud Configuration
QDRANT_URL=https://xxxxx.qdrant.io
QDRANT_API_KEY=xxxxx

# HuggingFace API Key (for embeddings)
HUGGINGFACE_API_KEY=hf_xxxxx

Configuration Options

Variable Description Required
OPENROUTER_API_KEY API key for LLM access โœ… Yes
QDRANT_URL Qdrant cluster URL โœ… Yes
QDRANT_API_KEY Qdrant authentication key โœ… Yes
HUGGINGFACE_API_KEY HuggingFace API token โœ… Yes

๐Ÿ“– Usage

Basic Workflow

  1. Start the Application

    streamlit run app.py
  2. Ingest a Video

    • Paste a YouTube URL in the sidebar
    • Click "๐Ÿ“ฅ Ingest Transcript"
    • Wait for processing (10-30 seconds)
  3. Start Chatting

    • Type your question in the chat input
    • Receive AI-generated answers based on video content
    • Continue the conversation naturally

Supported Video Languages

The chatbot supports transcripts in:

  • ๐Ÿ‡ฌ๐Ÿ‡ง English
  • ๐Ÿ‡ฎ๐Ÿ‡ณ Hindi
  • ๐Ÿ‡ต๐Ÿ‡ฐ Urdu
  • ๐Ÿ‡ธ๐Ÿ‡ฆ Arabic
  • ๐Ÿ‡ช๐Ÿ‡ธ Spanish
  • ๐Ÿ‡ซ๐Ÿ‡ท French
  • ๐Ÿ‡ฉ๐Ÿ‡ช German
  • ๐Ÿ‡ฏ๐Ÿ‡ต Japanese
  • ๐Ÿ‡ฐ๐Ÿ‡ท Korean
  • ๐Ÿ‡จ๐Ÿ‡ณ Chinese
  • And 50+ more languages!

Available LLM Models

Choose from multiple AI models:

Model Provider Strengths
LLaMA 3.2 3B Meta Fast, efficient
Mistral Small Mistral AI Balanced performance

๐Ÿค Contributing

Contributions are welcome! Here's how you can help:

Ways to Contribute

  • ๐Ÿ› Report Bugs: Open an issue describing the problem
  • ๐Ÿ’ก Suggest Features: Share your ideas for improvements
  • ๐Ÿ“ Improve Documentation: Help make docs clearer
  • ๐Ÿ”ง Submit Pull Requests: Fix bugs or add features

Development Setup

# Fork and clone the repository
git clone https://github.com/yourusername/youtube-chatbot.git

# Create a feature branch
git checkout -b feature/amazing-feature

# Make your changes and commit
git commit -m "Add amazing feature"

# Push to your fork
git push origin feature/amazing-feature

# Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License.

๐Ÿ™ Acknowledgments

Technologies

๐Ÿ“ž Support

Built with โค๏ธ by Muhammad Talha

โญ Star this repo if you find it helpful!

About

An intelligent multilingual chatbot that enables natural conversations with YouTube videos in 50+ languages using RAG

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors