CoolFace
Apppublic

vikramvasudevan/youtube-channel-surfer-ai

sourceHugging Facemitupdated 11mo agoView on Hugging Face
2likes
App README

๐Ÿ“บ YouTube Metadata Q&A Agent

This application allows you to index YouTube channels and ask natural language questions about the videos. It leverages OpenAI embeddings and GPT-4o-mini to provide insightful answers based on video metadata (titles + descriptions), and it displays top relevant videos in a clean, interactive table.


Features

  • โ€”Index YouTube Channels: Provide one or more YouTube channel URLs to index video metadata.
  • โ€”Search & Answer Questions: Ask questions about channel content and get answers generated by an LLM.
  • โ€”Top Video Results: View top relevant videos in a structured HTML table with clickable links.
  • โ€”Embedded Video Player: Watch videos directly in the app using YouTube embeds.
  • โ€”Refresh Channels: Update previously indexed channels to include the latest videos.
  • โ€”Lightweight Storage: Uses a local ChromaDB persistent database to store video embeddings for fast retrieval.
  • โ€”Structured LLM Output: LLM returns structured LLMAnswer objects with textual answer + top videos for clean rendering.

How it Works

  1. 1.Channel Indexing:
  2. 2.The app fetches the latest videos from provided YouTube channels using the YouTube Data API.
  3. 3.Video metadata (title, description, channel, video ID) is embedded with OpenAI embeddings and stored in ChromaDB.
  1. 1.Query & Retrieval:
  2. 2.User queries are embedded and compared with stored video embeddings.
  3. 3.Top matching videos are retrieved.
  1. 1.Answer Generation:
  2. 2.The LLM generates an answer based on the top video metadata.
  3. 3.The answer and top videos are returned as structured data (LLMAnswer).
  1. 1.Rendering:
  2. 2.Answer text is displayed in Markdown.
  3. 3.Top videos are displayed in a structured HTML table with clickable links and embedded YouTube players.

Installation

Steps to Run

  1. 1.Clone the repository:

git clone <repourl> cd youtubesurferaiagent

  1. 1.Create and activate a virtual environment:
  • โ€”Linux/macOS:

python -m venv .venv source .venv/bin/activate

  • โ€”Windows:

python -m venv .venv .venv\Scripts\activate

  1. 1.Install dependencies:

pip install -r requirements.txt

  1. 1.Create a `.env` file in the project root with your API keys:

YOUTUBEAPIKEY=youryoutubeapikey OPENAIAPIKEY=youropenaiapikey

  1. 1.Run the application:

python app.py

  1. 1.Open the Gradio interface in your browser (default: http://127.0.0.1:7860).

How to Use

  • โ€”Index Channels: Paste one or more YouTube channel URLs (comma or newline separated) and click "Index Channels".
  • โ€”Refresh Channels: Use the sidebar "Refresh All Channels" button to update existing channels.
  • โ€”Ask Questions: Type a query in the text box and click "Get Answer" to receive a structured response with embedded videos.
  • โ€”View Indexed Channels: The sidebar lists all channels that have been indexed with clickable links.

Notes

  • โ€”The LLM uses structured outputs (LLMAnswer + VideoItem) internally to produce consistent results.
  • โ€”Top videos are embedded as iframes in the Gradio interface.
  • โ€”You can adjust the number of top videos returned by modifying the top_k parameter in answer_query.