feat(shipping-notice): 实现货代发货通知的库存全流程与对话交互
This commit is contained in:
1 parent
a5cc48b6aa
commit
2607f4a9f6
26 files changed
+5013
-256
No files matched your search
@@ -48,7 +48,6 @@ def _post_op(
|
||||
},
|
||||
}
|
||||
},
|
||||
"security": [{"ShippingToolKey": []}],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,17 +68,6 @@ def build_dify_openapi_spec(base_url: str) -> dict[str, Any]:
|
||||
"description": "货代发货通知 Agent Tool API。仅包含 Chatflow 编排工具,不含 RPA 回调。",
|
||||
},
|
||||
"servers": [{"url": server}],
|
||||
"components": {
|
||||
"securitySchemes": {
|
||||
"ShippingToolKey": {
|
||||
"type": "apiKey",
|
||||
"in": "header",
|
||||
"name": "X-Shipping-Tool-Key",
|
||||
"description": "与 hxops SHIPPING_NOTICE_TOOL_API_KEY 相同",
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [{"ShippingToolKey": []}],
|
||||
"paths": {
|
||||
"/tools/create_case": _post_op(
|
||||
"create_case",
|
||||
@@ -100,9 +88,50 @@ def build_dify_openapi_spec(base_url: str) -> dict[str, Any]:
|
||||
},
|
||||
required=["case_id"],
|
||||
),
|
||||
"/tools/parse_inventory": _post_op(
|
||||
"parse_inventory",
|
||||
"解析库存。大 Excel 禁止 raw_inventory_text(会超 LLM token);"
|
||||
"先 POST /tools/upload_inventory_file 上传,再 get_inventory_schema_preview → "
|
||||
"apply_inventory_mapping;或 use_uploaded_file=true(规则映射兜底)。小表可粘贴文本。"
|
||||
"成功后 stop_agent_turn,等 confirm_inventory_mapping 后再 match。",
|
||||
{
|
||||
"case_id": case_id,
|
||||
"use_uploaded_file": _str_prop(
|
||||
"true=解析该 case 已上传的 Excel(服务端直传,不经过 LLM)",
|
||||
enum=["true", "false"],
|
||||
),
|
||||
"column_mapping_json": _str_prop(
|
||||
'可选,列映射 JSON 字符串,如 {"sku":"AWS Sku","available_qty":"Qty Available"}'
|
||||
),
|
||||
"raw_inventory_text": _str_prop(
|
||||
"仅小表(约 <8 万字符)。大 Excel 勿传此字段,改用 upload_inventory_file"
|
||||
),
|
||||
"inventory_lines_json": _str_prop(
|
||||
'可选,已整理好的 JSON 数组字符串,如 [{"sku":"A001","available_qty":10}]'
|
||||
),
|
||||
},
|
||||
required=["case_id"],
|
||||
),
|
||||
"/tools/get_inventory_schema_preview": _post_op(
|
||||
"get_inventory_schema_preview",
|
||||
"读取已上传库存 Excel 的表头与样例行(小 payload,供 LLM 推断列映射)",
|
||||
{"case_id": case_id},
|
||||
required=["case_id"],
|
||||
),
|
||||
"/tools/apply_inventory_mapping": _post_op(
|
||||
"apply_inventory_mapping",
|
||||
"应用 LLM/人工列映射并解析完整库存文件;返回 field_alignment 等待用户确认",
|
||||
{
|
||||
"case_id": case_id,
|
||||
"column_mapping_json": _str_prop(
|
||||
'列映射 JSON,如 {"sku":"料号","reservation_id":"COM ID","available_qty":"Qty Available"}'
|
||||
),
|
||||
},
|
||||
required=["case_id", "column_mapping_json"],
|
||||
),
|
||||
"/tools/ensure_inventory": _post_op(
|
||||
"ensure_inventory",
|
||||
"确保库存快照可用(RPA 或手工 JSON)",
|
||||
"确保库存快照可用(RPA 自动导出;对话库存请优先用 parse_inventory)",
|
||||
{
|
||||
"case_id": case_id,
|
||||
"mode": _str_prop("auto=自动/RPA;retry_rpa=重试 RPA", enum=["auto", "retry_rpa"]),
|
||||
@@ -114,7 +143,8 @@ def build_dify_openapi_spec(base_url: str) -> dict[str, Any]:
|
||||
),
|
||||
"/tools/match_inventory": _post_op(
|
||||
"match_inventory",
|
||||
"匹配发货需求与库存",
|
||||
"匹配发货需求与库存。前置条件:submit_decision(confirm_inventory_mapping) 已成功;"
|
||||
"未确认时调用会被拒绝并返回 forbidden_next_tools",
|
||||
{
|
||||
"case_id": case_id,
|
||||
"inventory_lines_json": _str_prop("可选,覆盖库存 JSON 数组后再匹配"),
|
||||
@@ -123,20 +153,31 @@ def build_dify_openapi_spec(base_url: str) -> dict[str, Any]:
|
||||
),
|
||||
"/tools/submit_decision": _post_op(
|
||||
"submit_decision",
|
||||
"人工复核决策",
|
||||
"人工复核决策。case_id 与 conversation_id 至少传一个;用户确认时禁止 create_case",
|
||||
{
|
||||
"case_id": case_id,
|
||||
"conversation_id": _str_prop("Dify 会话 ID;用户仅回复「确认」时用于定位 case"),
|
||||
"decision": _str_prop(
|
||||
"confirm=确认继续;reject=驳回;rematch=重新匹配;reparse=重新解析",
|
||||
enum=["confirm", "reject", "rematch", "reparse"],
|
||||
"confirm=确认继续;reject=驳回;rematch=重新匹配;reparse=重新解析;"
|
||||
"confirm_inventory_mapping=确认库存字段对齐;correct_inventory_mapping=更正列映射;reparse_inventory=重新上传库存",
|
||||
enum=[
|
||||
"confirm",
|
||||
"confirm_parse",
|
||||
"reject",
|
||||
"rematch",
|
||||
"reparse",
|
||||
"confirm_inventory_mapping",
|
||||
"correct_inventory_mapping",
|
||||
"reparse_inventory",
|
||||
],
|
||||
),
|
||||
"comment": _str_prop("备注(可选)"),
|
||||
},
|
||||
required=["case_id", "decision"],
|
||||
required=["decision"],
|
||||
),
|
||||
"/tools/generate_shipment_excel": _post_op(
|
||||
"generate_shipment_excel",
|
||||
"生成固定模板发货 Excel",
|
||||
"生成固定模板发货 Excel(须 match_inventory 成功且 process_status=matched)",
|
||||
{"case_id": case_id},
|
||||
required=["case_id"],
|
||||
),
|
||||
@@ -155,9 +196,11 @@ def build_dify_openapi_spec(base_url: str) -> dict[str, Any]:
|
||||
),
|
||||
"/tools/get_case_status": _post_op(
|
||||
"get_case_status",
|
||||
"查询 case 当前状态与 human_options",
|
||||
{"case_id": case_id},
|
||||
required=["case_id"],
|
||||
"查询 case 当前状态与 human_options。case_id 与 conversation_id 至少传一个",
|
||||
{
|
||||
"case_id": case_id,
|
||||
"conversation_id": _str_prop("Dify 会话 ID"),
|
||||
},
|
||||
),
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user