feat(file-check): 新增历史检核报告检索功能及相关 API

This commit is contained in:
hugo committed 2026-06-16 13:32:00 +08:00
1 parent 29a7704d46
commit f6fe56f205
16 files changed
+1060 -163

No files matched your search

+32
View File
@@ -87,6 +87,11 @@ def _tool_error_code(exc: AppError) -> str:
"run_not_found",
"excel_not_ready",
"kb_sync_failed",
"query_required",
"kb_not_configured",
"kb_group_not_found",
"kb_dataset_not_bound",
"dify_retrieve_failed",
}:
return message
if exc.code == "AUTH.UNAUTHORIZED":
@@ -401,6 +406,33 @@ def get_latest_file_check_run(task_id: int):
return jsonify({"ok": True, "run": _serialize_tool_run(run)})
@file_check_bp.route("/tools/history/search", methods=["POST"])
def search_file_check_history():
"""
检索已入库的历史检核报告片段;按 task_id 解析 ScheduleTask → KbGroup → Dify Dataset。
核心逻辑:Chatflow history_report_query 分支调用;task_id 来自 HXOPS 注入的 Start 变量。
"""
data = request.get_json(silent=True) or {}
raw_task_id = data.get("task_id")
try:
task_id = int(raw_task_id)
except (TypeError, ValueError):
raise ValidationError("task_id_invalid")
if task_id <= 0:
raise ValidationError("task_id_invalid")
from app.services.file_check_tools.history_search_service import search_file_check_history as run_history_search
result = run_history_search(
task_id=task_id,
query=str(data.get("query") or ""),
top_k=data.get("top_k"),
score_threshold=data.get("score_threshold"),
)
return jsonify({"ok": True, **result})
@file_check_bp.route("/tools/openapi.json", methods=["GET"])
def file_check_openapi_spec():
return jsonify(build_file_check_openapi_spec(resolve_HXOPS_TOOLS_API_BASE()))