Files
group_fqcd_jr/app/static/portal/employee-operations/nl2sql/index.html
T
张胜宇 5d0becb67d 客服 Agent 重构收口:五出口决策链 + 知识库档位隔离 + 前端入参边界(答辩演示版本)
一、客服 Agent 智能增强(正面回应"不智能、动不动就转人工")
- 决策链由 2 个出口扩到 5 个:E1 澄清 / E2 计算型 / E3 知识直返 / E4 证据约束生成 / E5 分级回退
- 转人工从"默认动作"降为最后一档 E5c,只保留 4 类白名单:
  P0 反诈 / P1 账户与个人数据 / P2 写操作与争议 / 用户明确要求人工
- 46 条金标实测(修复前 → 修复后):
  转人工率 43.5% → 10.9%;出口准确率 45.7% → 100%;事实正确率 69.6% → 100%
  禁忌违反 1 → 0;档位越权 / 无出处数字 / 误拒 四项零容忍全 0
- 安全不变量 INV-1~INV-5;零容忍规则未删,改的是挂载点
  (输出侧字面黑名单 → 检索层档位隔离 + 判定层合规词表 + 输出守护)

二、知识库:档位单点化与物理隔离
- 新增 app/core/knowledge_tier.py 作为档位规则唯一落点(G-03),
  knowledge_contracts.py 原定义块改为显式再导出(X as X,非副本)
- 档位过滤由 bool 默认值(fail-open)改为 tiers 必填集合(缺参即 TypeError)
- Milvus 侧四集合按 visibility 分区键物理隔离;双 schema 收敛为一套
- 新增 app/core/actor.py:访客三元组与匿名判定的唯一构造/判定点(G-01/G-01b)
- 新增 app/core/fund_fee_rules.py:费率计算纯函数

三、前端入参边界对齐(本轮 W11 新修,4 处"校验宽于存储")
- message 加 max_length=8000(与浮窗 widget.js 的 maxlength 一致)
- session_id 加 1—64;idempotency_key 上限 128 → 64(对齐列宽 String(64))
- feedback_type 加 max_length=32(对齐列宽 String(32))
- 8 条路径参数补 min_length=1 + max_length=64 + 字符集正则
  ({session_id} / {run_id} / {handover_id})
- 改前超限值会落到 MySQL 才失败(500);改后一律 422 AGENT_INPUT_INVALID + 字段级定位
- 新增 tests/unit/api/test_frontend_boundaries.py(33 例),含"端点表 ↔ OpenAPI 全量对照"

四、投顾模块整体清除(D4.4 / D4.5)
- 删除投顾相关 controller / schema / model / repository / service 及门户页面
- tools/portal_api_check.py 同步作废 AD003/AD005/AD011/A047 四条用例与 advisor_t 登录
  (端点与账号均已不存在,此前稳定报 3 条假红)

五、验证(提交前实测)
- pytest -q:1856 passed / 2 skipped / 0 failed
- ruff check app tools tests:19(= 基线);mypy app:2(= 基线)
- 前端接口契约体检 portal_api_check.py:38 项,通过 34,失败 0,跳过 4
- 全链路冒烟 e2e_smoke_test.py --read-only:31/31
- HTTP 全链路探针 http_probe.py:11/11 succeeded
- 跨文档一致性 _consistency.py:GATE PASS
- 真机边界复验 12 条:12/12 符合预期

六、纪律与文档
- 可改文件白名单 A-09(docs/46)与底座会签申请单 A-10(docs/47,组 1—组 4 全部受理)
- 零 DDL:未新增/修改任何表结构,89 张业务表与基线一致
- 证据留痕:docs/evidence/**(含 46 条金标 score、快照、清除与重建记录)
- 未提交(刻意排除,见提交说明):仓库内 客服agent/ 与 开发文档/ 是 2026-09-16 前的
  过期副本(Todolist 440 行 vs 权威 D2.1 1167 行),权威正本在仓库外;
  _chunks_report.txt 是 tools/build_knowledge_chunks.py 生成的本地产物
2026-09-20 14:33:30 +08:00

37 lines
4.5 KiB
HTML

<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NL2SQL · 南方基金</title>
<link rel="stylesheet" href="/static/portal/common/base.css">
<link rel="stylesheet" href="/static/portal/common/operations.css">
<link rel="stylesheet" href="/static/portal/employee-operations/operator-workspace.css?v=20260921">
<link rel="stylesheet" href="/static/portal/employee-operations/nl2sql/nl2sql.css?v=20260914-layout3">
</head>
<body>
<main id="main-content" class="page-shell operations-shell operator-shell operator-workspace operator-workspace--spacious nl2sql-page">
<section class="operations-hero operator-hero fade-in">
<div class="operations-hero__content"><p class="operations-kicker">数据运营 · 只读查询链路</p><h1 class="operations-hero__title">NL2SQL</h1><p class="operations-hero__copy">支持场外单据核对和通用金融自然语言查询,查询、权限、审计和最终状态均由后端 Agent 链路决定。</p><div class="operations-hero__signals"><span>只读查询</span><span>白名单表</span><span>权限审计</span></div></div>
<div class="operations-hero__meta"><strong data-operator-name>运营人员</strong><span data-operator-scope>权限加载中</span></div>
</section>
<article class="panel panel--flush">
<div class="operator-tabs" role="tablist" aria-label="NL2SQL 模式"><button class="operator-tab" type="button" aria-selected="true" data-tab="offsite">场外单据核对</button><button class="operator-tab" type="button" aria-selected="false" data-tab="general">通用自然语言查询</button></div>
<section class="operator-view" data-view="offsite">
<div class="panel__body operator-columns">
<section class="operator-stack"><div><h2 class="panel__title">场外单据核对</h2><p class="operator-inline-note">先生成并确认自然语言,再执行只读核对。</p></div><label class="form-field"><span class="form-field__label">单据 task_id</span><input class="form-field__input" data-offsite-task placeholder="例如 20260910-001-A01"></label><label class="form-field"><span class="form-field__label">自然语言:</span><textarea class="form-field__input form-field__input--natural-language" data-offsite-natural-language rows="8" placeholder="点击“生成自然语言”后显示,可人工修改"></textarea><span class="operator-inline-note">该内容用于人工查看和调整查询意图。</span></label><label class="operator-checkboxes"><input type="checkbox" data-manual-confirmed> <span>我已人工确认原始文件内容</span></label><div class="operator-actions"><button class="button button--primary" type="button" data-action="generate-offsite">生成自然语言</button><button class="button" type="button" data-action="run-offsite">执行只读核对</button><a class="button button--back" data-offsite-back href="/portal/employee-operations/offsite/">返回</a></div></section>
<section><div class="operator-section-heading"><div><h2 class="panel__title">核对结果</h2><p class="operator-inline-note">查询结果写回场外单据链路后,返回规则摘要。</p></div><span class="tag" data-offsite-status>等待执行</span></div><div data-offsite-result><div class="operations-empty">输入 task_id 后执行一次只读核对。</div></div></section>
</div>
</section>
<section class="operator-view" data-view="general" hidden>
<div class="panel__body operator-columns">
<section class="operator-stack"><div><h2 class="panel__title">通用自然语言查询</h2></div><label class="form-field"><span class="form-field__label">业务问题</span><textarea class="form-field__input" data-query-text rows="5" placeholder="例如:查询某基金最近一个交易日的净值"></textarea></label><button class="button button--primary" type="button" data-action="run-general">提交只读查询</button></section>
<section><div class="operator-section-heading"><div><h2 class="panel__title">运行状态与结果</h2><p class="operator-inline-note">状态完成后展示结果和工具调用摘要。</p></div></div><div data-general-result><div class="operations-empty">提交问题后,前端会自动轮询运行状态。</div></div></section>
</div>
</section>
</article>
</main>
<script type="module" src="/static/portal/employee-operations/nl2sql/nl2sql.js?v=20260914-layout3"></script>
</body>
</html>