feat: 工作流记忆与内置工具、知你客服脚本、Agent管理技能展示与能力配置、文档与Windows启动脚本;忽略 redis_temp 二进制目录
Made-with: Cursor
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
工作流任务
|
||||
"""
|
||||
from celery import Task
|
||||
from app.core.tools_bootstrap import ensure_builtin_tools_registered
|
||||
|
||||
ensure_builtin_tools_registered()
|
||||
|
||||
from app.core.celery_app import celery_app
|
||||
from app.services.workflow_engine import WorkflowEngine
|
||||
from app.services.execution_logger import ExecutionLogger
|
||||
@@ -15,6 +19,17 @@ import asyncio
|
||||
import time
|
||||
|
||||
|
||||
def _format_task_error(e: Exception) -> str:
|
||||
"""Celery 任务异常写入 DB 时的可读文案(HTTPException.detail 等)。"""
|
||||
detail = getattr(e, "detail", None)
|
||||
if isinstance(detail, str) and detail.strip():
|
||||
return detail
|
||||
if detail is not None and detail != "":
|
||||
return str(detail)
|
||||
s = str(e).strip()
|
||||
return s if s else repr(e)
|
||||
|
||||
|
||||
@celery_app.task(bind=True)
|
||||
def execute_workflow_task(
|
||||
self,
|
||||
@@ -87,14 +102,15 @@ def execute_workflow_task(
|
||||
execution_time = int((time.time() - start_time) * 1000)
|
||||
|
||||
# 记录错误日志
|
||||
err_text = _format_task_error(e)
|
||||
if execution_logger:
|
||||
execution_logger.error(f"工作流任务执行失败: {str(e)}", data={"error_type": type(e).__name__})
|
||||
execution_logger.error(f"工作流任务执行失败: {err_text}", data={"error_type": type(e).__name__})
|
||||
|
||||
# 更新执行记录为失败
|
||||
execution = db.query(Execution).filter(Execution.id == execution_id).first()
|
||||
if execution:
|
||||
execution.status = "failed"
|
||||
execution.error_message = str(e)
|
||||
execution.error_message = err_text
|
||||
execution.execution_time = execution_time
|
||||
db.commit()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user