449c6d4875
## H5 员工端 v4 (2026-07-13 00:48 已部署)
- 人工按钮三态文案统一为"人工坐席"
- 按钮位置移至发送键和语音按钮上方(垂直堆叠)
- 点按钮直接调 store.shakeAgent(),删除 CallAgentModal 弹窗动画
- 截图快捷键提示改为"截图->粘贴:Alt+Shift+A-Ctrl+V ---> Ctrl+V"
- 移动端隐藏截图提示(CSS 媒体查询)
- AI转人工提示改为"已为您呼叫人工坐席,请稍等!"
- 坐席接入提示改为"坐席正在查看您的信息,请等待处理回复!"
- 删除"摇铃呼叫坐席"入口和文案
- 删除孤儿组件 MessageList.vue + shake 动画 CSS
## H5 员工端 v5 (2026-07-13 02:08 已部署)
- RightPanel v2.1:删除"软件安装"和"资源权限"标签页
- 移除标签栏,智能推荐(DynamicRecommend)直接展示
- 删除 SoftwareDownloads/ApprovalLinks 引用和相关 CSS
## AI 对话链路全栈改造 Phase 1-6 (已部署)
- Phase 1: Dify JSON输出 + 后端blocking解析 + 双WS推送 + 错误降级
- Phase 2: 关键词收窄(~25强意图词) + 两级分类Prompt + 删除前端checkApprovalIntent
- Phase 3: WS扩展(ai_thinking+dynamic_recommend) + ai_structured气泡 + RightPanel v2 + 选项回传
- Phase 4: VisionService接入 + 图片消息融合(5秒窗口) + 降级策略
- Phase 5: 坐席端ai_thinking指示器 + ai_structured/byod_card渲染 + handleNewMessage修复
- Phase 6: diagnosis_stage(6值) + response_time_ms计时 + 慢响应告警(>10s)
## 坐席端 v5 (2026-07-13 01:38 已部署)
- ai_structured/byod_card 只读渲染
- AI思考指示器 UI
- handleNewMessage 透传 msg_type/extra_data 修复
- 布局优化v2.0: QuickReplyBar L1+L2悬浮 + ReplyBox左右分区 + 右栏260/560px切换
- 键盘快捷键v2.3: 纯数字路由 + ESC分层撤销 + Shift+Space用event.code
## 上下文感知智能诊断闭环 (2026-07-12 已部署)
- 三层诊断(API→Script→AI) + 三段排队(VIP→info_locked→not locked)
- 答题插队 + 五场景关闭
- 迁移052(6表+6列) + queue_service + quiz_service + closing_service
- H5前端: QueueWaiting + RightPanel双Tab + InputBar三态 + ResolveConfirmCard
- 坐席前端: pending_close结单流程 + 信息锁定(Dify步骤完成+有效回答率≥70%)
## 知识库迭代3 (2026-07-12 已部署)
- 分诊交互(H5+坐席+Dify独立应用)
- 拓扑预览(ECharts只读)
- 代答排除(4种匹配器: keyword/regex/intent/category)
- 迁移051 + 44文件43测试通过
## 后端变更
- 6个Python文件改造(h5_ai_task.py/h5.py/ai_service.py/closing_service.py等)
- funny_phrase_service.py: shake/connected/keyword 默认文案更新
- session_service.py: 企微消息文案同步
- 新增: queue.py/quiz.py/triage.py/exclusion_rules.py 等API端点
- 新增: diagnostic.py/quiz.py/triage_session.py 等模型
- 新增: closing_service/queue_service/quiz_service/triage_service 等服务
## 文档更新
- CHANGELOG.md: 新增 [未发布] 区全部变更记录
- 项目管理主文档 v2.5: 新增v0.7.3版本 + 已完成看板 + 最近搞定
- 版本记录: 新增v0.7.3条目
- AI对话链路实施计划: Phase 1-6 全部标记✅已实施
- 新增架构图/时序图/类图(mermaid)
## 部署路径修正
- 服务器项目根路径: /opt/wecom-it-desk/
- 所有前端dist均为ro bind mount,只能在宿主机源路径操作
- 服务器nginx /h5/ 是静态文件服务(非proxy_pass)
- elFinder上传二进制不可靠(MD5不匹配),改用base64分块上传
185 lines
7.1 KiB
Python
185 lines
7.1 KiB
Python
# =============================================================================
|
||
# 企微IT智能服务台 — 代答排除 Pydantic Schema
|
||
# =============================================================================
|
||
# 说明:代答排除模块的请求/响应数据模型,覆盖管理后台所有接口。
|
||
# =============================================================================
|
||
|
||
from datetime import datetime
|
||
from typing import List, Optional
|
||
|
||
from pydantic import BaseModel, Field
|
||
|
||
|
||
# =============================================================================
|
||
# 请求 Schema
|
||
# =============================================================================
|
||
|
||
class ExclusionRuleCreate(BaseModel):
|
||
"""新建排除规则请求。
|
||
|
||
Attributes:
|
||
rule_name: 规则名称(唯一)
|
||
rule_description: 规则描述
|
||
priority: 优先级(P0/P1/P2/P3)
|
||
match_type: 匹配方式(keyword/regex/intent/category)
|
||
match_condition: 匹配条件
|
||
match_scope: 匹配范围
|
||
action_type: 命中后动作类型
|
||
transfer_message: 转人工提示语
|
||
"""
|
||
|
||
rule_name: str = Field(..., min_length=1, max_length=200, description="规则名称")
|
||
rule_description: Optional[str] = Field(None, description="规则描述")
|
||
priority: str = Field("P2", description="优先级:P0/P1/P2/P3")
|
||
match_type: str = Field(..., description="匹配方式:keyword/regex/intent/category")
|
||
match_condition: str = Field(..., min_length=1, description="匹配条件")
|
||
match_scope: List[str] = Field(default_factory=lambda: ["ai_auto_reply"], description="匹配范围")
|
||
action_type: str = Field("transfer_human", description="命中后动作类型")
|
||
transfer_message: Optional[str] = Field(None, description="转人工提示语")
|
||
|
||
|
||
class ExclusionRuleUpdate(BaseModel):
|
||
"""编辑排除规则请求。
|
||
|
||
所有字段可选,仅更新传入的字段。
|
||
|
||
Attributes:
|
||
rule_name: 规则名称
|
||
rule_description: 规则描述
|
||
priority: 优先级
|
||
match_type: 匹配方式
|
||
match_condition: 匹配条件
|
||
match_scope: 匹配范围
|
||
action_type: 命中后动作类型
|
||
transfer_message: 转人工提示语
|
||
"""
|
||
|
||
rule_name: Optional[str] = Field(None, min_length=1, max_length=200, description="规则名称")
|
||
rule_description: Optional[str] = Field(None, description="规则描述")
|
||
priority: Optional[str] = Field(None, description="优先级")
|
||
match_type: Optional[str] = Field(None, description="匹配方式")
|
||
match_condition: Optional[str] = Field(None, description="匹配条件")
|
||
match_scope: Optional[List[str]] = Field(None, description="匹配范围")
|
||
action_type: Optional[str] = Field(None, description="命中后动作类型")
|
||
transfer_message: Optional[str] = Field(None, description="转人工提示语")
|
||
|
||
|
||
class ExclusionRuleToggle(BaseModel):
|
||
"""启用/停用规则请求。
|
||
|
||
Attributes:
|
||
status: 目标状态(enabled/disabled)
|
||
"""
|
||
|
||
status: str = Field(..., description="目标状态:enabled/disabled")
|
||
|
||
|
||
class ExclusionTestRequest(BaseModel):
|
||
"""测试匹配请求。
|
||
|
||
Attributes:
|
||
message: 测试消息文本
|
||
rule_id: 指定规则ID(可选,不指定则测试所有启用规则)
|
||
"""
|
||
|
||
message: str = Field(..., min_length=1, description="测试消息文本")
|
||
rule_id: Optional[str] = Field(None, description="指定规则ID")
|
||
|
||
|
||
# =============================================================================
|
||
# 查询参数 Schema
|
||
# =============================================================================
|
||
|
||
class ExclusionRuleQuery(BaseModel):
|
||
"""排除规则列表查询参数。
|
||
|
||
Attributes:
|
||
status: 状态筛选
|
||
match_type: 匹配方式筛选
|
||
priority: 优先级筛选
|
||
keyword: 关键词搜索(规则名称/描述)
|
||
page: 页码
|
||
page_size: 每页数量
|
||
"""
|
||
|
||
status: Optional[str] = Field(None, description="状态筛选")
|
||
match_type: Optional[str] = Field(None, description="匹配方式筛选")
|
||
priority: Optional[str] = Field(None, description="优先级筛选")
|
||
keyword: Optional[str] = Field(None, description="关键词搜索")
|
||
page: int = Field(1, ge=1, description="页码")
|
||
page_size: int = Field(20, ge=1, le=100, description="每页数量")
|
||
|
||
|
||
# =============================================================================
|
||
# 响应 Schema
|
||
# =============================================================================
|
||
|
||
class ExclusionRuleResponse(BaseModel):
|
||
"""排除规则响应。
|
||
|
||
Attributes:
|
||
id: 规则ID
|
||
rule_name: 规则名称
|
||
rule_description: 规则描述
|
||
priority: 优先级
|
||
match_type: 匹配方式
|
||
match_condition: 匹配条件
|
||
match_scope: 匹配范围
|
||
action_type: 命中后动作类型
|
||
transfer_message: 转人工提示语
|
||
status: 状态
|
||
hit_count: 命中次数
|
||
created_by: 创建人ID
|
||
created_at: 创建时间
|
||
updated_at: 更新时间
|
||
"""
|
||
|
||
id: str = Field(..., description="规则ID")
|
||
rule_name: str = Field(..., description="规则名称")
|
||
rule_description: Optional[str] = Field(None, description="规则描述")
|
||
priority: str = Field(..., description="优先级")
|
||
match_type: str = Field(..., description="匹配方式")
|
||
match_condition: str = Field(..., description="匹配条件")
|
||
match_scope: List[str] = Field(default_factory=list, description="匹配范围")
|
||
action_type: str = Field(..., description="命中后动作类型")
|
||
transfer_message: Optional[str] = Field(None, description="转人工提示语")
|
||
status: str = Field(..., description="状态")
|
||
hit_count: int = Field(0, description="命中次数")
|
||
created_by: str = Field(..., description="创建人ID")
|
||
created_at: Optional[datetime] = Field(None, description="创建时间")
|
||
updated_at: Optional[datetime] = Field(None, description="更新时间")
|
||
|
||
model_config = {"from_attributes": True}
|
||
|
||
|
||
class ExclusionTestResponse(BaseModel):
|
||
"""测试匹配响应。
|
||
|
||
Attributes:
|
||
matched: 是否命中
|
||
matched_detail: 命中详情
|
||
rule_name: 命中的规则名称
|
||
action_type: 命中后动作类型
|
||
"""
|
||
|
||
matched: bool = Field(False, description="是否命中")
|
||
matched_detail: Optional[str] = Field(None, description="命中详情")
|
||
rule_name: Optional[str] = Field(None, description="命中的规则名称")
|
||
action_type: Optional[str] = Field(None, description="命中后动作类型")
|
||
|
||
|
||
class ExclusionStatsResponse(BaseModel):
|
||
"""排除规则统计概要响应。
|
||
|
||
Attributes:
|
||
enabled_count: 启用规则数
|
||
disabled_count: 停用规则数
|
||
monthly_hits: 本月命中次数
|
||
monthly_transfers: 本月转人工次数
|
||
"""
|
||
|
||
enabled_count: int = Field(0, description="启用规则数")
|
||
disabled_count: int = Field(0, description="停用规则数")
|
||
monthly_hits: int = Field(0, description="本月命中次数")
|
||
monthly_transfers: int = Field(0, description="本月转人工次数")
|