feat(llm): 上游多账号路由 + 账号级负载统计 (1.0.14)
一个 slot 挂多把上游账号 Key,解决厂商「单账号额度/并发受限」与 「同一用户缓存命中」两个矛盾诉求。 多账号路由 (plugin-llm) - models: Upstream.accounts[] (auth/note/resets) + 上游级 exhaust_status/exhaust_markers;顶层 auth 保留兼容(accounts 为空时合成单账号) - upstreams::pick_account:粘性绑定 ukb:<key> 优先 → 无绑定时 FNV-1a(下游 Key) % 可用数 冷分散 → 绑定账号冷却则重新分散 → 全冷却取最早恢复 * 分散避开厂商单账号 agent 并发上限;落点固定保住 prompt/token 缓存 - cool_until_until 天锚定冷却:boundary = day0 + ceil(已过/窗口)*窗口, 封顶次日 0 点(MiniMax 5h 窗口、24=5*4+4 → 末段 20:00-24:00 只有 4h 随天重置) - 耗尽双检测 (log 阶段):$upstream_status 命中 exhaust_status,或 usage_filter 流式扫到 marker → $llm_acct 定位本次账号 → 写冷却 uac: - shm: up:/upa:/uac:/ukb:/upe: 五类前缀;$llm_acct 变量 (NOCACHEABLE) 账号级负载统计(问题发现与跟踪) - 新增 uda:<slot>:<idx>:<day>(请求/token)与 uex:(耗尽次数) 日桶, 复用内核 usage::bump_day —— 无数据库、无新进程(项目红线) - 计数点只在 log 阶段一次;pick_account 会被 $llm_target/$llm_auth/$llm_acct 三个变量各触发一次,放进那里会三倍计数 - view() 投影带每账号 load 与 account_trend + trend_labels(日期由后端算) - 管理台「上游」页密钥列:各 Key 今日请求/token/耗尽 + 负载比例条 + 14 天迷你趋势(自绘 SVG,零第三方依赖)+ 冷却/耗尽徽标 + 上游合计 测试与验证 - 回归 279 条全绿(网关 102 + LLM 177),新增 6 条多账号/负载断言 - 假上游新增 UPSTREAM_FAIL_AUTH 模拟账号额度耗尽;靶机验证 Key 真被替换 - 前端以真实 admin.css + upstreams.js 渲染路径做无头浏览器断言: 比例条与负载成比例(412 vs 96 → 100%/23%)、每账号 14 条块、 悬停峰值日期与数据逐位吻合、单账号/无账号兜底正常、无横向溢出、零 JS 错误 文档 - 新增 docs/llm/MULTI_ACCOUNT_ROUTING.md(数据模型/路由/冷却数学/shm 布局/负载统计) - readme §11 数据模型 + §15 上游配置 + §15 用量统计 + §12.6 tag 表 + §16 变更记录 - 修正 docs/llm/*.md 中插件化前的过时路径(rust/src/* → crates/plugin-llm/src/*)
This commit is contained in:
1 parent
db99ce1521
commit
bfa3cf8ff8
21 files changed
+1506
-85
No files matched your search
@@ -183,3 +183,23 @@ button.host-copy:hover{text-decoration:underline solid}
|
||||
/* 弹窗内表单同样限宽两列,窄屏单列;spa-all 跨整行由通用 .grid-form 规则保证 */
|
||||
.modal-body .grid-form.up-form{grid-template-columns:repeat(2,1fr)}
|
||||
@media (max-width:600px){.modal-body .grid-form.up-form{grid-template-columns:1fr}}
|
||||
/* 多账号上游:宽弹窗 + 账号行 */
|
||||
.modal-card.modal-wide{max-width:860px}
|
||||
.acct-list{display:flex;flex-direction:column;gap:10px;margin-bottom:8px}
|
||||
.acct-row{border:1px solid var(--border);border-radius:8px;padding:10px 12px;background:var(--bg);
|
||||
display:flex;flex-direction:column;gap:8px}
|
||||
.acct-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
|
||||
.acct-row .acct-auth,.acct-row .acct-note,.acct-row .acct-resets{width:100%}
|
||||
.acct-row .acct-del{margin-left:auto}
|
||||
.acct-empty{font-size:12.5px;padding:6px 0}
|
||||
|
||||
/* 上游「密钥」列:每账号负载块(请求/token/耗尽 + 比例条 + 14天迷你趋势)*/
|
||||
.acct-load{padding:4px 0;border-bottom:1px dashed #eef1f5}
|
||||
.acct-load:last-child{border-bottom:0}
|
||||
.acct-load .load-line{font-size:11.5px;color:var(--muted);margin:2px 0 3px}
|
||||
.acct-load .load-bar{height:5px;background:#eef1f5;border-radius:3px;overflow:hidden}
|
||||
.acct-load .load-bar span{display:block;height:100%;background:var(--c-req);border-radius:3px}
|
||||
.spark{margin-top:3px}
|
||||
.spark-svg{display:block}
|
||||
.spark-svg .s-bar{fill:var(--c-req)}
|
||||
.spark-svg .s-zero{fill:#e6eaf0}
|
||||
Reference in new issue
Block a user