feat(shipping-notice): 完成货代发货通知全流程开发与代码重构
- 新增PO号提取、预约ID解析(支持`PR@xxx`格式)工具,完善库存匹配逻辑 - 新增库存映射缓存、匹配/解析结果格式化摘要,优化用户提示 - 修复数据库迁移脚本未检查表存在的问题,避免全新部署失败 - 新增路径工具类统一管理相对路径,优化配置文件处理逻辑 - 归档旧文档,将部署、Dify配置合并到`shipping_notice.md` - 新增完整单元测试与集成测试覆盖核心流程 - 更新前端国际化与会话管理逻辑,优化界面交互
This commit is contained in:
1 parent
b62082758b
commit
8deae3146b
65 files changed
+6477
-1937
No files matched your search
@@ -1,5 +1,7 @@
|
||||
# Dify Chatflow 绑定 OpenAPI — 操作手册
|
||||
|
||||
> **已归档**:Dify 配置已合并至 [`shipping_notice.md` §2 Dify 配置(合集)](./shipping_notice.md#2-dify-配置合集)(OpenAPI 与端口见 **§2.1–§2.2**,Chatflow 画布见 **§2.4**)。下文仅作历史参考,请以 §2 为准。
|
||||
|
||||
本文说明如何将 hxops **货代发货通知 Tool API** 绑定到 Dify **Chatflow** 应用「货代发货通知 Agent」。
|
||||
|
||||
---
|
||||
@@ -97,14 +99,14 @@ python seed_shipping_notice_agents.py
|
||||
- API Key 值:与 hxops `SHIPPING_NOTICE_TOOL_API_KEY` 一致
|
||||
|
||||
6. 点击 **测试** / **保存**,确认 8 个工具均解析成功:
|
||||
- `create_case`
|
||||
- `create_task`
|
||||
- `parse_notice`
|
||||
- `ensure_inventory`
|
||||
- `match_inventory`
|
||||
- `submit_decision`
|
||||
- `generate_shipment_excel`
|
||||
- `upload_to_freight`
|
||||
- `get_case_status`
|
||||
- `get_task_status`
|
||||
|
||||
> OpenAPI 已针对 Dify 优化:每个 POST 含 `parameters: []`、扁平 `requestBody` 字段、不含 RPA 回调接口。
|
||||
|
||||
@@ -137,11 +139,11 @@ GET /api/shipping-notice/tools/openapi.dify.yaml
|
||||
|
||||
## 步骤 4:配置系统提示词
|
||||
|
||||
将 `docs/shipping_notice_dify_prompt.md` 中「角色」至「对话风格」段落粘贴到 Chatflow **系统提示词 / Instructions**。
|
||||
将 [`shipping_notice.md` §2.5 Agent 系统指令](./shipping_notice.md#25-agent-系统指令粘贴用) 全文粘贴到 Chatflow Agent 节点 **指令 / Instructions**。
|
||||
|
||||
要点:
|
||||
|
||||
- 必须先 `create_case`,全程携带 `case_id`
|
||||
- 必须先 `create_task`,全程携带 `task_id`
|
||||
- `status=needs_human` 时等待用户选择,勿跳过
|
||||
- `inventory_lines_json` 传 JSON 字符串,例如:`[{"sku":"A001","available_qty":10}]`
|
||||
|
||||
@@ -149,8 +151,8 @@ GET /api/shipping-notice/tools/openapi.dify.yaml
|
||||
|
||||
| 变量 | 用途 |
|
||||
|------|------|
|
||||
| `sys.user_id` / 自定义 `user_id` | 传入 `create_case.user_id` |
|
||||
| `sys.conversation_id` | 传入 `create_case.conversation_id` |
|
||||
| `sys.user_id` / 自定义 `user_id` | 传入 `create_task.user_id` |
|
||||
| `sys.conversation_id` | 传入 `create_task.conversation_id` |
|
||||
|
||||
---
|
||||
|
||||
@@ -165,9 +167,9 @@ GET /api/shipping-notice/tools/openapi.dify.yaml
|
||||
```
|
||||
|
||||
4. 在 Dify **日志** 中确认 Agent 依次调用:
|
||||
- `create_case` → `parse_notice` → `ensure_inventory` → …
|
||||
- `create_task` → `parse_notice` → `ensure_inventory` → …
|
||||
|
||||
5. 工作台 **货代发货** 应出现新 case;状态为 `running` 时表示 RPA 进行中,可 `get_case_status` 轮询。
|
||||
5. 工作台 **货代发货** 应出现新 task;状态为 `running` 时表示 RPA 进行中,可 `get_task_status` 轮询。
|
||||
|
||||
---
|
||||
|
||||
@@ -207,5 +209,5 @@ GET /api/shipping-notice/tools/openapi.dify.yaml
|
||||
|------|------|
|
||||
| `backend/app/services/shipping_notice/openapi_spec.py` | Dify 兼容 OpenAPI 生成 |
|
||||
| `GET /api/shipping-notice/tools/openapi.json` | 动态 spec(含绝对 server URL) |
|
||||
| `docs/shipping_notice_dify_prompt.md` | 系统提示词 |
|
||||
| `docs/shipping_notice_runbook.md` | 整体部署 Runbook |
|
||||
| `docs/shipping_notice.md` §2 | Dify 配置合集(OpenAPI、Workflow、画布、Agent 指令) |
|
||||
| `docs/shipping_notice_runbook.md` | 精简部署 Runbook(Dify 见 §2) |
|
||||
Reference in new issue
Block a user