CoolFace
Apppublic

gvaishnava/ai-call-center-assistant

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
App README

๐Ÿ“ž AI Call Center Assistant

An end-to-end Agentic AI system that transforms raw call center data โ€” audio recordings or text transcripts โ€” into structured insights using a multi-agent LangGraph pipeline powered by GPT-4o.


๐Ÿง  System Overview

The AI Call Center Assistant automatically performs the following on every call:

  1. 1.Validates & registers call metadata (customer, agent, timestamp)
  2. 2.Transcribes audio to text (via OpenAI Whisper API for files, or local RealtimeSTT for Live WebRTC Calls) or accepts text directly
  3. 3.Summarizes the conversation into key points, sentiment, and action items
  4. 4.Quality scores the agent's performance against a structured rubric
  5. 5.Detects sentiment & churn risk from the customer's behavior
  6. 6.Presents all results through an interactive Streamlit UI

๐Ÿ—๏ธ Architecture

User Input (Text / Audio)
         โ”‚
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚      Intake Agent        โ”‚   Validates & enriches metadata (UUID, timestamp)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
             โ”‚
             โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Transcription Agent   โ”‚   Whisper API (audio files), RealtimeSTT (Live Call), or passthrough (text)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
             โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”
        โ”‚         โ”‚   (parallel async execution via LangGraph)
        โ–ผ         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Summarizationโ”‚ โ”‚  Quality Scoring  โ”‚
โ”‚    Agent     โ”‚ โ”‚      Agent        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
        โ”‚                  โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ–ผ
       Streamlit UI (Results)

All agents are connected via a LangGraph StateGraph with full async/await support, ensuring summarization and quality scoring run in parallel after transcription completes.


๐Ÿค– Agents

1. IntakeAgent โ€” agents/intake_agent.py

  • โ€”Validates raw user input using Pydantic models
  • โ€”Auto-generates call_id (UUID) and timestamp if not provided
  • โ€”Returns a structured CallMetadata object

2. TranscriptionAgent โ€” agents/transcription_agent.py

  • โ€”Live Call (WebRTC): Uses streamlit-webrtc and RealtimeSTT (local, free Whisper tiny.en or base.en models) to capture and transcribe browser microphone audio instantly via true multi-threading.
  • โ€”Audio File mode: Calls OpenAI whisper-1 via AsyncOpenAI for fast file-based speech-to-text.
  • โ€”Text mode: Directly wraps provided text into a TranscriptionResult
  • โ€”Cloud API calls are wrapped with LangSmith wrap_openai for full trace visibility

3. SummarizationAgent โ€” agents/summarization_agent.py

  • โ€”Uses gpt-4o with a structured prompt via LangChain
  • โ€”Extracts:
  • โ€”One-line call summary
  • โ€”Key discussion points
  • โ€”Overall sentiment (Positive / Neutral / Negative)
  • โ€”Action items โ€” including callbacks, follow-ups, and future dates
  • โ€”Returns a structured CallSummary Pydantic object

4. QualityScoreAgent โ€” agents/quality_score_agent.py

  • โ€”Uses gpt-4o with a loaded rubric from config/rubrics.json
  • โ€”Scores agent performance across 5 dimensions (1โ€“10 scale): | Dimension | Description | |---|---| | technical_score | Technical knowledge & issue resolution | | professionalism_score | Demeanor, respectfulness, brand representation | | communication_score | Clarity, conciseness, language appropriateness | | process_adherence_score | Policy compliance & verification steps | | soft_skills_score | Empathy, active listening, emotional de-escalation |
  • โ€”Also extracts: customer sentiment, primary emotion, agent tone, sentiment shift, and churn risk

5. RoutingAgent โ€” agents/routing_agent.py

  • โ€”LangGraph orchestrator that connects all agents
  • โ€”Exposes a single async run(raw_input) entry point
  • โ€”Manages the state machine (GraphState) across all nodes
  • โ€”Handles errors gracefully per node without crashing the full pipeline

๐Ÿ–ฅ๏ธ User Interface

Streamlit (ui/streamlit_app.py) provides an interactive web dashboard:

  • โ€”Choose input mode: Text Transcript, Audio File upload (WAV/MP3/M4A), or Live Call (WebRTC)
  • โ€”Live Call mode streams browser audio via true multi-threaded AudioProcessorBase into a local Whisper engine, updating text on the screen word-by-word with zero text loss.
  • โ€”Enter customer and agent names
  • โ€”Click Generate Insights to run the full pipeline
  • โ€”View results:
  • โ€”Quality score metric cards (Professionalism, Soft Skills, Technical)
  • โ€”Sentiment analysis (sentiment, emotion, agent tone, churn risk, sentiment shift)
  • โ€”Call summary (one-line, key points, action items)
  • โ€”Full transcript expander
  • โ€”Quality scoring rubric notes expander

๐Ÿ“Š Quality Rubric

Scoring rubric is externalized to config/rubrics.json for easy customization without code changes.

Each category maps score brackets to agent behavior descriptions:

ScoreMeaning
1โ€“3Poor / Non-compliant
4โ€“6Average / Partial compliance
7โ€“8Good / Meets expectations
9โ€“10Exceptional / Exceeds expectations

๐Ÿ” Observability โ€” LangSmith

The system integrates LangSmith for full trace visibility into every call processed:

  • โ€”All LangChain/LangGraph calls are automatically traced (via LANGCHAIN_TRACING_V2)
  • โ€”Direct OpenAI Whisper calls are traced via langsmith.wrappers.wrap_openai
  • โ€”View token usage, latency, prompts, outputs, and LangGraph node transitions at smith.langchain.com

๐Ÿš€ Getting Started

Prerequisites

  • โ€”Python 3.10+
  • โ€”OpenAI API Key
  • โ€”LangSmith API Key (optional, for tracing)
  • โ€”System Packages: ffmpeg and portaudio19-dev (Linux) for microphone/audio processing.

Installation

bash
# 1. Clone the repository
git clone <repo-url>
cd "AI Call Center Assistant"

# 2. Create and activate virtual environment
python -m venv venv
.\venv\Scripts\Activate.ps1      # Windows
source venv/bin/activate          # Linux/Mac

# 3. Install dependencies
pip install -r requirements.txt

Configuration

Create a .env file in the root directory:

env
OPENAI_API_KEY="sk-..."

# Optional: LangSmith tracing
LANGCHAIN_TRACING_V2=true
LANGCHAIN_API_KEY="lsv2_..."
LANGCHAIN_PROJECT="AI Call Center Assistant"
toml
OPENAI_API_KEY = "sk-..."
LANGCHAIN_TRACING_V2 = "true"
LANGCHAIN_API_KEY = "lsv2_..."
LANGCHAIN_PROJECT = "AI Call Center Assistant"

# TURN Server (Metered.ca)
TURN_USERNAME = "..."
TURN_CREDENTIAL = "..."

# Optional: Faster Hugging Face downloads
HF_TOKEN = "hf_..."

Hugging Face Spaces Deployment

This repository includes the required metadata in README.md to run as a Hugging Face Space.

  1. 1.Create a new Space on Hugging Face.
  2. 2.Select Streamlit as the SDK.
  3. 3.Connect this GitHub repository.
  4. 4.Add the secrets listed above to Settings > Variables and Secrets on Hugging Face.
  5. 5.Note: Use "Secrets" for API keys and "Variables" for public config.
  6. 6.Hugging Face will automatically install dependencies from requirements.txt and system packages from packages.txt.

The application automatically syncs these secrets to environment variables on startup.

Run the Application

bash
streamlit run ui/streamlit_app.py

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


๐Ÿงช Testing

The project includes a closed-ended LLM-as-judge evaluation framework.

bash
python -m tests.test_closed_ended_validation

This runs a second gpt-4o model as an independent judge that evaluates each pipeline output against pre-defined yes/no validation questions per sample transcript.

Latest results: 10 / 10 tests passed (100%)

Sample validation questions include:

  • โ€”"Does the one_line_summary mention an issue with the internet cutting out or fluctuating?"
  • โ€”"Is the churn_risk_detected correctly identified based on the customer's behavior?"
  • โ€”"Did the quality score professionalism_score exceed 6?"

Real-Time Audio Testing

To mathematically verify that the WebRTC background threads are lossless, a direct STT pipeline test is provided.

bash
python tests/test_realtime_stt.py

This script bypasses Streamlit and chunks a standard WAV file into 100ms segments, simulating exactly how the browser sends audio, proving that the local VAD and threading implementation does not drop frames.


๐Ÿ“ Project Structure

AI Call Center Assistant/
โ”œโ”€โ”€ agents/
โ”‚   โ”œโ”€โ”€ intake_agent.py           # Input validation & metadata extraction
โ”‚   โ”œโ”€โ”€ transcription_agent.py    # Audio-to-text (Whisper) or text passthrough
โ”‚   โ”œโ”€โ”€ summarization_agent.py    # GPT-4o call summarization
โ”‚   โ”œโ”€โ”€ quality_score_agent.py    # GPT-4o rubric-based quality scoring
โ”‚   โ””โ”€โ”€ routing_agent.py          # LangGraph orchestrator
โ”œโ”€โ”€ config/
โ”‚   โ”œโ”€โ”€ rubrics.json              # Dynamic quality scoring rubric
โ”‚   โ””โ”€โ”€ mcp.yaml                  # Model Control Plane configuration
โ”œโ”€โ”€ data/
โ”‚   โ””โ”€โ”€ sample_transcripts/
โ”‚       โ””โ”€โ”€ samples.json          # Sample call transcripts for testing
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ test_closed_ended_validation.py  # LLM-as-judge evaluation suite
โ”œโ”€โ”€ ui/
โ”‚   โ””โ”€โ”€ streamlit_app.py          # Streamlit web interface
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ logger.py                 # Centralized logging
โ”‚   โ””โ”€โ”€ validation.py             # Pydantic models (CallMetadata, QualityScore, etc.)
โ”œโ”€โ”€ .env                          # API keys & environment config
โ”œโ”€โ”€ requirements.txt              # Python dependencies
โ”œโ”€โ”€ docker-compose.yml            # Docker deployment config
โ””โ”€โ”€ README.md                     # This document

๐Ÿ“ฆ Dependencies

PackagePurpose
langchain, langchain-openaiLLM prompting & chain composition
langgraphMulti-agent graph orchestration
openaiGPT-4o + Whisper API access
langsmithTracing, monitoring & evaluation
pydanticStructured data validation
streamlitWeb UI
streamlit-webrtc, tornadoWebRTC live browser audio capture
RealtimeSTT, pydubLocal, word-by-word live transcription via faster-whisper
python-dotenvEnvironment variable management

๐Ÿ”ฎ Key Design Decisions

DecisionRationale
Async throughoutAll agents use async/await + LangGraph ainvoke so summarization and quality scoring run in parallel
Externalized rubricrubrics.json allows scoring criteria to be updated without code changes
Pydantic output parsingEnforces structured, type-safe LLM outputs that flow cleanly between agents
LLM-as-Judge testingUses a second independent LLM to objectively evaluate pipeline output quality
LangSmith integrationProvides deep observability into every node, prompt, and API call

๐Ÿณ Docker Deployment

bash
docker-compose up --build

The docker-compose.yml is configured to run the Streamlit application in a container.


Built with LangGraph, GPT-4o, OpenAI Whisper, LangSmith, and Streamlit.