feat(file-check): 新增文件资产管理与清理功能,支持上传、查询、删除及下载
This commit is contained in:
1 parent
143e054d86
commit
729546a7b7
52 files changed
+3420
-34
No files matched your search
@@ -2,8 +2,9 @@
|
||||
backend/app/services/chat/turn_runtime.py
|
||||
|
||||
用途:平台统一 Chat Turn 执行器,编排 SSE 生命周期、session、ChatLog 与 action 路由。
|
||||
依赖:action_registry、turn_events、session_service、log_service、turn_context、action_schema。
|
||||
依赖:action_registry、turn_events、session_service、log_service、turn_context、action_schema、db。
|
||||
逻辑:api/chat/turns/stream 调用 ChatTurnRuntime.stream();业务 handler 只 yield TurnEvent。
|
||||
失败路径先 db.session.rollback(),再 touch_chat_session,避免 handler 脏写被一并提交。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -14,6 +15,7 @@ from typing import Any, Iterator
|
||||
|
||||
from flask import current_app
|
||||
|
||||
from app import db
|
||||
from app.core.errors import AppError, ValidationError
|
||||
from app.services.chat.action_registry import ensure_handlers_loaded, resolve_action_handler
|
||||
from app.services.chat.action_schema import TurnEvent, TurnInput, parse_turn_refs_from_context
|
||||
@@ -183,6 +185,8 @@ class ChatTurnRuntime:
|
||||
getattr(exc, "code", None),
|
||||
exc.message,
|
||||
)
|
||||
# 业务失败后先 rollback,避免 handler 预占/脏写被 touch_chat_session 一并提交
|
||||
db.session.rollback()
|
||||
touch_chat_session(user_id, agent_id, session.session_id, status="error")
|
||||
yield emit_run_failed(
|
||||
run_id=run_id,
|
||||
@@ -193,6 +197,7 @@ class ChatTurnRuntime:
|
||||
)
|
||||
except Exception as exc:
|
||||
current_app.logger.exception("[chat-turn] unexpected failure request_id=%s turn_id=%s", req_id, turn_id)
|
||||
db.session.rollback()
|
||||
touch_chat_session(user_id, agent_id, session.session_id, status="error")
|
||||
yield emit_run_failed(
|
||||
run_id=run_id,
|
||||
|
||||
Reference in new issue
Block a user