Skip to content

tannerchung/ticket-sum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

156 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Support Ticket Summarizer v2.2

A sophisticated Python-powered multi-agent AI system for intelligent customer support ticket processing, leveraging advanced collaborative intelligence and comprehensive telemetry.

Overview

This application implements a collaborative multi-agent GenAI system for customer support automation using CrewAI. The system features four specialized AI agents (Triage Specialist, Ticket Analyst, Support Strategist, QA Reviewer) that work collaboratively with authentic consensus building, dynamic quality evaluation, and comprehensive monitoring through Langfuse Cloud tracing integration.

Key Features ✨

🤖 Advanced Multi-Agent Architecture

  • Triage Specialist: Fast, accurate ticket classification with intent and severity analysis
  • Ticket Analyst: Deep content analysis and comprehensive summarization
  • Support Strategist: Strategic response planning and escalation decisions
  • QA Reviewer: Quality validation and consensus building across all agents

🔀 Multi-Provider AI Support

  • OpenAI Models: GPT-4o, GPT-4o-mini, GPT-3.5-turbo for reliable performance
  • Anthropic Models: Claude 3.5 Sonnet, Claude 3.5 Haiku, Claude 3 Opus for thoughtful reasoning
  • Cohere Models: Command R, Command R+, Command for business-focused analysis
  • Dynamic Model Assignment: Each agent can use different models optimized for their specific tasks

🎯 Authentic Collaboration Features

  • Real Consensus Building: Genuine agent disagreement detection and resolution
  • Custom Faithfulness Scoring: GPT-4o-based evaluation comparing outputs to source content
  • Dynamic Conflict Resolution: Tracks actual conflicts between agents and resolution methods
  • Collaboration Metrics: Authentic measurement of agent agreement and consensus strength

🚀 High-Performance Parallel Processing

  • Concurrent Ticket Processing: Process up to 10 tickets simultaneously with async/await architecture
  • Configurable Concurrency: Adjustable parallel processing settings (1-10 concurrent operations)
  • Intelligent Load Balancing: Semaphore-controlled resource management with thread pool optimization
  • Performance Metrics: Real-time speedup tracking with 3-5x throughput improvements
  • Bulk Database Operations: Optimized batch saves for enhanced database performance

🌐 Interactive Web Interface

  • Real-time Dashboard: Live agent status monitoring with processing indicators
  • Parallel Processing Controls: Toggle between sequential and concurrent processing modes
  • Model Management Hub: Dynamic model swapping per agent without system restart
  • Performance Analytics: Comparative analysis of different AI models across test tickets
  • Database Analytics: Historical insights with interactive Plotly charts and trend analysis

📊 Comprehensive Monitoring & Observability

  • Langfuse Cloud Integration: Complete tracing of all agent interactions with OpenInference instrumentation and intelligent session management
  • Dynamic Quality Assessment: Real-time DeepEval metrics with authentic faithfulness evaluation using GPT-4o
  • Session Management: individual sessions for single tickets, shared sessions for batch processing
  • PostgreSQL Analytics: Persistent storage with performance metrics, collaboration tracking, and historical analysis
  • Real-time Collaboration Tracking: Live monitoring of agent consensus building and conflict resolution with enhanced telemetry

🧠 Advanced Analytics Platform (v2.3.0)

  • Collaboration Intelligence Dashboard: Measures authentic disagreement vs rubber-stamping with 0-1 scoring
  • Cost-Quality Optimization Analytics: Intelligent model selection with complexity-based routing and savings predictions
  • Production Observability Platform: Enterprise-grade monitoring with anomaly detection and automated alerting
  • Agent Influence Network Mapping: Quantifies decision influence patterns across multi-agent collaborations
  • Information Flow Fidelity Analysis: Tracks entity preservation, value addition, and fact distortion
  • Predictive Performance Modeling: Forecasts collaboration outcomes and optimization opportunities

Technology Stack 🛠️

  • Multi-Agent Framework: CrewAI with collaborative task orchestration and async parallel processing
  • Parallel Processing: asyncio, ThreadPoolExecutor for concurrent ticket evaluation with semaphore-controlled concurrency
  • AI Providers: OpenAI (GPT-4o), Anthropic (Claude 3.5), Cohere (Command R) with fallback support
  • Database: PostgreSQL with SQLAlchemy, connection pooling, and bulk operations optimization
  • Web Interface: Streamlit with real-time updates, interactive dashboards, and parallel processing controls
  • Observability: Langfuse Cloud with OpenInference instrumentation and intelligent session management
  • Quality Assessment: DeepEval integration with dynamic metrics and custom faithfulness evaluation
  • Data Processing: pandas, kagglehub for dataset management with concurrent batch processing
  • Visualization: Plotly for interactive charts and performance analytics

Version History & Release Journey 📈

v2.3.0 - Advanced Analytics Platform Implementation (August 4, 2025)

Analytics Revolution: Enterprise-Grade Collaboration Intelligence & Cost Optimization

Comprehensive Analytics Tooling Refactor

  • 🧠 Enhanced Collaboration Analytics: Sophisticated measurement of authentic multi-agent collaboration
    • Disagreement Authenticity Detection: Distinguishes genuine peer review from rubber-stamping (0-1 scoring)
    • Information Flow Fidelity Analysis: Tracks entity preservation, value addition, and fact distortion across agent handoffs
    • Collaborative Intelligence Scoring: Measures emergent intelligence beyond individual agent capabilities
    • Agent Influence Network Mapping: Quantifies how agents affect each other's decisions
  • 💰 Cost-Quality Optimization Analytics: Intelligent model selection and efficiency analysis
    • Complexity-Based Routing: Automatic model assignment based on ticket complexity analysis
    • Cost-per-Quality-Point Optimization: Real-time cost efficiency analysis with savings predictions
    • Model Efficiency Scoring: Performance tracking across OpenAI, Anthropic, and Cohere models
    • Optimization Opportunity Detection: Automated identification of cost reduction possibilities
  • 🚀 Production Observability Platform: Enterprise-grade monitoring and alerting
    • Real-Time Metrics Dashboard: Comprehensive system health monitoring with anomaly detection
    • Automated Performance Optimization: Self-improving system capabilities with predictive modeling
    • Alert Configuration System: Proactive issue detection with actionable recommendations
    • Advanced Visualization Engine: Production-ready dashboards with agent interaction networks

Technical Infrastructure Enhancements

  • Database Schema Enhancement: Added 12 new analytics fields for advanced collaboration and cost tracking
  • Advanced Dashboard Integration: 4-tab analytics interface (Traditional, Collaboration Intelligence, Cost Optimization, Production Observability)
  • Fallback Compatibility: Graceful degradation when sklearn dependencies unavailable
  • Error Resilience: Comprehensive error handling for database queries and analytics processing
  • Performance Optimization: Sub-second analytics updates for real-time dashboard responsiveness

Key Advanced Features

  • Collaboration Intelligence Scoring: 0-1 authenticity scores for disagreement quality and consensus building
  • Information Synthesis Quality: Measures collaborative value vs individual performance
  • Predictive Cost Modeling: Forecasts optimal configurations for cost-quality balance
  • Agent Specialization Metrics: Model performance tracking per agent role
  • Production Alerting: Automated detection of error rates, processing delays, and quality degradation

v2.2 - High-Performance Parallel Processing

Performance Revolution: Concurrent Ticket Evaluation with 3-5x Speedup

Major Performance Enhancements

  • 🚀 Async Parallel Processing: Complete async/await implementation for concurrent ticket evaluation
  • Configurable Concurrency: Process 1-10 tickets simultaneously with semaphore-controlled resource management
  • 🎯 Thread Pool Optimization: ThreadPoolExecutor integration for optimal resource utilization
  • 📊 Real-time Performance Metrics: Live speedup tracking with actual vs estimated throughput measurement

Infrastructure Improvements

  • Database Connection Pooling: Thread-safe database operations with bulk save optimizations
  • Bulk Transaction Processing: 70% faster database saves with single-transaction bulk operations
  • Error Resilience: Failed tickets don't block batch processing with graceful exception handling
  • Resource Management: Intelligent load balancing prevents API rate limiting and memory overflow

User Experience Enhancements

  • Interactive Parallel Controls: Toggle between sequential and parallel processing with live settings
  • Performance Dashboard: Real-time speedup metrics and processing mode indicators
  • Batch Processing Optimization: Enhanced CSV upload and Kaggle dataset processing with parallel execution
  • Progress Tracking: Live status updates for both sequential and concurrent processing modes

Technical Architecture

  • Semaphore-Controlled Concurrency: Prevents resource exhaustion while maximizing throughput
  • Async Streamlit Integration: Custom async wrapper for running concurrent operations in Streamlit
  • Backwards Compatibility: Maintains all existing single-ticket processing functionality
  • Performance Benchmarking: Built-in comparison tools for measuring parallel vs sequential performance

v2.1 - Advanced Telemetry & Quality Assessment

Critical Migration: LangSmith → Langfuse Cloud + Enhanced Session Management

Major Breaking Changes & Migrations

  • 🔄 LangSmith to Langfuse Migration: Complete telemetry overhaul due to CrewAI 0.80+ incompatibility with LangSmith callbacks
  • 🔧 OpenInference Instrumentation: Replaced custom LangSmith integration with OpenTelemetry-based tracing for better CrewAI compatibility
  • 📊 DeepEval Metrics Fix: Resolved hardcoded evaluation scores, now showing real-time dynamic metrics (Hallucination, Relevancy, Faithfulness)
  • 🎯 Intelligent Session Management: Implemented batch sessions - individual tickets get unique sessions, batch processing shares session IDs

Critical Technical Fixes

  • CrewAI Compatibility Crisis: LangSmith callback system incompatible with CrewAI 0.80+, causing trace failures
  • DeepEval Integration Issues: Fixed subscription to get actual dynamic scores instead of placeholder values
  • Session Tracking Logic: Optimized for Langfuse dashboard organization with batch vs individual processing separation
  • Database Schema Reset: Complete cleanup for fresh analytics tracking with enhanced collaboration metrics

Telemetry Architecture Revolution

  • Langfuse Cloud Integration: Full OTLP exporter setup with automatic trace capture via OpenInference
  • Per-Run Session IDs: Individual tickets = unique sessions, batch processing = shared session per batch
  • Enhanced Trace Context: Comprehensive metadata including processing type, agent count, and collaboration metrics
  • Automatic Instrumentation: No manual callback management - OpenInference handles all LLM trace capture

Quality Assessment Improvements

  • Dynamic DeepEval Scores: Real-time hallucination (1.000), relevancy (1.000), faithfulness (0.600) calculation
  • Custom Faithfulness Pipeline: GPT-4o-based fact-checking with fallback mechanisms for offline scenarios
  • Enhanced Collaboration Tracking: Authentic disagreement detection and consensus building metrics
  • Database Analytics Refresh: Clean slate for accurate performance tracking and quality trends

v2.0 - Collaborative Intelligence Era (Previous)

Major Architecture Evolution: From Sequential to Collaborative Processing

Core Breakthroughs

  • Authentic Multi-Agent Collaboration: Transformed from sequential agent processing to genuine collaborative intelligence with real consensus building
  • Custom Faithfulness Evaluation: Revolutionary GPT-4o-based fact-checking system that validates agent outputs against source content
  • Multi-Provider AI Ecosystem: Complete integration of OpenAI, Anthropic, and Cohere with dynamic model assignment per agent
  • LangSmith Integration: Advanced observability with comprehensive tracing (later migrated to Langfuse in v2.1)
  • Real-Time Collaboration Metrics: Authentic disagreement detection, conflict resolution tracking, and consensus strength measurement

Technical Innovations

  • Dynamic Model Management: Hot-swappable AI models per agent without system restart
  • Collaborative Memory System: Shared context and knowledge building across agent interactions
  • Performance Analytics Framework: Comprehensive model comparison with weighted scoring (70% accuracy, 30% speed)
  • Database Analytics Engine: Historical insights with interactive Plotly visualizations
  • Robust Error Handling: JSON serialization fixes and database constraint validation

Latest Enhancements (2025)

  • Enhanced Performance Analytics: Real processing time tracking for accurate agent performance monitoring
  • Improved Accuracy: Better extraction of severity levels, priorities, and action recommendations
  • Quality Assessment: Real-time evaluation metrics with authentic DeepEval integration
  • Multi-Model Support: Seamless switching between OpenAI, Anthropic, and Cohere models

v1.5 - Enhanced Processing & Monitoring

Foundation Building: Observability and Quality Assessment

Key Additions

  • 🔍 LangSmith Integration: Advanced tracing and logging
  • 📊 PostgreSQL Database: Persistent storage for tickets, processing logs, and evaluations
  • 🎯 Quality Metrics: Basic DeepEval integration for response quality assessment
  • 📈 Streamlit Interface: Interactive web dashboard for real-time monitoring
  • 🗃️ Kaggle Integration: Automated dataset downloading and processing capabilities

Technical Improvements

  • Database Schema Design: Comprehensive models for tickets, logs, and agent status
  • Progress Tracking: Real-time updates during ticket processing workflows
  • Error Handling: Initial robust error management and logging systems
  • Configuration Management: Centralized config system with environment validation

v1.0 - Multi-Agent Foundation

Genesis: Sequential Multi-Agent Architecture

Original Implementation

  • 🤖 Four-Agent System: Initial CrewAI implementation with specialized roles
    • Classifier Agent: Intent and severity determination
    • Summarizer Agent: Content summarization and key problem identification
    • Action Recommender Agent: Next steps and escalation recommendations
    • QA Agent: Basic output validation and consistency checking

Core Features

  • Sequential Processing: Linear workflow with agents building on previous outputs
  • OpenAI Integration: Single-provider implementation using GPT-4o models
  • CSV Processing: Basic batch processing capabilities for support ticket datasets
  • JSON Output: Structured results with classification, summary, and recommendations
  • Environment Configuration: Basic API key management and validation

Initial Architecture

  • CrewAI Framework: Multi-agent orchestration for customer support automation
  • Python-Based: Core implementation using pandas for data processing
  • Terminal Interface: Command-line execution with progress indicators
  • File-Based Output: JSON results saved to local files for analysis

Development Milestones & Evolution

Version Key Innovation Impact
v1.0 Multi-agent architecture foundation Established specialized AI roles for support automation
v1.5 Observability & persistence layer Added monitoring, database storage, and quality metrics
v2.0 Collaborative intelligence breakthrough Revolutionary authentic agent collaboration with real consensus
v2.1 Advanced telemetry & quality assessment LangSmith → Langfuse migration with enhanced session management
v2.2 High-performance parallel processing 3-5x speedup with concurrent ticket evaluation
v2.3 Advanced analytics platform Enterprise-grade collaboration intelligence & cost optimization

Technical Evolution Timeline

v1.0: Sequential → v1.5: Monitored → v2.0: Collaborative → v2.1: Advanced → v2.2: Parallel → v2.3: Analytics
   ↓                ↓                ↓                    ↓             ↓               ↓
Basic Pipeline   Observability    Authentic            Telemetry      Performance     Intelligence
Single Provider  Database         Collaboration        Migration      Optimization    Platform
File Output      Monitoring       Multi-Provider       Quality        Concurrency     Cost Analytics
Manual Process   Quality Metrics  Consensus Building   Assessment     3-5x Speedup    Observability

This journey represents the evolution from basic multi-agent processing to sophisticated collaborative AI systems with enterprise-grade analytics, authentic collaboration intelligence, and production-ready observability.

Quick Start

Prerequisites

  • Python 3.10+ (3.10.18 recommended) - Required for CrewAI compatibility
  • PostgreSQL database
  • OpenAI API key
  • LangSmith API key (optional, for tracing)
  • Kaggle API credentials (optional, for datasets)

⚠️ Important: Python 3.9 is not compatible with CrewAI 0.152.0 due to union operator syntax requirements.

Environment Variables

Create a .env file with:

OPENAI_API_KEY=your_openai_api_key
DATABASE_URL=your_postgresql_url
LANGFUSE_SECRET_KEY=your_langfuse_secret_key  # Optional
KAGGLE_USERNAME=your_kaggle_username  # Optional
KAGGLE_KEY=your_kaggle_key           # Optional

Installation

# Clone the repository
git clone https://github.com/yourusername/ticket-sum.git
cd ticket-sum

# Activate Python 3.10 environment (REQUIRED)
source venv310/bin/activate

# Verify Python version
python --version  # Should show Python 3.10.18

# Install dependencies
pip install -r requirements-py310.txt

# Run the Streamlit interface
streamlit run streamlit_app.py --server.port 5000

# Or run batch processing
python main.py

Quick Activation: Use the provided activation script:

./activate_python310.sh

📊 Usage

Web Interface

  1. Launch the Streamlit application
  2. Configure parallel processing (Enable parallel processing, set max concurrent tickets 1-10)
  3. Select sample tickets or enter custom support requests
  4. Watch agents collaborate in real-time through the monitoring dashboard
  5. Review detailed analysis, action plans, and quality assessments with performance metrics

Single Ticket Processing

from agents import CollaborativeSupportCrew

# Initialize collaborative crew
crew = CollaborativeSupportCrew()

# Process single ticket
result = crew.process_ticket_collaboratively("TICKET001", "Customer message here")

Parallel Batch Processing

import asyncio
from agents import CollaborativeSupportCrew
from utils import load_ticket_data

# Initialize collaborative crew
crew = CollaborativeSupportCrew()

# Prepare tickets for parallel processing
tickets = [
    {"id": "TICKET001", "content": "First ticket message"},
    {"id": "TICKET002", "content": "Second ticket message"},
    {"id": "TICKET003", "content": "Third ticket message"}
]

# Process tickets in parallel (up to 5 concurrent)
results = asyncio.run(crew.process_tickets_parallel(tickets, max_concurrent=5))

# Sequential processing (for comparison)
results = []
for ticket in tickets:
    result = crew.process_ticket_collaboratively(ticket["id"], ticket["content"])
    results.append(result)

Kaggle Dataset Processing

from utils import load_ticket_data

# Load real customer support data
df = load_ticket_data()

# Process with parallel processing (3-5x faster)
kaggle_tickets = [
    {"id": str(row['ticket_id']), "content": str(row['message'])} 
    for _, row in df.head(20).iterrows()
]
results = asyncio.run(crew.process_tickets_parallel(kaggle_tickets, max_concurrent=5))

⚡ Performance Benchmarks

Parallel Processing Performance

  • Sequential Processing: ~8-12 seconds per ticket
  • Parallel Processing (5 concurrent): 3-5x speedup improvement
  • Optimal Concurrency: 5-7 concurrent tickets for best balance of speed and resource usage
  • Bulk Database Operations: 70% faster database saves with bulk transactions

Processing Throughput

Batch Size Sequential Time Parallel Time (5x) Speedup
5 tickets ~50 seconds ~15 seconds 3.3x
10 tickets ~100 seconds ~25 seconds 4.0x
20 tickets ~200 seconds ~45 seconds 4.4x
50 tickets ~500 seconds ~120 seconds 4.2x

Resource Optimization

  • Memory Usage: Thread pool limits prevent memory overflow
  • API Rate Limiting: Semaphore controls respect AI provider limits
  • Database Connections: Connection pooling with 10 worker threads
  • Error Resilience: Failed tickets don't block batch processing

🏗 Architecture

Collaborative Workflow

  1. Triage Specialist performs initial classification and severity assessment
  2. Ticket Analyst conducts deep analysis and generates comprehensive summaries
  3. Support Strategist develops action plans and strategic recommendations
  4. QA Reviewer validates outputs and ensures consensus across all agents

Data Flow

  • Tickets → Multi-agent processing → Database storage → Analytics dashboard
  • Real-time status updates and collaboration monitoring
  • Comprehensive logging with Langfuse integration
  • Quality assessment with DeepEval metrics

Database Schema

  • support_tickets: Processed ticket data and classifications
  • processing_logs: Detailed agent activity logs
  • quality_evaluations: DeepEval assessment results
  • agent_status: Real-time agent performance metrics

📈 Monitoring & Analytics

  • Agent Performance: Success rates, processing times, collaboration metrics
  • Ticket Analysis: Intent distribution, severity patterns, resolution trends
  • Quality Metrics: Hallucination detection, relevancy scoring, accuracy assessment
  • System Health: Database analytics, error tracking, performance monitoring

🚀 Deployment

The application is designed for flexible deployment with automatic environment configuration:

  • Replit: Automatic setup with integrated database and secrets management
  • Local Development: Full PostgreSQL and environment variable configuration
  • Cloud Platforms: Compatible with major cloud providers (AWS, GCP, Azure)
  • Docker: Containerized deployment ready (Dockerfile included)

Ensure all environment variables are properly configured and PostgreSQL database is accessible.

🤝 Contributing

This project demonstrates advanced multi-agent AI orchestration with practical customer support applications. Contributions are welcome for:

  • Additional AI Provider Integrations: New model providers and capabilities
  • Enhanced Quality Metrics: Advanced evaluation frameworks and scoring systems
  • Agent Specializations: New agent types and collaborative patterns
  • Performance Optimizations: Speed improvements and resource efficiency
  • Integration Extensions: CRM systems, ticketing platforms, and workflow tools

📝 License

This project is available under standard open source licensing terms for educational and demonstration purposes, showcasing advanced AI agent collaboration techniques in customer support automation.

About

Multi-agent AI system for intelligent customer support ticket processing with CrewAI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages