feat(shipping_notice): 完成货代发货通知全流程功能迭代与重构
主要变更: 1. 移除废弃的发货通知字段抽取独立Workflow Agent相关代码 2. 重构Dify服务调用,新增inputs参数支持注入环境变量配置的工具API地址与密钥 3. 新增auto_progress工具API与checkpoint catalog接口,支持流程自动推进 4. 统一字段命名,将column_mapping_json改为map_json并兼容旧有调用 5. 重构库存匹配、解析结果的展示格式,改为标准化多语言Markdown表格 6. 新增ODM ID库存字段支持,优化库存解析与映射逻辑 7. 新增LibreOffice转换隔离Profile配置,避免多实例运行冲突 8. 新增完整环境变量配置、数据库迁移脚本与测试用例 9. 适配前端代码,更新字段命名与聊天跳转逻辑 10. 更新OpenAPI规范适配Dify工具调用,删除已归档的旧部署文档
This commit is contained in:
1 parent
2ce5256483
commit
c18c0394d0
50 files changed
+6088
-2407
No files matched your search
@@ -1,20 +1,52 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from app.models import ShippingTask
|
||||
|
||||
|
||||
def tool_response(
|
||||
*,
|
||||
status: str,
|
||||
task: ShippingTask | None = None,
|
||||
task_id: str | None = None,
|
||||
message: str = "",
|
||||
data: dict[str, Any] | None = None,
|
||||
human_options: list[str] | None = None,
|
||||
action_buttons: list[dict[str, str]] | None = None,
|
||||
checkpoint: str | None = None,
|
||||
next_required_action: str | None = None,
|
||||
forbidden_next_tools: list[str] | None = None,
|
||||
stop_agent_turn: bool = False,
|
||||
) -> dict[str, Any]:
|
||||
"""Build a shipping-notice tool JSON response.
|
||||
|
||||
When ``checkpoint`` is omitted and ``task`` is given, checkpoint / human_options /
|
||||
action_buttons are derived from ``resolve_task_ui_state(task)`` (single read path).
|
||||
Explicit ``checkpoint`` wins (e.g. ``parse_ok``, ``task_exists``).
|
||||
"""
|
||||
from app.services.shipping_notice.state_machine import (
|
||||
action_buttons_for_checkpoint,
|
||||
build_action_buttons,
|
||||
resolve_task_ui_state,
|
||||
)
|
||||
|
||||
if task is not None and not task_id:
|
||||
task_id = task.task_no
|
||||
|
||||
resolved_checkpoint = checkpoint
|
||||
resolved_human_options = human_options
|
||||
resolved_action_buttons = action_buttons
|
||||
|
||||
if checkpoint is None and task is not None:
|
||||
ui = resolve_task_ui_state(task)
|
||||
resolved_checkpoint = ui.checkpoint
|
||||
if human_options is None:
|
||||
resolved_human_options = ui.human_options
|
||||
if action_buttons is None and ui.action_buttons:
|
||||
resolved_action_buttons = ui.action_buttons
|
||||
|
||||
payload: dict[str, Any] = {
|
||||
"status": status,
|
||||
"message": message,
|
||||
@@ -22,10 +54,18 @@ def tool_response(
|
||||
}
|
||||
if task_id:
|
||||
payload["task_id"] = task_id
|
||||
if human_options:
|
||||
payload["human_options"] = human_options
|
||||
if checkpoint:
|
||||
payload["checkpoint"] = checkpoint
|
||||
if resolved_human_options is not None:
|
||||
payload["human_options"] = resolved_human_options
|
||||
if resolved_action_buttons is not None:
|
||||
payload["action_buttons"] = resolved_action_buttons
|
||||
elif resolved_human_options is not None:
|
||||
payload["action_buttons"] = build_action_buttons(resolved_human_options)
|
||||
elif resolved_checkpoint:
|
||||
buttons = action_buttons_for_checkpoint(resolved_checkpoint)
|
||||
if buttons:
|
||||
payload["action_buttons"] = buttons
|
||||
if resolved_checkpoint:
|
||||
payload["checkpoint"] = resolved_checkpoint
|
||||
if next_required_action:
|
||||
payload["next_required_action"] = next_required_action
|
||||
if forbidden_next_tools:
|
||||
|
||||
Reference in new issue
Block a user