Fade0510's picture
Add Scoring Rubric
18ddfa2
|
Raw
History Blame Contribute Delete
5.74 kB
---
title: CallCenterSummarizationAgent
emoji: 🚀
colorFrom: red
colorTo: red
sdk: docker
app_port: 8501
tags:
- streamlit
pinned: false
short_description: Summarize Call Center Conversations
license: mit
# Add arguments here if the SDK supports them:
args: ["--server.enableCORS", "false", "--server.enableXsrfProtection", "false"]
---
---
# Call Center Data Analysis Agent
This project implements a multi-agent workflow using **LangGraph** to process, transcribe, summarize, and score call center data. It comes with a **Streamlit** user interface to easily upload `.csv`, `.json`, `.mp3`, or `.wav` files and view the resulting insights.
## Workflow Flow & Agent Classes
The core analysis logic is driven by a LangGraph StateGraph defined in `src/workflow.py`. The state moves sequentially between several agent classes located in the `src/agents/` directory.
### Workflow Architecture
```text
[ IntakeAgent ]
|
v
[ Router (file type) ]
/ | \
(CSV invalid)/ (If Audio) (If Text)
v v v
(END) [ TranscriptionAgent ] |
| |
v |
[ ModerationAgent ] <-----/
|
v
[ SummarizationAgent ]
|
v
[ PostSummarizeRouter (output) ]
| |
(END) [ QualityScoringAgent ]
|
v
(END)
```
Notes:
- The workflow uses a LangGraph memory checkpointer (`MemorySaver`) and fallbacks on critical nodes (summarization/scoring) to avoid UI breakage on transient API/parse errors.
- If CSV headers are invalid, the workflow terminates immediately and the UI shows a validation error.
- After summarization, the workflow can short-circuit to `END` if the transcript is too short or the model output is missing/empty.
### Agent Classes
1. **`IntakeAgent` (`src/agents/IntakeAgent.py`)**
- *Entry Point*.
- Reads the uploaded file, validates the file format and schema, extracts basic metadata, and runs a first-pass clean-up (using an LLM).
- **CSV requirement:** headers must include `id` and `transcript` (case-insensitive).
- **JSON supported shapes:** a list of `{id, transcript}` objects, a single `{id, transcript}` object, or a dict with `transcripts`/`calls` arrays containing `{id, transcript}` objects.
2. **`Router` (`src/agents/Router.py`)**
- *Conditional Routing Node*.
- Determines the next step based on the file type and intake validation state.
- **If Audio (`.mp3`, `.wav`)**: Routes to the `TranscriptionAgent`.
- **If Text (`.csv`)**: Routes to the `ModerationAgent` then summarization/scoring.
- **If CSV invalid**: Routes to `END` (the UI displays `metadata.intake_error`).
**`PostSummarizeRouter` (`src/agents/Router.py`)**
- Routes based on model output quality (e.g., short transcript or missing summary can skip scoring).
3. **`TranscriptionAgent` (`src/agents/TranscriptionAgent.py`)**
- Utilizes `openai-whisper` to convert audio files into text.
- Also scrubs the resulting transcript of profanity before passing it down the pipeline.
4. **`ModerationAgent` (`src/agents/ModerationAgent.py`)**
- Receives text either directly from the `Router` (if text upload) or from the `TranscriptionAgent` (if audio upload).
- Identifies any obscene words or profanity using an LLM and replaces them entirely with a `***` mask to safely prepare the text for downstream analysis.
5. **`SummarizationAgent` (`src/agents/SummarizationAgent.py`)**
- Takes the redacted text from the `ModerationAgent`.
- Generates a concise **summary**, **key points**, **action items**, **tags**, and **highlights** using OpenAI (`gpt-4o`) with Pydantic-structured output.
6. **`QualityScoringAgent` (`src/agents/QualityScoringAgent.py`)**
- Takes the clean text and evaluates it against a predefined rubric.
- Scores the transcript based on Tone, Professionalism, and Structured Resolution using Pydantic structured output (function calling when supported). Automatically applies a 3-point penalty to each score and logs a count of policy violations if the `ModerationAgent` detected and masked any profanity (`***`).
## Prerequisites
- Python 3.9+
- An OpenAI API key
- `ffmpeg` installed on your system (required for `openai-whisper` audio transcription).
- On macOS: `brew install ffmpeg`
- On Ubuntu/Debian: `sudo apt update && sudo apt install ffmpeg`
## Installation
1. Create a virtual environment and activate it (if you haven't already):
```bash
python3 -m venv .venv
source .venv/bin/activate
```
2. Install the required dependencies:
```bash
pip install -r requirements.txt
```
## Running the Application
1. Ensure your OpenAI API key is set in your environment variables:
```bash
export OPENAI_API_KEY="your_api_key_here"
```
2. Start the Streamlit application:
```bash
streamlit run src/streamlit_app.py
```
3. Open your browser to the local URL provided by Streamlit (usually `http://localhost:8501`).
4. Use the sidebar to upload a `.csv`, `.mp3`, or `.wav` file and watch the agents analyze your data!
## Processed Files
**Note:** The following sample data can be used for analysis:
- [Customer Call Center Dataset Analysis](https://www.kaggle.com/datasets/rafaqatkhan608/customer-call-center-dataset-analysis/code/data)
- [E-commerce Customer Support English Audio](https://huggingface.co/datasets/HumynLabs/e-commerce-customersupport-english-audio/tree/main)