# Ticket Pipeline - Customer Service Agent Demo
A production-ready demonstration of an AI-powered customer service ticket processing pipeline. This project combines LangGraph workflow orchestration, structured output extraction, and external search APIs to automate customer feedback processing.
## Key Features
- **LangGraph Workflow**: Stateful pipeline with search → extract → report flow
- **Structured Output**: Pydantic-validated JSON extraction from unstructured text
- **External Search**: Real web search via Tavily API
- **Retry Mechanism**: Automatic retry on failure
- **Web Interface**: Gradio UI for easy testing
- **Test Suite**: 10 test cases for validation
- **Data Persistence**: SQLite database for storing processed tickets
## Architecture
User Input → Search Node → Extract Node → Report Node → Output ↓ SQLite DB (persistence layer)
## Quick Start
### Prerequisites
- Python 3.10+
- DeepSeek API key
- Tavily API key (for search)
### Installation
```bash
git clone https://github.com/yourusername/ticket-pipeline.git
cd ticket-pipeline
pip install -r requirements.txt
cp .env.example .env
# Edit .env with your API keys
python -m src.mainOpen http://localhost:7860 in your browser.
ticket-pipeline/
├── src/
│ ├── __init__.py
│ ├── state.py # State TypedDict definition
│ ├── nodes.py # Node functions (search, extract, report)
│ ├── graph.py # LangGraph workflow builder
│ ├── main.py # Gradio web application
│ └── storage.py # SQLite database operations
├── tests/
│ └── test_cases.json # Test suite with 10 test cases
├── .env.example # Environment variables template
├── .gitignore # Files to exclude from version control
├── LICENSE # MIT License
├── requirements.txt # Python dependencies
├── README.md # This file
└── tickets.db # Auto-generated SQLite database (not committed)
Note: The SQLite database file tickets.db will be automatically created in the project root directory when you first run the application. It stores processed ticket data and is excluded from version control via .gitignore.
Create a .env file:
DEEPSEEK_API_KEY=your_deepseek_api_key
DEEPSEEK_BASE_URL=https://api.deepseek.com
TAVILY_API_KEY=your_tavily_api_key# Manual test execution:
# 1. Start the application: python -m src.main
# 2. Enter test cases from tests/test_cases.json one by one in the Gradio interface
# 3. Verify that the output JSON matches the expected resultsMIT License - see LICENSE file for details.
一个采用生产级设计思路的 AI 客服工单处理流水线演示项目。该项目结合了 LangGraph 工作流编排、结构化输出提取和外部搜索API,用于自动化处理客户反馈。
- LangGraph 工作流:具有状态管理的流水线,流程为 搜索 → 提取 → 报告
- 结构化输出:通过 Pydantic 验证,从非结构化文本中提取 JSON 数据
- 外部搜索:通过 Tavily API 实现真实的网络搜索
- 重试机制:失败时自动重试
- Web 界面:基于 Gradio 的界面,方便测试
- 测试套件:包含 10 个测试用例用于验证
- 数据持久化:使用 SQLite 数据库存储已处理的工单
用户输入 → 搜索节点 → 提取节点 → 报告节点 → 输出
↓
SQLite 数据库 (独立持久化)
- Python 3.10 或更高版本
- DeepSeek API 密钥
- Tavily API 密钥(用于搜索功能)
git clone https://github.com/你的实际用户名/ticket-pipeline.git
cd ticket-pipeline
pip install -r requirements.txt
cp .env.example .env
# 编辑 .env 文件,填入你的 API 密钥python -m src.main在浏览器中打开 http://localhost:7860。
ticket-pipeline/
├── src/
│ ├── __init__.py # 包标识文件
│ ├── state.py # State TypedDict 定义
│ ├── nodes.py # 节点函数(搜索、提取、报告)
│ ├── graph.py # LangGraph 工作流构建器
│ ├── main.py # Gradio Web 应用
│ └── storage.py # SQLite 数据库操作
├── tests/
│ └── test_cases.json # 包含 10 个测试用例的测试集
├── .env.example # 环境变量模板
├── .gitignore # 版本控制排除文件列表
├── LICENSE # MIT 许可证文件
├── requirements.txt # Python 依赖列表
├── README.md # 项目说明文档
└── tickets.db # 自动生成的 SQLite 数据库(不提交)
注意:首次运行应用时,SQLite 数据库文件 tickets.db 会在项目根目录自动生成。它用于存储已处理的工单数据,并已通过 .gitignore 排除在版本控制之外。
创建 .env 文件:
DEEPSEEK_API_KEY=你的DeepSeek密钥
DEEPSEEK_BASE_URL=https://api.deepseek.com
TAVILY_API_KEY=你的Tavily密钥# 运行测试用例(手动验证)
# 1. 启动应用:python -m src.main
# 2. 在 Gradio 界面中逐个输入 tests/test_cases.json 中的测试用例
# 3. 检查输出的 JSON 是否与预期匹配MIT License - see LICENSE file for details.