出口退税多智能体工作流系统 —— 基于 LangGraph 的智能体协同平台,实现从单证识别到审核报告生成的全流程自动化。
- OCR 单证识别 — 自动识别发票、装箱单、提单等单证,提取结构化字段,多单交叉校验
- HS 编码归类 — Skill 搜索引擎多候选评分排名,OCR 数据库反查,支持交互式编码确认
- 报关单草稿生成 — 结合 LLM 生成申报要素,业务逻辑校验,输出 Excel 草单
- 退税率查询 — 查询商品退税率,计算退税额,合规判定
- 目的国政策分析 — 按目的国路由至专属分析模块,覆盖德国(MFN/反倾销/CBAM/进口增值税)和越南(ACFTA/RCEP/环保税/消费税)
- 审核报告生成 — 汇总 OCR 结果、一致性校验、草单、退税分析和目的国政策,输出完整审核报告
┌─────────────────────────────────────────────────────┐
│ FastAPI 入口 │
│ (app.py, 端口 8000) │
└────────────────────────┬────────────────────────────┘
│
┌──────────▼──────────┐
│ Orchestrator Agent │ 工作流调度中枢
└──────────┬──────────┘
│
┌────────┬────────┬──┴───┬────────┬────────┬────────┐
▼ ▼ ▼ ▼ ▼ ▼ ▼
┌───────┐┌───────┐┌───────┐┌───────┐┌───────┐┌───────┐┌───────┐
│Document││HS Code││HS Sel ││ Draft ││ Tax ││Policy ││Report │
│ Agent ││ Agent ││ Agent ││ Agent ││ Agent ││ Agent ││ Agent │
└───┬───┘└───┬───┘└───┬───┘└───┬───┘└───┬───┘└───┬───┘└───┬───┘
│ │ │ │ │ │ │
▼ ▼ ▼ ▼ ▼ ▼ ▼
┌───────┐┌───────┐ ┌───────┐┌───────┐┌───────┐┌───────┐
│ OCR ││ HS │ │ Draft ││ Tax ││ DE ││ VN │
│ API ││ Search│ │ LLM ││ DB ││Policy ││Policy │
└───────┘└───────┘ └───────┘└───────┘└───────┘└───────┘
工作流链路:
orchestrator → document → hs_code → hs_code_select → draft → tax_refund → policy → report
export_refund_agent/
├── app.py # FastAPI 入口
├── workflow.py # LangGraph StateGraph 定义
├── router.py # 条件路由 & 国家代码映射
├── requirements.txt # 依赖清单
│
├── core/
│ ├── state.py # ExportRefundState TypedDict
│ └── config.py # 全局配置 (OCR / LLM / 路径)
│
├── agents/
│ ├── orchestrator.py # 工作流调度 & 路由决策
│ ├── document_agent.py # OCR 识别 Agent
│ ├── hs_code_agent.py # HS 编码 Skill 搜索排名
│ ├── hs_code_select_agent.py # 交互式编码选择
│ ├── draft_generator_agent.py # 报关单草稿生成
│ ├── tax_refund_agent.py # 退税查询 Agent
│ ├── policy_agent.py # 目的国政策路由
│ └── report_agent.py # 审核报告生成
│
├── tools/
│ ├── ocr_tool.py # OCR API 调用 & 单证解析
│ ├── draft_tool.py # HS 归类 + LLM 申报要素 + Excel 生成
│ ├── tax_refund_tool.py # 退税率查询
│ ├── de_policy_tool.py # 德国关税分析
│ └── vn_policy_tool.py # 越南税收分析
│
└── tests/
├── test_case_germany.py # 铝型材出口德国
└── test_case_vietnam.py # 摩托车出口越南
- Python >= 3.10
pip install -r requirements.txt在项目根目录创建 .env 文件:
LLM_API_KEY=your_api_keypython app.py服务启动在 http://localhost:8000,访问 /docs 查看 Swagger API 文档。
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /health |
健康检查 |
| POST | /workflow/run |
启动工作流 (JSON) |
| POST | /workflow/run/files |
上传文件 + 启动工作流 |
| GET | /workflow/state/{thread_id} |
查询工作流状态 |
新增目的国支持只需三步:
- 在
router.py的COUNTRY_ROUTER添加国家映射 - 在
tools/新增对应政策分析工具 - 在
agents/policy_agent.py添加路由分支
MIT