一个 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/*)
37 lines
1.4 KiB
HTML
37 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<base href="/admin/">
|
||
<title>LLM 上游 · 尚数网 山海关</title>
|
||
<link rel="stylesheet" href="assets/admin.css">
|
||
</head>
|
||
<body>
|
||
<div id="shell"></div>
|
||
|
||
<div class="wrap">
|
||
<div class="panel">
|
||
<div class="panel-head">
|
||
<div>
|
||
<h2>上游列表</h2>
|
||
<div class="desc">slot 即 URL 前缀:客户端把 base_url 指向 <code>https://lm.mayishangshu.cn/<slot>/v1</code> 并携带其账号 API Key,网关把 Key 换成本处配置的上游密钥后转发。一家厂商通常挂很多模型,把模型名登记在这里,客户端就能通过 <code>GET /v1/models</code> 或 <code>GET /api/v1/models</code> 先列出可用模型再调用。停用的上游对客户端表现为 404;删除不可恢复,指向它的调用会立即失败。</div>
|
||
</div>
|
||
<button class="btn-primary btn-sm" id="newUpBtn">+ 新建上游</button>
|
||
</div>
|
||
<table>
|
||
<thead><tr>
|
||
<th>slot</th><th>上游地址</th><th>密钥 / 负载</th><th>模型</th><th>备注</th><th>状态</th><th>创建时间</th><th>操作</th>
|
||
</tr></thead>
|
||
<tbody id="upstreamsBody"></tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="toast"></div>
|
||
|
||
<script src="assets/core.js"></script>
|
||
<script src="assets/upstreams.js"></script>
|
||
</body>
|
||
</html>
|