A sophisticated AI workflow to analyze the "health" of business communications and provide actionable insights for improvement.
This project implements an analysis system based on LangGraph and Claude Sonnet 4.5 that evaluates communications across 7 key dimensions:
- Emotional Tone (20%) - Negative sentiment β Neutral β Positive
- Clarity (20%) - Ambiguous β Clear and specific
- Engagement (5%) - Disengaged β Highly participative
- Respect/Professionalism (20%) - Disrespectful β Highly professional
- Productivity (15%) - Off-topic β Results-oriented
- Alignment (15%) - Strong disagreement β Full consensus
- Response Speed (5%) - Delayed β Timely
The workflow follows a linear pipeline with conditional branching:
START β Input Validator β [Conditional Routing] β Conversation Preprocessor
β Multi-Dimensional Analyzer β Critical Moments Detector β Timeline Builder
β Aggregator & Scorer β Explainer β Output Formatter β END
- 8 workflow nodes: 4 with LLM (parsing, analysis, detection, explanation), 4 deterministic
- Multi-Model Strategy: Optimized Claude models for each task (Haiku 4.5, Sonnet 4.5)
- Pydantic v2 Models: Structured output validation
- LangGraph: Workflow orchestration
The system uses a multi-model strategy to optimize costs and quality:
| Node | Model | Temp | Max Tokens | Rationale |
|---|---|---|---|---|
| Conversation Preprocessor | Claude Haiku 4.5 | 0.0 | 4096 | Fast and cost-effective parsing for all conversation types (email, chat, meetings). Temperature 0.0 ensures maximum precision and consistency in structured output extraction. Haiku 4.5 is 40% faster and 50% cheaper than Sonnet while maintaining excellent accuracy for structured parsing tasks. |
| Dimensional Analyzer | Claude Sonnet 4.5 | 0.2 | 8000 | High-quality multi-dimensional scoring requiring deep understanding of communication nuances. Temperature 0.2 balances consistency with slight flexibility for edge cases. Increased max_tokens (8000) handles complex output: 7 dimensions Γ N messages with detailed reasoning per score. Sonnet 4.5's superior reasoning capabilities ensure accurate evaluation across all dimensions. |
| Critical Moments Detector | Claude Sonnet 4.5 | 0.3 | 6000 | Pattern detection requiring creative insight to identify tension spikes, breakthroughs, deadlocks, misalignments, and positive turns. Temperature 0.3 allows slight creativity while maintaining reliability. Sonnet 4.5's advanced pattern recognition excels at detecting subtle communication shifts that simpler models might miss. |
| Explainer | Claude Sonnet 4.5 | 0.4 | 6000 | Professional-quality text generation for executive summaries, key findings, and actionable recommendations. Temperature 0.4 balances consistency with natural language variety. Sonnet 4.5 produces clear, well-structured explanations that stakeholders can immediately act upon. |
- Python 3.11+
- ANTHROPIC_API_KEY
cd varolio-assignmentpython -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate# For production use
pip install -r requirements.txt
# For development (includes testing and quality tools)
pip install -r requirements-dev.txtNote: The pyproject.toml file contains only tool configurations (Black, Ruff, Mypy, pytest). Dependencies are managed via requirements.txt files.
cp .env.example .env
# Edit .env and add your ANTHROPIC_API_KEYRun the main script:
python main.pyThe script will prompt you for the input file path:
Enter file path: examples/email_thread_positive.txt
The analysis results will be:
- Displayed in the terminal with a formatted summary
- Saved as JSON in
outputs/output_{timestamp}.json
Supported input formats:
- Email threads (with
From:/To:headers) - Meeting transcripts (with
Speaker:dialogue format) - Chat conversations
langgraph devThis will start LangGraph Studio with a visual interface to test the workflow.
The workflow produces a structured JSON with:
- Analysis timestamp
- Participants
- Conversation duration
- Overall health score (0-1)
- Category (excellent/good/fair/poor)
- Scores per dimension
- Top 2 strengths
- Top 2 areas for improvement
- Critical Moments: Key moments (tension spike, breakthrough, deadlock, etc.)
- Timeline: Communication evolution over time (quartiles)
- Per-Message Scores: Detailed scores for each message
- Executive summary (2-3 paragraphs)
- 3-5 key findings
- 2-5 prioritized recommendations with actionable steps
- Positive aspects to maintain
- Observed communication patterns
The project includes a comprehensive test suite with 240 tests covering all system components:
- 186 unit tests (77.5%) - Fast, no API calls required
- 54 integration tests (22.5%) - Require ANTHROPIC_API_KEY
- Unit Tests (tests/unit/): Tests for deterministic nodes, config, schemas, state, graph
- Integration Tests (tests/integration/): End-to-end tests, error handling, edge cases, advanced scenarios
- Shared Fixtures (tests/conftest.py): 20+ reusable fixtures for conversations, state, etc.
- Coverage: ~95% overall, 95-100% on critical components
# All unit tests
pytest tests/unit/ -v
# Specific tests
pytest tests/unit/test_input_validator.py -v
pytest tests/unit/test_prompts.py -v
pytest tests/unit/test_graph.py -v
pytest tests/unit/test_state.py -v# All integration tests
pytest tests/integration/ -v -m integration
# Specific tests
pytest tests/integration/test_workflow_integration.py -v
pytest tests/integration/test_error_handling.py -v# Run all tests (unit + integration)
pytest tests/ -v
# Run only unit tests (skip integration)
pytest tests/ -v -m "not integration"# Generate coverage report
pytest tests/ --cov=src --cov-report=html
# Open HTML report
open htmlcov/index.html # macOS/Linux
start htmlcov\index.html # Windowsvarolio-assignment/
βββ src/
β βββ config/ # Configuration and constants
β β βββ settings.py # Dimension weights, thresholds, LLM config
β β βββ logger.py # Logging setup
β βββ models/ # Pydantic models and state
β β βββ schemas.py # All Pydantic models
β β βββ state.py # WorkflowState TypedDict
β βββ workflow/
β βββ nodes/ # 8 workflow nodes
β β βββ input_validator.py
β β βββ conversation_preprocessor.py
β β βββ dimensional_analyzer.py
β β βββ critical_moments.py
β β βββ timeline_builder.py
β β βββ aggregator_scorer.py
β β βββ explainer.py
β β βββ output_formatter.py
β βββ prompts/ # Prompt templates for LLM nodes
β βββ graph.py # LangGraph orchestration
βββ tests/
β βββ conftest.py # Shared pytest fixtures (20+ fixtures)
β βββ unit/ # Unit tests for deterministic nodes (10 files)
β βββ integration/ # Integration tests and edge cases (4 files)
βββ examples/
β βββ run_analysis.py # Example script
βββ pyproject.toml # Dependencies and config
βββ langgraph.json # LangGraph Studio config
βββ README.md
Edit src/config/settings.py:
DIMENSION_WEIGHTS = {
"emotional_tone": 0.25, # Increase weight
"clarity": 0.20,
# ...
}TEMPERATURES = {
"conversation_preprocessor": 0.0,
"dimensional_analyzer": 0.3, # Increase creativity
# ...
}HEALTH_THRESHOLDS = {
"excellent": 0.85, # Make more stringent
"good": 0.70,
# ...
}- Input too short: Validation with minimum length
- Insufficient messages: Minimum 2 messages required
- Missing timestamps: Sequential creation with flag
- Multilingual content: Processed by Claude (native support)
- Single participant: Neutral scores for non-applicable dimensions
langgraph>=0.2.0- Workflow orchestrationlangchain-anthropic>=0.2.0- Claude integrationpydantic>=2.0.0- Data validationpython-dotenv>=1.0.0- Environment variable management