feat: 新增风险图谱算法与系统仪表盘及操作反馈体系
后端新增风险图谱算法模块、风险观察与反馈服务、规则 DSL 校验器和可解释性引擎,完善系统仪表盘和财务仪表盘统计, 优化 agent 运行和编排执行链路,清理旧开发文档,前端新增 系统趋势、负载热力图等多种仪表盘图表组件,完善操作反馈 对话框和工作台日期选择器,优化报销创建和审批详情交互, 补充单元测试覆盖。
This commit is contained in:
47
server/src/app/api/v1/endpoints/agent_feedback.py
Normal file
47
server/src/app/api/v1/endpoints/agent_feedback.py
Normal file
@@ -0,0 +1,47 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import APIRouter, Depends, Query, status
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.api.deps import get_db
|
||||
from app.schemas.agent_feedback import (
|
||||
AgentFeedbackCreate,
|
||||
AgentFeedbackRead,
|
||||
AgentFeedbackSummaryRead,
|
||||
)
|
||||
from app.services.agent_feedback import AgentFeedbackService
|
||||
|
||||
router = APIRouter(prefix="/agent-feedback")
|
||||
DbSession = Annotated[Session, Depends(get_db)]
|
||||
|
||||
|
||||
@router.post(
|
||||
"",
|
||||
response_model=AgentFeedbackRead,
|
||||
status_code=status.HTTP_201_CREATED,
|
||||
summary="记录 Agent 操作评价",
|
||||
description="记录用户对一次智能体处理结果的 1-5 星评价和低分原因。",
|
||||
)
|
||||
def create_agent_feedback(payload: AgentFeedbackCreate, db: DbSession) -> AgentFeedbackRead:
|
||||
return AgentFeedbackService(db).create_feedback(payload)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/summary",
|
||||
response_model=AgentFeedbackSummaryRead,
|
||||
summary="查询 Agent 操作评价统计",
|
||||
description="按最近反馈记录汇总评分分布、低分数量和低分原因。",
|
||||
)
|
||||
def summarize_agent_feedback(
|
||||
db: DbSession,
|
||||
agent: Annotated[str | None, Query(description="Agent 名称筛选。")] = None,
|
||||
session_type: Annotated[str | None, Query(description="会话类型筛选。")] = None,
|
||||
limit: Annotated[int, Query(ge=1, le=500, description="统计最近记录数。")] = 200,
|
||||
) -> AgentFeedbackSummaryRead:
|
||||
return AgentFeedbackService(db).summarize_feedback(
|
||||
agent=agent,
|
||||
session_type=session_type,
|
||||
limit=limit,
|
||||
)
|
||||
Reference in New Issue
Block a user