CoolFace
Apppublic

Fade0510/CallCenterSummarizationAgent

sourceHugging Facemitupdated 5mo agoView on Hugging Face
0likes
README.md130 linesDownload Raw Back to root
1---2title: CallCenterSummarizationAgent3emoji: ๐Ÿš€4colorFrom: red5colorTo: red6sdk: docker7app_port: 85018tags:9- streamlit10pinned: false11short_description: Summarize Call Center Conversations12license: mit13# Add arguments here if the SDK supports them:14args: ["--server.enableCORS", "false", "--server.enableXsrfProtection", "false"]15---16---17# Call Center Data Analysis Agent18 19This 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.20 21## Workflow Flow & Agent Classes22 23The 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.24 25### Workflow Architecture26```text27                  [ IntakeAgent ]28                        |29                        v30               [ Router (file type) ]31              /         |           \32 (CSV invalid)/     (If Audio)     (If Text)33          v          v               v34        (END) [ TranscriptionAgent ] |35                  |                  |36                  v                  |37            [ ModerationAgent ] <-----/38                  |39                  v40          [ SummarizationAgent ]41                  |42                  v43     [ PostSummarizeRouter (output) ]44              |                |45           (END)        [ QualityScoringAgent ]46                               |47                               v48                             (END)49```50 51Notes:52- The workflow uses a LangGraph memory checkpointer (`MemorySaver`) and fallbacks on critical nodes (summarization/scoring) to avoid UI breakage on transient API/parse errors.53- If CSV headers are invalid, the workflow terminates immediately and the UI shows a validation error.54- After summarization, the workflow can short-circuit to `END` if the transcript is too short or the model output is missing/empty.55 56### Agent Classes57 581. **`IntakeAgent` (`src/agents/IntakeAgent.py`)**59   - *Entry Point*.60   - Reads the uploaded file, validates the file format and schema, extracts basic metadata, and runs a first-pass clean-up (using an LLM).61   - **CSV requirement:** headers must include `id` and `transcript` (case-insensitive).62   - **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.63 642. **`Router` (`src/agents/Router.py`)**65   - *Conditional Routing Node*.66   - Determines the next step based on the file type and intake validation state.67   - **If Audio (`.mp3`, `.wav`)**: Routes to the `TranscriptionAgent`.68   - **If Text (`.csv`)**: Routes to the `ModerationAgent` then summarization/scoring.69   - **If CSV invalid**: Routes to `END` (the UI displays `metadata.intake_error`).70 71   **`PostSummarizeRouter` (`src/agents/Router.py`)**72   - Routes based on model output quality (e.g., short transcript or missing summary can skip scoring).73 743. **`TranscriptionAgent` (`src/agents/TranscriptionAgent.py`)**75   - Utilizes `openai-whisper` to convert audio files into text.76   - Also scrubs the resulting transcript of profanity before passing it down the pipeline.77 784. **`ModerationAgent` (`src/agents/ModerationAgent.py`)**79   - Receives text either directly from the `Router` (if text upload) or from the `TranscriptionAgent` (if audio upload).80   - Identifies any obscene words or profanity using an LLM and replaces them entirely with a `***` mask to safely prepare the text for downstream analysis.81 825. **`SummarizationAgent` (`src/agents/SummarizationAgent.py`)**83   - Takes the redacted text from the `ModerationAgent`.84   - Generates a concise **summary**, **key points**, **action items**, **tags**, and **highlights** using OpenAI (`gpt-4o`) with Pydantic-structured output.85 866. **`QualityScoringAgent` (`src/agents/QualityScoringAgent.py`)**87   - Takes the clean text and evaluates it against a predefined rubric.88   - 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 (`***`).89 90## Prerequisites91 92- Python 3.9+93- An OpenAI API key94- `ffmpeg` installed on your system (required for `openai-whisper` audio transcription). 95  - On macOS: `brew install ffmpeg`96  - On Ubuntu/Debian: `sudo apt update && sudo apt install ffmpeg`97 98## Installation99 1001. Create a virtual environment and activate it (if you haven't already):101   ```bash102   python3 -m venv .venv103   source .venv/bin/activate104   ```1052. Install the required dependencies:106   ```bash107   pip install -r requirements.txt108   ```109 110## Running the Application111 1121. Ensure your OpenAI API key is set in your environment variables:113   ```bash114   export OPENAI_API_KEY="your_api_key_here"115   ```116 1172. Start the Streamlit application:118   ```bash119   streamlit run src/streamlit_app.py120   ```121 1223. Open your browser to the local URL provided by Streamlit (usually `http://localhost:8501`).1234. Use the sidebar to upload a `.csv`, `.mp3`, or `.wav` file and watch the agents analyze your data!124 125## Processed Files126 127**Note:** The following sample data can be used for analysis:128- [Customer Call Center Dataset Analysis](https://www.kaggle.com/datasets/rafaqatkhan608/customer-call-center-dataset-analysis/code/data)129- [E-commerce Customer Support English Audio](https://huggingface.co/datasets/HumynLabs/e-commerce-customersupport-english-audio/tree/main)130