511 lines
14 KiB
JSON
511 lines
14 KiB
JSON
{
|
|
"template_kind": "hxops_shipping_notice_chatflow_delivery_template",
|
|
"template_version": "2026-06-17",
|
|
"template_status": "manual-import-required",
|
|
"app": {
|
|
"name": "货代发货通知 Agent",
|
|
"mode": "advanced-chat",
|
|
"description": "Hxops 货代发货通知 Chatflow 交付模板。用于在 Dify 画布中手工还原节点、变量、HTTP 调用和 Agent 配置。",
|
|
"icon": "truck",
|
|
"icon_background": "#E0F2FE"
|
|
},
|
|
"delivery_notes": [
|
|
"本文件是仓库侧交付模板,不是从 Dify 控制台实际导出的原生 DSL。",
|
|
"实际发布前,仍应在 Dify 中完成节点配置后导出一份官方 DSL 作为最终交付包。",
|
|
"Tool API 契约以 docs/openapi/shipping_notice_tools.dify.json 和 backend/app/services/shipping_notice/openapi_spec.py 为准。",
|
|
"Agent Prompt、节点职责与 HTTP 示例以 docs/shipping_notice.md 为准。"
|
|
],
|
|
"tool_openapi": {
|
|
"runtime_import_url": "{{HXOPS_TOOLS_API_BASE}}/api/shipping-notice/tools/openapi.json",
|
|
"repo_import_file": "docs/openapi/shipping_notice_tools.dify.json",
|
|
"auth": {
|
|
"header_name": "X-Shipping-Tool-Key",
|
|
"value_from_env": "SHIPPING_NOTICE_TOOL_API_KEY"
|
|
}
|
|
},
|
|
"environment_variables": [
|
|
{
|
|
"name": "HXOPS_API_BASE",
|
|
"type": "string",
|
|
"required": true,
|
|
"example": "http://192.168.100.192:8890"
|
|
},
|
|
{
|
|
"name": "SHIPPING_NOTICE_TOOL_API_KEY",
|
|
"type": "secret",
|
|
"required": true,
|
|
"example": "your-tool-key"
|
|
},
|
|
{
|
|
"name": "HXOPS_TOOLS_API_BASE",
|
|
"type": "string",
|
|
"required": true,
|
|
"example": "http://192.168.100.192:8890"
|
|
}
|
|
],
|
|
"conversation_variables": [
|
|
{
|
|
"name": "current_batch_no",
|
|
"type": "string",
|
|
"description": "当前批次号"
|
|
},
|
|
{
|
|
"name": "current_task_no",
|
|
"type": "string",
|
|
"description": "当前聚焦任务号"
|
|
},
|
|
{
|
|
"name": "current_task_step",
|
|
"type": "string",
|
|
"description": "当前任务步骤"
|
|
},
|
|
{
|
|
"name": "current_checkpoint",
|
|
"type": "string",
|
|
"description": "当前人工节点 / checkpoint"
|
|
},
|
|
{
|
|
"name": "current_task_status",
|
|
"type": "string",
|
|
"description": "当前任务 process_status"
|
|
},
|
|
{
|
|
"name": "batch_queue_summary",
|
|
"type": "string",
|
|
"description": "批次摘要文案"
|
|
},
|
|
{
|
|
"name": "last_tool_status",
|
|
"type": "string",
|
|
"description": "最近一次 Tool 调用状态"
|
|
}
|
|
],
|
|
"graph": {
|
|
"entry_node_id": "start",
|
|
"answer_node_id": "answer_final",
|
|
"nodes": [
|
|
{
|
|
"id": "start",
|
|
"type": "start",
|
|
"title": "开始",
|
|
"outputs": [
|
|
"query",
|
|
"files",
|
|
"conversation_id"
|
|
],
|
|
"doc_anchor": "docs/shipping_notice.md#L471-L480"
|
|
},
|
|
{
|
|
"id": "ctx_preprocess",
|
|
"type": "code",
|
|
"title": "预处理上下文",
|
|
"script_ref": "docs/shipping_notice.md#L481-L523",
|
|
"outputs": [
|
|
"normalized_query",
|
|
"detected_batch_no",
|
|
"detected_task_no",
|
|
"intent_hint",
|
|
"has_files",
|
|
"error_message"
|
|
]
|
|
},
|
|
{
|
|
"id": "route_classifier",
|
|
"type": "code",
|
|
"title": "附件/意图分类",
|
|
"script_ref": "docs/shipping_notice.md#L525-L550",
|
|
"outputs": [
|
|
"route_key",
|
|
"reason"
|
|
]
|
|
},
|
|
{
|
|
"id": "tool_create_batch",
|
|
"type": "tool",
|
|
"title": "创建批次",
|
|
"operation_id": "create_batch",
|
|
"when": "route_key == notice_batch_upload",
|
|
"inputs": {
|
|
"conversation_id": "{{conversation_id}}",
|
|
"file_count": "{{files.length}}"
|
|
}
|
|
},
|
|
{
|
|
"id": "iter_notice_files",
|
|
"type": "iteration",
|
|
"title": "文件循环器",
|
|
"when": "route_key == notice_batch_upload",
|
|
"iterates": "files",
|
|
"doc_anchor": "docs/shipping_notice.md#L442-L449"
|
|
},
|
|
{
|
|
"id": "tool_create_task",
|
|
"type": "tool",
|
|
"title": "创建单个任务",
|
|
"operation_id": "create_task",
|
|
"inputs": {
|
|
"batch_no": "{{current_batch_no}}",
|
|
"conversation_id": "{{conversation_id}}",
|
|
"source_type": "pdf",
|
|
"source_file_name": "{{iter_notice_files.item.name}}",
|
|
"source_file_type": "{{iter_notice_files.item.mime_type}}",
|
|
"batch_index": "{{iter_notice_files.index}}",
|
|
"batch_total": "{{files.length}}"
|
|
}
|
|
},
|
|
{
|
|
"id": "http_extract_notice_text",
|
|
"type": "http",
|
|
"title": "文本抽取",
|
|
"method": "external_or_frontend",
|
|
"notes": [
|
|
"由前端或 HTTP 节点完成原文抽取。",
|
|
"抽取出的 raw_text 继续传给 LLM字段抽取 / parse_notice。"
|
|
]
|
|
},
|
|
{
|
|
"id": "llm_extract_notice",
|
|
"type": "llm",
|
|
"title": "LLM字段抽取",
|
|
"prompt_ref": "docs/shipping_notice.md#L733-L778",
|
|
"outputs": [
|
|
"llm_json_text"
|
|
]
|
|
},
|
|
{
|
|
"id": "code_validate_notice_json",
|
|
"type": "code",
|
|
"title": "抽取结果校验",
|
|
"script_ref": "docs/shipping_notice.md#L567-L594",
|
|
"outputs": [
|
|
"validated_json",
|
|
"is_valid",
|
|
"error_message"
|
|
]
|
|
},
|
|
{
|
|
"id": "tool_parse_notice",
|
|
"type": "tool",
|
|
"title": "保存解析结果",
|
|
"operation_id": "parse_notice",
|
|
"inputs": {
|
|
"task_id": "{{tool_create_task.text.task_id}}",
|
|
"raw_text": "{{http_extract_notice_text.text}}"
|
|
}
|
|
},
|
|
{
|
|
"id": "code_batch_summary",
|
|
"type": "code",
|
|
"title": "批次摘要组装",
|
|
"script_ref": "docs/shipping_notice.md#L596-L621",
|
|
"outputs": [
|
|
"batch_queue_summary",
|
|
"focus_task_no"
|
|
]
|
|
},
|
|
{
|
|
"id": "code_set_focus_task",
|
|
"type": "code",
|
|
"title": "设置当前聚焦任务",
|
|
"writes_variables": [
|
|
"current_batch_no",
|
|
"current_task_no"
|
|
]
|
|
},
|
|
{
|
|
"id": "tool_get_task_status_init",
|
|
"type": "tool",
|
|
"title": "读取当前任务状态",
|
|
"operation_id": "get_task_status",
|
|
"inputs": {
|
|
"task_id": "{{current_task_no}}",
|
|
"conversation_id": "{{conversation_id}}"
|
|
}
|
|
},
|
|
{
|
|
"id": "http_upload_inventory",
|
|
"type": "http",
|
|
"title": "上传库存文件",
|
|
"request_ref": "docs/shipping_notice.md#L271-L310",
|
|
"method": "POST",
|
|
"url": "{{HXOPS_API_BASE}}/api/shipping-notice/tools/upload_inventory_file",
|
|
"headers": {
|
|
"X-Shipping-Tool-Key": "{{SHIPPING_NOTICE_TOOL_API_KEY}}"
|
|
},
|
|
"body_type": "multipart/form-data",
|
|
"body": {
|
|
"task_id": "{{current_task_no}}",
|
|
"file": "{{files[0]}}"
|
|
}
|
|
},
|
|
{
|
|
"id": "tool_schema_preview",
|
|
"type": "tool",
|
|
"title": "读取 schema preview",
|
|
"operation_id": "get_inventory_schema_preview",
|
|
"inputs": {
|
|
"task_id": "{{current_task_no}}"
|
|
}
|
|
},
|
|
{
|
|
"id": "llm_map_inventory",
|
|
"type": "llm",
|
|
"title": "LLM字段映射建议",
|
|
"prompt_ref": "docs/shipping_notice.md#L780-L815",
|
|
"outputs": [
|
|
"mapping_json_text"
|
|
]
|
|
},
|
|
{
|
|
"id": "code_validate_mapping",
|
|
"type": "code",
|
|
"title": "映射 JSON 校验",
|
|
"script_ref": "docs/shipping_notice.md#L651-L678",
|
|
"outputs": [
|
|
"mapping_json",
|
|
"is_valid",
|
|
"error_message"
|
|
]
|
|
},
|
|
{
|
|
"id": "tool_apply_mapping",
|
|
"type": "tool",
|
|
"title": "应用字段映射",
|
|
"operation_id": "apply_inventory_mapping",
|
|
"inputs": {
|
|
"task_id": "{{current_task_no}}",
|
|
"map_json": "{{code_validate_mapping.mapping_json}}"
|
|
}
|
|
},
|
|
{
|
|
"id": "code_alignment_result",
|
|
"type": "code",
|
|
"title": "字段对齐结果收口",
|
|
"notes": [
|
|
"整理 align_msg / 下一步动作。",
|
|
"若 stop_agent_turn=true,则直接进入 Answer。"
|
|
]
|
|
},
|
|
{
|
|
"id": "code_switch_intent",
|
|
"type": "code",
|
|
"title": "任务切换意图解析",
|
|
"script_ref": "docs/shipping_notice.md#L623-L649",
|
|
"when": "route_key == task_switch"
|
|
},
|
|
{
|
|
"id": "tool_switch_focus_task",
|
|
"type": "tool",
|
|
"title": "切换聚焦任务",
|
|
"operation_id": "switch_focus_task",
|
|
"when": "route_key == task_switch",
|
|
"inputs": {
|
|
"batch_no": "{{current_batch_no}}",
|
|
"task_id": "{{code_switch_intent.target_task_no}}",
|
|
"switch_mode": "{{code_switch_intent.switch_mode}}"
|
|
}
|
|
},
|
|
{
|
|
"id": "tool_get_task_status_after_switch",
|
|
"type": "tool",
|
|
"title": "加载当前任务详情",
|
|
"operation_id": "get_task_status",
|
|
"when": "route_key == task_switch",
|
|
"inputs": {
|
|
"task_id": "{{current_task_no}}",
|
|
"conversation_id": "{{conversation_id}}"
|
|
}
|
|
},
|
|
{
|
|
"id": "agent_shipping",
|
|
"type": "agent",
|
|
"title": "货代 Agent",
|
|
"instruction_ref": "docs/shipping_notice.md#L881-L912",
|
|
"tool_bindings": [
|
|
"get_task_status",
|
|
"submit_decision",
|
|
"match_inventory",
|
|
"generate_shipment_excel",
|
|
"upload_to_freight",
|
|
"auto_progress",
|
|
"get_inventory_schema_preview",
|
|
"apply_inventory_mapping",
|
|
"ensure_inventory",
|
|
"parse_inventory",
|
|
"update_notice_fields",
|
|
"update_notice_line"
|
|
]
|
|
},
|
|
{
|
|
"id": "code_normalize_tool_result",
|
|
"type": "code",
|
|
"title": "工具结果标准化",
|
|
"script_ref": "docs/shipping_notice.md#L680-L704",
|
|
"outputs": [
|
|
"tool_status",
|
|
"tool_message",
|
|
"tool_checkpoint",
|
|
"tool_action_buttons",
|
|
"tool_human_options",
|
|
"tool_data_json"
|
|
]
|
|
},
|
|
{
|
|
"id": "code_build_reply",
|
|
"type": "code",
|
|
"title": "组装直接回复",
|
|
"script_ref": "docs/shipping_notice.md#L706-L731",
|
|
"outputs": [
|
|
"final_reply"
|
|
]
|
|
},
|
|
{
|
|
"id": "answer_final",
|
|
"type": "answer",
|
|
"title": "直接回复",
|
|
"text": "{{final_reply}}"
|
|
}
|
|
],
|
|
"edges": [
|
|
{
|
|
"from": "start",
|
|
"to": "ctx_preprocess"
|
|
},
|
|
{
|
|
"from": "ctx_preprocess",
|
|
"to": "route_classifier"
|
|
},
|
|
{
|
|
"from": "route_classifier",
|
|
"to": "tool_create_batch",
|
|
"condition": "route_key == notice_batch_upload"
|
|
},
|
|
{
|
|
"from": "tool_create_batch",
|
|
"to": "iter_notice_files"
|
|
},
|
|
{
|
|
"from": "iter_notice_files",
|
|
"to": "tool_create_task"
|
|
},
|
|
{
|
|
"from": "tool_create_task",
|
|
"to": "http_extract_notice_text"
|
|
},
|
|
{
|
|
"from": "http_extract_notice_text",
|
|
"to": "llm_extract_notice"
|
|
},
|
|
{
|
|
"from": "llm_extract_notice",
|
|
"to": "code_validate_notice_json"
|
|
},
|
|
{
|
|
"from": "code_validate_notice_json",
|
|
"to": "tool_parse_notice",
|
|
"condition": "is_valid == true"
|
|
},
|
|
{
|
|
"from": "tool_parse_notice",
|
|
"to": "code_batch_summary"
|
|
},
|
|
{
|
|
"from": "code_batch_summary",
|
|
"to": "code_set_focus_task"
|
|
},
|
|
{
|
|
"from": "code_set_focus_task",
|
|
"to": "tool_get_task_status_init"
|
|
},
|
|
{
|
|
"from": "tool_get_task_status_init",
|
|
"to": "agent_shipping"
|
|
},
|
|
{
|
|
"from": "route_classifier",
|
|
"to": "http_upload_inventory",
|
|
"condition": "route_key == inventory_upload"
|
|
},
|
|
{
|
|
"from": "http_upload_inventory",
|
|
"to": "tool_schema_preview"
|
|
},
|
|
{
|
|
"from": "tool_schema_preview",
|
|
"to": "llm_map_inventory"
|
|
},
|
|
{
|
|
"from": "llm_map_inventory",
|
|
"to": "code_validate_mapping"
|
|
},
|
|
{
|
|
"from": "code_validate_mapping",
|
|
"to": "tool_apply_mapping",
|
|
"condition": "is_valid == true"
|
|
},
|
|
{
|
|
"from": "tool_apply_mapping",
|
|
"to": "code_alignment_result"
|
|
},
|
|
{
|
|
"from": "code_alignment_result",
|
|
"to": "answer_final"
|
|
},
|
|
{
|
|
"from": "route_classifier",
|
|
"to": "code_switch_intent",
|
|
"condition": "route_key == task_switch"
|
|
},
|
|
{
|
|
"from": "code_switch_intent",
|
|
"to": "tool_switch_focus_task"
|
|
},
|
|
{
|
|
"from": "tool_switch_focus_task",
|
|
"to": "tool_get_task_status_after_switch"
|
|
},
|
|
{
|
|
"from": "tool_get_task_status_after_switch",
|
|
"to": "agent_shipping"
|
|
},
|
|
{
|
|
"from": "route_classifier",
|
|
"to": "agent_shipping",
|
|
"condition": "route_key == continue_task"
|
|
},
|
|
{
|
|
"from": "agent_shipping",
|
|
"to": "code_normalize_tool_result"
|
|
},
|
|
{
|
|
"from": "code_normalize_tool_result",
|
|
"to": "code_build_reply"
|
|
},
|
|
{
|
|
"from": "code_build_reply",
|
|
"to": "answer_final"
|
|
},
|
|
{
|
|
"from": "route_classifier",
|
|
"to": "answer_final",
|
|
"condition": "route_key == direct_reply"
|
|
}
|
|
]
|
|
},
|
|
"http_examples": {
|
|
"upload_inventory_file_ref": "docs/shipping_notice.md#L271-L310",
|
|
"create_batch_ref": "docs/shipping_notice.md#L312-L349",
|
|
"apply_inventory_mapping_ref": "docs/shipping_notice.md#L350-L369"
|
|
},
|
|
"acceptance_checklist": [
|
|
"OpenAPI 从 docs/openapi/shipping_notice_tools.dify.json 或运行时 /tools/openapi.json 成功导入",
|
|
"Agent 节点已绑定 get_task_status/submit_decision/match_inventory/auto_progress/update_notice_* 等工具",
|
|
"HTTP 节点已配置 X-Shipping-Tool-Key",
|
|
"多通知文件场景能够 create_batch -> create_task -> parse_notice",
|
|
"库存 Excel 场景走 upload_inventory_file -> get_inventory_schema_preview -> apply_inventory_mapping",
|
|
"align_review 时 Agent 不越过人工确认",
|
|
"match_inventory 返回 ok 后,同轮继续 auto_progress",
|
|
"parse_review 阶段可调用 update_notice_fields / update_notice_line"
|
|
]
|
|
}
|