Skip to content

hari9618/Meadia-Mind--MultiAgent-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ™οΈ MediaMind β€” Autonomous Media Intelligence Platform

⚑ Multi-Agent AI that turns any podcast, video or transcript into summaries, highlights, social content & direct answers


🧩 Tech Badges


πŸš€ Live Demo

πŸ‘‰ Try the App Here

πŸ”— https://mediamind-ai.onrender.com/


πŸ“Œ Project Overview

MediaMind is a production-grade Autonomous Media Intelligence Platform powered by a multi-agent AI pipeline.

Instead of a single LLM call, it routes every user request through a Supervisor β†’ Specialist agent system β€” intelligently deciding whether to summarize, extract highlights, generate social content, or answer a direct question.

It combines Groq's ultra-fast inference with Hybrid RAG (ChromaDB + BM25), MCP-style tool calling, Langfuse v4 observability, RAGAS auto-evaluation, and real-time YouTube transcript ingestion β€” all behind a clean, session-aware Streamlit chat UI.


✨ Key Features

Feature Description
⚑ Ultra-Fast Inference Groq LPU running Llama 3.3 70B β€” sub-2s responses
🧠 Multi-Agent Pipeline Supervisor routes to Summarize / Highlight / Social / Q&A agent
πŸ“Ί YouTube Ingestion Paste any YouTube URL β€” transcript fetched, indexed, answered
πŸ” Hybrid RAG ChromaDB vector search (60%) + BM25 keyword search (40%) merged
πŸ”§ MCP Tool Registry Wikipedia, DuckDuckGo, YouTube Transcript, File Reader β€” per-agent access control
πŸ’¬ Multi-Session Chat Full session history, auto-titles, session switching, export to markdown
πŸ’¬ Direct Q&A Mode Ask any question β€” Q&A Agent answers in 2–5 sentences, grounded in context
πŸ›‘οΈ Production Guardrails Input validation, content moderation, output sanitization (Pydantic v2)
πŸ“Š RAGAS Auto-Evaluation Faithfulness, Answer Relevancy, Context Precision + Hallucination detection
πŸ”­ Langfuse Observability Every trace, span, LLM call and RAGAS score logged to Langfuse dashboard
πŸš€ Deployed on Render Persistent ChromaDB storage β€” data survives server restarts

πŸ› οΈ Tech Stack

Technology Purpose
🐍 Python 3.11+ Core programming
⚑ Groq API Fast LLM inference (Llama 3.3 70B)
🧠 LangGraph Agent orchestration (StateGraph)
πŸ”— LangChain LLM integration + tool binding
🎨 Streamlit Frontend UI + multi-session chat
πŸ“¦ ChromaDB Persistent vector store
πŸ“Š BM25 (rank_bm25) Keyword search for hybrid RAG
πŸ€— all-MiniLM-L6-v2 Local embeddings β€” zero API cost
🌐 DuckDuckGo DDGS Live web search tool
πŸ“– Wikipedia API Factual enrichment tool
πŸ“Š RAGAS 0.4.x Production RAG evaluation (reference-free)
πŸ”­ Langfuse v4 LLM observability + score tracking
πŸš€ Render Cloud deployment
🐳 Docker Containerised production build

πŸ—οΈ System Architecture

MediaMind
β”‚
β”œβ”€β”€ app.py              # Streamlit UI β€” multi-session chat, source management
β”œβ”€β”€ agent.py            # LangGraph multi-agent pipeline + evaluation trigger
β”œβ”€β”€ rag.py              # Hybrid RAG (ChromaDB + BM25) β€” retrieve_context_with_chunks()
β”œβ”€β”€ evaluation.py       # RAGAS evaluation service (fire-and-forget, non-blocking)
β”œβ”€β”€ mcp_tools.py        # MCP tool registry (4 tools, per-agent access control)
β”œβ”€β”€ llm.py              # Groq LLM client (3 temperature modes)
β”œβ”€β”€ prompts.py          # All LLM prompts β€” ChatPromptTemplate + Few-Shot + CoT
β”œβ”€β”€ guardrails.py       # Input validation, content moderation, output sanitization
β”œβ”€β”€ tracer.py           # Langfuse v4 observability wrapper
β”œβ”€β”€ schemas.py          # Pydantic v2 schemas for I/O validation
β”œβ”€β”€ config.py           # Central config β€” models, RAG params, eval thresholds
β”œβ”€β”€ tracer.py           # Langfuse v4 SDK wrapper (create_score, spans, traces)
β”œβ”€β”€ Dockerfile          # Multi-stage production build
β”œβ”€β”€ docker-compose.yml  # Local dev + persistent volumes
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ .env                # API keys (NOT pushed to GitHub)
└── README.md

πŸ€– Agent Pipeline

User Query
    β”‚
    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Supervisor Node                    β”‚
β”‚          Reads query, decides routing (temp=0.0)      β”‚
β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
     β”‚          β”‚              β”‚              β”‚
     β–Ό          β–Ό              β–Ό              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚Summarizeβ”‚ β”‚Highlightβ”‚ β”‚ Social  β”‚  β”‚  Q&A Agent β”‚
β”‚  Agent  β”‚ β”‚  Agent  β”‚ β”‚  Agent  β”‚  β”‚            β”‚
β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
     β”‚           β”‚           β”‚             β”‚
     β–Ό           β–Ό           β–Ό             β–Ό
 Wikipedia   Wikipedia   Web Search    Wikipedia
 Web Search  Web Search    (only)      Web Search
     β”‚           β”‚           β”‚             β”‚
     β–Ό           β–Ό           β–Ό             β–Ό
  Groq 0.3   Groq 0.0    Groq 0.75    Groq 0.3
 (balanced) (precise)   (creative)   (balanced)
     β”‚           β”‚           β”‚             β”‚
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚
                         β–Ό
              Output Guardrails
              (validation + sanitization)
                         β”‚
                         β–Ό
                 Final Response β†’ UI
                         β”‚
                         β–Ό (background daemon thread)
              RAGAS Evaluation (non-blocking)
                         β”‚
                         β–Ό
              Langfuse Scores Dashboard

πŸ€– Agent Routing Logic

Query type Example Routes to
Wants a summary / overview "summarize this video" summarize_agent
Wants highlights / key moments "what are the key points?" highlight_agent
Wants social media content "write a LinkedIn post" social_agent
Asks a direct question "what does X mean?" / "who is Y?" qa_agent

Routing rule: If the query contains question words β€” what, why, how, who, when, explain, define, tell me β€” the supervisor always routes to qa_agent. The Q&A Agent answers in 2–5 sentences grounded in transcript content, no structured reports.


πŸ” Hybrid RAG Pipeline

User Query
    β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β–Ό                              β–Ό
ChromaDB Vector Search         BM25 Keyword Search
(semantic similarity)          (exact term matching)
all-MiniLM-L6-v2 embeddings    rank_bm25 BM25Okapi
Top-4 chunks (60% weight)      Top-4 chunks (40% weight)
    β”‚                              β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β–Ό
       Merge + Deduplicate
    (vector results get priority)
               β”‚
               β–Ό
  retrieve_context_with_chunks()
  returns: (joined_str, List[str])
       β”‚              β”‚
       β–Ό              β–Ό
   LLM Prompt    RAGAS Evaluation

retrieve_context_with_chunks() returns both the joined context string (for the LLM prompt) and the raw chunk list (for RAGAS evaluation) in a single retrieval call β€” zero double-fetching.


πŸ“Š RAGAS Evaluation Pipeline

MediaMind automatically evaluates every production query using RAGAS 0.4.x β€” no ground truth or human labels required.

run_agent() completes
       β”‚
       β–Ό (fire-and-forget daemon thread β€” user never waits)
EvaluationService.evaluate_fire_and_forget()
       β”‚
       β–Ό
_run_ragas_sync()
  β”œβ”€β”€ Faithfulness                          (is answer grounded in context?)
  β”œβ”€β”€ Answer Relevancy                      (does answer address the question?)
  └── LLMContextPrecisionWithoutReference   (is retrieval pulling clean chunks?)
       β”‚
       β–Ό
_check_thresholds()  β†’  WARNING logs + UI alerts if below threshold
       β”‚
       β–Ό
tracer.score_response()  β†’  client.create_score()  β†’  Langfuse dashboard

Evaluation Metrics

Metric What it measures Threshold
Faithfulness Is the answer grounded in retrieved context? Low = hallucination risk >= 0.70
Answer Relevancy Does the answer actually address the query? >= 0.65
Context Precision Are retrieved chunks mostly relevant? Low = noisy retrieval >= 0.60
Hallucination Score Derived: 1 - faithfulness. High = fabrication risk <= 0.30

All metrics are reference-free β€” no ground truth needed. Scores appear in Langfuse within ~10–20s of each response.


πŸ”­ Langfuse Observability

Every pipeline run is fully traced in Langfuse v4:

What is traced Langfuse object
Full pipeline run Root span (mediamind_pipeline)
Supervisor routing decision Child span
RAG retrieval Child span (chunk count + latency)
Every LLM call (LangGraph) Auto-traced via CallbackHandler
Guardrail checks Child span (pass/fail + reason)
RAGAS scores create_score() per metric
User thumbs up / down create_score("user_feedback")

Langfuse v4 note: Uses get_client() + start_as_current_observation() + create_score(). The old .score() method silently did nothing β€” fixed to create_score() with data_type="NUMERIC".


πŸ›‘οΈ Production Guardrails

Three-layer protection on every request:

Input Query
    β”‚
    β–Ό
1. Pydantic QueryInput validation
   (min/max length, whitespace, injection patterns)
    β”‚
    β–Ό
2. Content moderation
   (off-topic, harmful, ambiguous β€” rule-based, no API cost)
    β”‚
    β–Ό
3. Output guardrails
   (HighlightOutput schema validation, prompt-leak sanitization)

πŸ”§ MCP Tool Registry

Tool Description Agent Access
youtube_transcript Fetches full transcript from YouTube URL Research agent
web_search Live DuckDuckGo search for news & trends All agents
wikipedia_search Factual background on people & topics Summarize, Highlight, Q&A
read_file Reads local .txt / .srt / .md transcript Research agent

Each agent gets only the tools it needs β€” deliberate access control, not default behaviour.


βš™οΈ Installation Guide

1️⃣ Clone Repository

git clone https://github.com/hari9618/mediamind
cd mediamind

2️⃣ Create Virtual Environment

python -m venv venv
source venv/bin/activate   # Mac/Linux
venv\Scripts\activate      # Windows

3️⃣ Install Dependencies

pip install -r requirements.txt

4️⃣ Setup Environment Variables

Create a .env file (see .env.example):

# Required
GROQ_API_KEY=your_groq_api_key_here

# Langfuse observability (v4 SDK)
LANGFUSE_PUBLIC_KEY=pk-lf-...
LANGFUSE_SECRET_KEY=sk-lf-...
LANGFUSE_BASE_URL=https://us.cloud.langfuse.com   # or https://cloud.langfuse.com for EU

# RAGAS evaluation
EVAL_ENABLED=true
EVAL_LOG_TO_LANGFUSE=true
EVAL_THRESH_FAITHFULNESS=0.70
EVAL_THRESH_PRECISION=0.60
EVAL_THRESH_RELEVANCY=0.65
EVAL_THRESH_HALLUCINATION=0.30

Get your free Groq API key at console.groq.com
Get your Langfuse keys at cloud.langfuse.com

5️⃣ Run the App

streamlit run app.py

🐳 Run with Docker

docker compose up --build    # first run
docker compose up            # subsequent runs
docker compose down -v       # stop + wipe volumes

🧠 How It Works

1️⃣  User sends a query (or pastes a YouTube URL)
        β”‚
2️⃣  Input guardrails β†’ Pydantic validation + content moderation
        β”‚
3️⃣  YouTube URL detected? β†’ Fetch transcript β†’ Clear ChromaDB β†’ Re-index
        β”‚
4️⃣  retrieve_context_with_chunks() β†’ ChromaDB semantic + BM25 keyword β†’ Top-4 chunks
        β”‚                              returns both joined string AND raw list
        β”‚
5️⃣  Supervisor reads query β†’ Routes to Summarize / Highlight / Social / Q&A agent
        β”‚        (question words detected? β†’ qa_agent for direct concise answer)
        β”‚
6️⃣  Agent calls MCP tools (Wikipedia, DuckDuckGo) via ReAct reasoning
        β”‚
7️⃣  Agent formats prompt β†’ Groq LLM β†’ Output guardrails β†’ Response to UI
        β”‚
8️⃣  Background: RAGAS evaluates faithfulness + relevancy + precision
        β”‚         Scores posted to Langfuse via create_score() (~10–20s delay)
        β”‚
9️⃣  Response rendered in chat β€” markdown or styled highlight cards
       User can submit πŸ‘/πŸ‘Ž feedback β†’ score_response("user_feedback") β†’ Langfuse

πŸ“· Application Preview

MediaMind Screenshot

πŸ“š What I Learned

βœ” LangGraph StateGraph β€” building real state machines with typed state and conditional edges
βœ” Hybrid RAG Engineering β€” combining vector + keyword search with weighted merging
βœ” MCP Tool Architecture β€” per-agent access control, tool binding, ToolMessage conversations
βœ” Multi-Session State Management β€” Streamlit session_state design for complex apps
βœ” Production RAG Deployment β€” PersistentClient ChromaDB, real-time re-indexing
βœ” LLM Temperature Strategy β€” precise / balanced / creative modes for different task types
βœ” YouTube API Integration β€” youtube-transcript-api v1.x, URL parsing, live ingestion
βœ” Intelligent Task Routing β€” keyword-based intent detection to separate Q&A from generation tasks
βœ” RAGAS Evaluation β€” reference-free production RAG evaluation with Faithfulness, Relevancy, Context Precision
βœ” Langfuse v4 Observability β€” tracing, spans, scores, create_score() API, US vs EU region config
βœ” Production Guardrails β€” Pydantic v2 input/output validation, prompt injection detection, content moderation
βœ” SDK Version Debugging β€” diagnosed breaking changes across RAGAS 0.1β†’0.4 and Langfuse v2β†’v4 APIs


🎯 Future Improvements

πŸ”Ή Cross-encoder reranking β€” add cross-encoder/ms-marco-MiniLM-L-6-v2 between retrieval and TOP-K slice
πŸ”Ή Semantic chunking β€” replace character splitter with SemanticChunker for boundary-aware chunks
πŸ”Ή Offline CI evaluation β€” RAGAS batch evaluation against collected JSONL dataset in GitHub Actions
πŸ”Ή Speaker diarization β€” identify who said what in transcripts
πŸ”Ή Multi-turn Q&A β€” follow-up questions that remember previous answers in session
πŸ”Ή Multi-document RAG β€” index multiple videos/files simultaneously
πŸ”Ή Audio file support β€” direct .mp3/.wav upload with Whisper transcription
πŸ”Ή Synthetic dataset generation β€” RAGAS testset generator for automated benchmark creation


πŸ‘¨β€πŸ’» Author

Hari Krishna T
AI Engineer | Multi-Agent Systems Builder | Gen AI Developer

πŸ”— GitHub: github.com/hari9618
πŸ”— LinkedIn: linkedin.com/in/hari-krishna-thota-06b850275


⭐ Support

If you like this project:

⭐ Star the repository
πŸ“’ Share with others
🍴 Fork and build on top of it


πŸ“’ Tags

AI Multi-Agent LangGraph LangChain Groq RAG ChromaDB BM25 Streamlit YouTube MCP RAGAS Langfuse Evaluation Observability Guardrails Python Generative AI LLM Render Docker

About

🧠 MediaMind is a multi-agent AI-powered media intelligence platform that transforms podcasts, videos, and transcripts into summaries, highlights, and social media content using LangGraph, Hybrid RAG, and Groq Llama 3.3 70B. Features include autonomous agent routing, YouTube transcript ingestion, MCP-inspired tool architecture, ChromaDB + BM25 retr

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors