feat(shipping-notice): 支持发货通知解析延后至 Dify 画布,优化任务创建流程

This commit is contained in:
hugo committed 2026-06-22 16:59:38 +08:00
1 parent d46d61bfa1
commit 70e8f700ff
38 files changed
+3215 -714

No files matched your search

+12 -4
View File
@@ -1065,6 +1065,8 @@ def chat_completions():
query = data.get('query')
# 前端传入的 conversation_id 在 B2 里代表本地 session_id
conversation_id = data.get('conversation_id')
shipping_task_id = str(data.get('task_id') or '').strip()
shipping_batch_no = str(data.get('batch_no') or '').strip()
kb_type = data.get('kb_type', '企业知识库')
files = data.get('files')
request_id = uuid.uuid4().hex[:12]
@@ -1194,14 +1196,13 @@ def chat_completions():
)
from app.services.file_check_tools.dify_inputs import build_file_check_dify_inputs
from app.services.shipping_notice.dify_inputs import (
build_dify_chat_inputs as build_shipping_dify_chat_inputs,
build_dify_chat_inputs as build_shipping_notice_dify_inputs,
is_shipping_notice_chat_agent,
)
declares_file_check = agent_declares_file_check_progress(agent_proxy)
is_file_check_agent = is_file_check_chat_agent(agent_proxy)
if is_shipping_notice_chat_agent(agent_proxy):
dify_inputs = build_shipping_dify_chat_inputs()
elif declares_file_check or is_file_check_agent:
is_shipping_agent = is_shipping_notice_chat_agent(agent_proxy)
if declares_file_check or is_file_check_agent:
# [STEP 1] 先校验 task_id,避免 Dify Chatflow 缺参时长连接挂死
dify_inputs = build_file_check_dify_inputs(agent_proxy, required=True)
if is_file_check_agent:
@@ -1215,6 +1216,13 @@ def chat_completions():
agent_id=agent_proxy.id,
query=query,
)
elif is_shipping_agent:
# [STEP 2] 发货通知 Chatflow 依赖会话级 task/batch 上下文稳定定位当前任务
dify_inputs = build_shipping_notice_dify_inputs(
external_conversation_id or session.session_id,
task_id=shipping_task_id,
batch_no=shipping_batch_no,
)
generator = DifyService.stream_chat(
query,
user_proxy.id,