Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Call Transcript Analysis

A FastAPI service that analyzes call center transcripts using the Anthropic Claude API. Submit a transcript and receive a structured QA score, call summary, and sentiment classification.

Features

  • QA Scoring — 1–10 score based on call quality
  • Summarization — 2–3 sentence summary of the call
  • Sentiment Analysispositive, neutral, or negative
  • Structured JSON responses validated with Pydantic
  • Retry logic with exponential backoff for transient API failures
  • JSON structured logging with per-request IDs

Project Structure

app/
├── main.py                  # FastAPI entry point
├── api/
│   ├── routes.py            # POST /analyze-transcript endpoint
│   └── middleware.py        # Request logging middleware
├── services/
│   └── claude_service.py    # Claude API interaction
├── models/
│   └── schemas.py           # Request/response Pydantic models
└── core/
    ├── config.py             # Settings (env-based)
    ├── logging.py            # JSON logger
    └── resilience.py         # Retry decorator

Requirements

Setup

1. Clone and create a virtual environment

git clone <repo-url>
cd call-transcript-analysis
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate

2. Install dependencies

pip install -r requirements.txt

3. Configure environment

cp .env.example .env

Edit .env:

ANTHROPIC_API_KEY=your-api-key-here
CLAUDE_MODEL=claude-sonnet-4-6
CLAUDE_TIMEOUT_SECONDS=30
CLAUDE_MAX_RETRIES=3

Running the Server

uvicorn app.main:app --reload

The API will be available at http://localhost:8000.

Interactive docs: http://localhost:8000/docs

API Reference

POST /analyze-transcript

Analyzes a call center transcript.

Request

{
  "transcript": "Agent: Thank you for calling. How can I help?\nCustomer: ..."
}
Field Type Constraints
transcript string 1–50,000 characters, non-blank

Response 200 OK

{
  "qa_score": 8,
  "summary": "The agent resolved the customer's billing issue efficiently and with a friendly tone.",
  "sentiment": "positive"
}
Field Type Values
qa_score integer 1–10
summary string 1–2 sentence call summary
sentiment string "positive", "neutral", "negative"

Error responses

Status Reason
422 Invalid or missing transcript input
503 Claude API unavailable or misconfigured

Resilience

Transient failures (rate limits, timeouts, server errors) are retried automatically with exponential backoff. The number of retries is controlled by CLAUDE_MAX_RETRIES (default: 3).

Tech Stack

Layer Library
Web framework FastAPI + Uvicorn
Validation Pydantic v2
AI Anthropic SDK (claude-sonnet-4-6)
HTTP client HTTPX
Retry Tenacity
Config pydantic-settings + dotenv

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages