feat(chat): 完善附件预览与订单提取交互
- 优化聊天附件上传、预览及 PDF.js 加载 - 完善订单文档画布与审核预览体验 - 优化订单提取运行状态及发送流程 - 增强会话附件接口与相关测试覆盖 - 更新 Nginx 配置、技术文档及四语言文案
This commit is contained in:
1 parent
104afa3844
commit
9d2fa522fa
29 files changed
+584
-140
No files matched your search
@@ -2,8 +2,8 @@
|
||||
api/chat/sessions.py
|
||||
|
||||
用途:处理聊天会话、历史消息与本地结构化消息路由。
|
||||
依赖:chat.shared、chat.core、ChatSession、ChatLog。
|
||||
逻辑:校验当前用户和 Agent 后读写会话及日志,保持历史数据兼容查询。
|
||||
依赖:chat.shared、chat.core、ChatSession、ChatLog、_normalize_user_attachments。
|
||||
逻辑:校验当前用户和 Agent 后读写会话及日志;用户附件快照写库前规范化,超限显式失败不落半截。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -246,7 +246,8 @@ def save_local_message():
|
||||
保存前端本地生成的聊天记录(如表单、确认弹窗、合同审查结果卡等)。
|
||||
|
||||
核心逻辑:user 角色用 content/query 落库;纯文本 assistant 忽略 query 防重复气泡;
|
||||
结构化 typed 消息(leave-form / procurement-contract-review 等)保留 query,供历史回放与会话标题。
|
||||
结构化 typed 消息(leave-form / procurement-contract-review 等)保留 query,供历史回放与会话标题;
|
||||
user 角色 payload 含 user_attachments 时写库前调用 _normalize_user_attachments,超限抛 ValidationError。
|
||||
"""
|
||||
user = getattr(g, 'current_user', None)
|
||||
agent = getattr(g, 'current_agent', None)
|
||||
@@ -286,6 +287,13 @@ def save_local_message():
|
||||
if user_query and _looks_like_review_auto_title(session.title or ''):
|
||||
session.title = _session_title_from_text(user_query)
|
||||
|
||||
# [STEP] 用户附件快照写前规范化;超限由 _normalize_user_attachments 显式失败,禁止落半截
|
||||
if role == 'user' and isinstance(payload, dict) and 'user_attachments' in payload:
|
||||
payload = {
|
||||
**payload,
|
||||
'user_attachments': _normalize_user_attachments(payload.get('user_attachments')),
|
||||
}
|
||||
|
||||
# 如果 payload 里面包含 formId,且该 formId 已经被保存过,可以直接更新该记录
|
||||
# 这样能保证前端表单状态(例如已确认)被持久化
|
||||
local_id = payload.get('formId') if payload and isinstance(payload, dict) else None
|
||||
|
||||
Reference in new issue
Block a user