CoolFace
Apppublic

navamara55/callcenter-agent

sourceHugging Facemitupdated 8mo agoView on Hugging Face
0likes
App README

AI Call Center Assistant πŸ“ž

Multi-Agent AI System for Call Center Audio Analysis with Automated Transcription, Summarization, Sentiment Analysis, and Quality Scoring.

![Python 3.10+](https://www.python.org/downloads/) ![License: MIT](https://opensource.org/licenses/MIT) ![Streamlit](https://streamlit.io)

πŸš€ [Live Demo](https://huggingface.co/spaces/navamara55/callcenter-agent) - Try it on Hugging Face Spaces!

🌟 Features

  • β€”πŸŽ™οΈ Audio Transcription: Automatic speech-to-text using OpenAI Whisper API with intelligent caching
  • β€”πŸ“ Call Summarization: Concise, structured summaries with key points and resolutions
  • β€”πŸ’­ Sentiment Analysis: Customer and agent sentiment tracking with emotional journey mapping
  • β€”πŸ“Š Quality Scoring: Comprehensive evaluation on 5 criteria (greeting, empathy, resolution, professionalism, adherence)
  • β€”βœ… Action Item Extraction: Automatic identification of follow-ups, commitments, and tasks
  • β€”πŸ‘₯ Role-Based Views: Specialized dashboards for Agents, Managers, and QA Teams
  • β€”πŸ“ˆ Interactive Visualizations: Radar charts, sentiment timelines, and exportable action items
  • β€”οΏ½ PDF Export: Professional reports with text and visual charts for stakeholder distribution
  • β€”οΏ½πŸ”„ Conversation Memory: Context-aware interactions using LangGraph checkpointing
  • β€”βš‘ Smart Routing: GPT-4o-mini powered query classification and agent routing
  • β€”πŸ›‘οΈ Production Guardrails: Rate limiting, cost control, circuit breaker, and metrics tracking

πŸ“Έ Screenshots

Home View

[image]

Agent View

[image]

Manager View

[image]

Quality Score Dashboard

[image]

Call Summary

[image]

Topic Tags

[image]

πŸ—οΈ Architecture

Multi-Agent System with Guardrails

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    User Query                            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  Query Router  β”‚ (GPT-4o-mini)
              β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚             β”‚             β”‚
   β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”   β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”   β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”
   β”‚ Call   β”‚   β”‚ Trans-  β”‚   β”‚ Summar- β”‚
   β”‚ Intake β”‚   β”‚ criptionβ”‚   β”‚ ization β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
       β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
       β”‚ Quality β”‚      β”‚  Sentiment  β”‚
       β”‚ Scoring β”‚      β”‚  Analysis   β”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

═══════════════════════════════════════════════════════════
         πŸ›‘οΈ Guardrail Layer (All API Calls)
═══════════════════════════════════════════════════════════
  Rate Limiting β”‚ Cost Tracking β”‚ Circuit Breaker β”‚ Metrics
═══════════════════════════════════════════════════════════

5 Specialized Agents

  1. 1.Call Intake Agent: Initial query handling and system guidance
  2. 2.Transcription Agent: Audio β†’ text with speaker labeling (Whisper + GPT-4o-mini)
  3. 3.Summarization Agent: Structured call summaries with key insights
  4. 4.Quality Scoring Agent: 1-10 scoring on 5 criteria with justifications
  5. 5.Sentiment Analysis Agent: Emotion tracking + action item extraction

πŸš€ Quick Start

Prerequisites

  • β€”Python 3.10 or higher
  • β€”OpenAI API key
  • β€”(Optional) Hugging Face token for datasets

Installation

  1. 1.Clone the repository
bash
git clone https://github.com/yourusername/ai-callcenter-assistant.git
cd ai-callcenter-assistant
  1. 1.Install uv (if not already installed)
bash
curl -LsSf https://astral.sh/uv/install.sh | sh

Or on macOS/Linux:

bash
brew install uv
  1. 1.Install dependencies with uv (recommended)
bash
uv sync

Or using pip:

bash
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
  1. 1.Set up environment variables
bash
cp .env.example .env

Edit .env and add your API keys:

env
OPENAI_API_KEY=sk-your-openai-api-key-here
HF_TOKEN=hf_your-huggingface-token-here  # Optional
  1. 1.Run the application

With UV (recommended):

bash
uv run python -m streamlit run app.py --server.port 8501

Or using pip/venv:

bash
source venv/bin/activate
streamlit run app.py

The app will open in your browser at http://localhost:8501

πŸ’‘ Tip: See docs/UV_COMMANDS.md for all available UV commands

πŸ“– Usage

Upload and Analyze Calls

  1. 1.Upload Audio: Click "Upload Call Recording" in the sidebar
  2. 2.Supported formats: MP3, WAV, M4A, OGG
  3. 3.Max size: 25MB
  1. 1.Transcribe: Click "πŸŽ™οΈ Transcribe Audio"
  2. 2.First transcription uses Whisper API
  3. 3.Subsequent transcriptions of the same file use cache
  1. 1.Analyze: Choose from three views:
πŸ‘€ Agent View
  • β€”Generate call summaries
  • β€”View action items
  • β€”Quick insights for call handlers
πŸ“Š Manager View
  • β€”Quality score radar charts
  • β€”Performance metrics
  • β€”Strengths and improvement areas
πŸ” QA View
  • β€”Detailed quality evaluation
  • β€”Sentiment analysis
  • β€”Action item tracking with CSV export

Example Queries

  • β€”"Transcribe this audio file"
  • β€”"Summarize this call"
  • β€”"What was the customer sentiment?"
  • β€”"Evaluate the quality of this conversation"
  • β€”"What action items were mentioned?"

πŸ§ͺ Testing

Run Tests

With UV (recommended):

bash
# Run all tests
uv run pytest tests/ -v

# Run with coverage
uv run pytest tests/ --cov=src/ai_callcenter_assistant --cov-report=html

# Using test runner script
./run_tests_uv.sh all

Traditional method:

bash
pytest tests/ -v

Test Coverage

  • β€”125+ test methods across 27+ test classes
  • β€”2,500+ lines of test code
  • β€”87.5%+ passing rate (112/128 tests)
  • β€”Coverage: Agents (100%), Orchestration (95%+), Router (95%+)

See docs/testing/TESTING.md for detailed testing guide and docs/UV_COMMANDS.md for all UV test commands.

πŸ“Š Evaluation

The system uses BLEU scores to evaluate summarization quality.

Run Evaluation

bash
uv run evaluate-system

Evaluation Metrics

  • β€”BLEU Score: Measures summary quality against references
  • β€”Quality Score MAE: Mean absolute error for quality predictions
  • β€”Action Item F1: Precision and recall for action item extraction

Creating Ground Truth

  1. 1.Prepare reference summaries in data/evaluation/ground_truth.json
  2. 2.Run system on test calls
  3. 3.Compare outputs using the evaluator
python
from ai_callcenter_assistant.utils.evaluator import get_system_evaluator

evaluator = get_system_evaluator()
results = evaluator.evaluate_summaries(generated, references)
print(f"Mean BLEU: {results['mean_bleu']:.4f}")

🧩 Project Structure

ai-callcenter-assistant/
β”œβ”€β”€ app.py                          # Streamlit application
β”œβ”€β”€ pyproject.toml                  # Dependencies & config
β”œβ”€β”€ requirements.txt                # Pinned dependencies
β”œβ”€β”€ Dockerfile                      # Container definition
β”œβ”€β”€ .env.example                    # Environment template
β”‚
β”œβ”€β”€ src/
β”‚   └── ai_callcenter_assistant/
β”‚       β”œβ”€β”€ config.py               # Configuration & prompts
β”‚       β”œβ”€β”€ graph.py                # LangGraph workflow
β”‚       β”œβ”€β”€ router.py               # Query routing
β”‚       β”‚
β”‚       β”œβ”€β”€ agents/                 # 5 specialized agents
β”‚       β”‚   β”œβ”€β”€ call_intake.py
β”‚       β”‚   β”œβ”€β”€ transcription.py
β”‚       β”‚   β”œβ”€β”€ summarization.py
β”‚       β”‚   β”œβ”€β”€ quality_scoring.py
β”‚       β”‚   └── sentiment_analysis.py
β”‚       β”‚
β”‚       β”œβ”€β”€ tools/                  # Core tools
β”‚       β”‚   └── whisper_transcriber.py
β”‚       β”‚
β”‚       β”œβ”€β”€ utils/                  # Utilities
β”‚       β”‚   └── evaluator.py
β”‚       β”‚
β”‚       └── scripts/                # CLI scripts
β”‚           β”œβ”€β”€ download_audio_datasets.py
β”‚           └── evaluate_system.py
β”‚
β”œβ”€β”€ tests/                          # Unit tests
β”‚   β”œβ”€β”€ test_router.py
β”‚   β”œβ”€β”€ test_agents.py
β”‚   └── test_whisper.py
β”‚
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ audio_files/                # Uploaded audio
β”‚   β”œβ”€β”€ transcripts/                # Cached transcripts
β”‚   └── evaluation/                 # Evaluation data
β”‚
└── .github/
    └── workflows/
        └── deploy.yml              # HF Spaces deployment

πŸ§ͺ Testing

Run All Tests

bash
uv run pytest

Run with Coverage

bash
uv run pytest --cov=src/ai_callcenter_assistant --cov-report=html

Run Specific Tests

bash
pytest tests/test_router.py
pytest tests/test_agents.py
pytest tests/test_whisper.py

🐳 Docker

Build Image

bash
docker build -t ai-callcenter-assistant .

Run Container

bash
docker run -p 8501:8501 \
  -e OPENAI_API_KEY=your-key-here \
  ai-callcenter-assistant

Using Docker Compose

bash
docker-compose up

πŸš€ Deployment

Hugging Face Spaces

  1. 1.Create a new Space on Hugging Face
  2. 2.Choose "Streamlit" as SDK
  3. 3.Name it ai-callcenter-assistant
  1. 1.Add Secrets in Space settings
  2. 2.OPENAI_API_KEY: Your OpenAI API key
  1. 1.Configure GitHub Actions
  2. 2.Add HF_TOKEN to repository secrets
  3. 3.Update .github/workflows/deploy.yml with your HF username
  1. 1.Push to trigger deployment
bash
git push origin main

Manual Deployment

bash
# Add Hugging Face remote
git remote add hf https://huggingface.co/spaces/YOUR_USERNAME/ai-callcenter-assistant

# Push to HF Spaces
git push hf main

βš™οΈ Configuration

Model Settings

Edit config.py or set environment variables:

python
OPENAI_MODEL_ROUTER = "gpt-4o-mini"    # Router model
OPENAI_MODEL_AGENT = "gpt-4o-mini"     # Agent model
WHISPER_MODEL = "whisper-1"            # Transcription model

ROUTER_TEMPERATURE = 0.0               # Deterministic routing
AGENT_TEMPERATURE = 0.3                # Creative responses

πŸ›‘οΈ Production Guardrails

The system includes comprehensive production guardrails for cost control and reliability:

Rate Limiting:

bash
RATE_LIMIT_RPM=60              # Requests per minute
RATE_LIMIT_TPM=90000           # Tokens per minute
MAX_TOKENS_PER_REQUEST=2000    # Max tokens per request

Cost Control:

bash
MAX_COST_PER_SESSION=1.00      # Maximum USD per session

Reliability:

bash
MAX_RETRIES=3                  # Retry attempts on failure
RETRY_BACKOFF_FACTOR=2.0       # Exponential backoff multiplier
REQUEST_TIMEOUT=30             # Request timeout (seconds)
CIRCUIT_BREAKER_THRESHOLD=5    # Failures before circuit opens
CIRCUIT_BREAKER_TIMEOUT=60     # Circuit reset timeout (seconds)

Features:

  • β€”βœ… Token bucket rate limiting (thread-safe)
  • β€”βœ… Automatic cost tracking and budget enforcement
  • β€”βœ… Circuit breaker for cascading failure prevention
  • β€”βœ… Exponential backoff retry logic
  • β€”βœ… Real-time metrics and monitoring
  • β€”βœ… UI dashboard with budget usage display

See docs/architecture/guardrails.md for complete documentation.

SSL/TLS Configuration (macOS/uv)

Note: This project disables SSL verification as a workaround for certificate issues with uv-managed Python on macOS. The configuration is in config.py.

For production deployments:

  • β€”Use system Python or Docker (where SSL works correctly)
  • β€”Or configure proper SSL certificates for your environment

Audio Limits

python
MAX_AUDIO_SIZE_MB = 25                 # Max upload size
MAX_AUDIO_DURATION_SECONDS = 600       # 10 minutes

Quality Criteria

python
QUALITY_CRITERIA = [
    "greeting",
    "empathy",
    "problem_resolution",
    "professionalism",
    "script_adherence"
]

πŸ’° Cost Optimization

Caching Strategy

  • β€”Whisper transcriptions: Permanent cache using file hash (no re-transcription)
  • β€”Agent responses: Session-based cache with configurable TTL
  • β€”LangGraph memory: Efficient conversation context management

Model Selection

  • β€”Router: GPT-4o-mini ($0.15/$0.60 per 1M tokens) for classification
  • β€”Agents: GPT-4o-mini for all analysis tasks
  • β€”Whisper: $0.006/minute with aggressive caching

Estimated Costs (per call)

  • β€”Transcription (5 min): ~$0.03 (cached after first use)
  • β€”Routing: ~$0.0001
  • β€”Analysis (all agents): ~$0.01-0.02
  • β€”Total: ~$0.04 per call (first analysis), ~$0.01 (cached transcript)

πŸ”§ Development

Setup Development Environment

bash
# Install with dev dependencies
uv sync --all-extras

# Install pre-commit hooks (if using)
uv run pre-commit install

Code Formatting

bash
uv run black src/ tests/
uv run ruff check src/ tests/ --fix

Adding New Agents

  1. 1.Create agent file in src/ai_callcenter_assistant/agents/
  2. 2.Follow existing agent pattern (inherit system prompt, process method)
  3. 3.Register in graph.py
  4. 4.Update router with new agent name
  5. 5.Add tests in tests/

πŸ“Š Performance

  • β€”Transcription: ~2-5 seconds per minute of audio (Whisper API)
  • β€”Analysis: ~3-10 seconds per query (GPT-4o-mini)
  • β€”Routing: <1 second (GPT-4o-mini)
  • β€”Total: ~10-20 seconds for full analysis of 5-minute call

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. 1.Fork the repository
  2. 2.Create a feature branch (git checkout -b feature/amazing-feature)
  3. 3.Commit your changes (git commit -m 'Add amazing feature')
  4. 4.Push to branch (git push origin feature/amazing-feature)
  5. 5.Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • β€”OpenAI for GPT-4o-mini and Whisper API
  • β€”LangChain and LangGraph for agent orchestration
  • β€”Streamlit for the web interface
  • β€”Hugging Face for hosting and datasets

πŸ“§ Contact

For questions, issues, or feedback:

  • β€”Create an Issue
  • β€”Email: your.email@example.com

πŸ—ΊοΈ Roadmap

  • β€”[ ] Real-time audio streaming support
  • β€”[ ] Speaker diarization with pyannote-audio
  • β€”[ ] Multi-language support
  • β€”[ ] Custom quality scoring rubrics
  • β€”[ ] Batch processing API
  • β€”[ ] Analytics dashboard
  • β€”[ ] Integration with CRM systems

Built with ❀️ using GPT-4o-mini, OpenAI Whisper, LangGraph, and Streamlit