feat(file-check): 新增文件检核相关 API 和工具,替换 RoHS 检核功能

This commit is contained in:
hugo committed 2026-06-16 09:28:37 +08:00
1 parent fa0cdee8df
commit 24310b63b3
35 files changed
+3066 -659

No files matched your search

+21 -18
View File
@@ -1084,6 +1084,7 @@ def chat_completions():
name=getattr(agent, 'name', None),
dify_api_key=getattr(agent, 'dify_api_key', None),
api_base_url=getattr(agent, 'api_base_url', None),
extra_config=getattr(agent, 'extra_config', None) or {},
)
user_proxy = SimpleNamespace(
id=user_id,
@@ -1174,31 +1175,33 @@ def chat_completions():
else:
dify_inputs: dict[str, str] | None = None
hxops_turn_id: str | None = None
from app.services.rohs_check_tools.dify_inputs import (
build_dify_chat_inputs as build_rohs_dify_chat_inputs,
is_rohs_check_chat_agent,
from app.services.file_check_tools.agent_resolver import (
agent_declares_file_check_progress,
is_file_check_chat_agent,
)
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,
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 is_rohs_check_chat_agent(agent_proxy):
hxops_turn_id = uuid.uuid4().hex
from app.services.rohs_check_tools.chat_turn_registry import register_rohs_chat_turn
elif 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:
hxops_turn_id = uuid.uuid4().hex
from app.services.file_check_tools.chat_turn_registry import register_file_check_chat_turn
register_rohs_chat_turn(
turn_id=hxops_turn_id,
session_id=session.session_id,
user_id=user_proxy.id,
agent_id=agent_proxy.id,
query=query,
)
dify_inputs = build_rohs_dify_chat_inputs(
hxops_session_id=session.session_id,
hxops_turn_id=hxops_turn_id,
)
register_file_check_chat_turn(
turn_id=hxops_turn_id,
session_id=session.session_id,
user_id=user_proxy.id,
agent_id=agent_proxy.id,
query=query,
)
generator = DifyService.stream_chat(
query,
user_proxy.id,
@@ -1206,7 +1209,7 @@ def chat_completions():
external_conversation_id,
request_id=request_id,
session_id=session.session_id,
hxops_turn_id=hxops_turn_id if is_rohs_check_chat_agent(agent_proxy) else None,
hxops_turn_id=hxops_turn_id if is_file_check_agent else None,
files=normalized_files,
inputs=dify_inputs,
)