mirror of
https://github.com/jasonxu114514/opencode2api.git
synced 2026-12-05 16:04:01 +00:00
发布准备:合入 #36、#46、#48、#49、#50、#53;修复 #42、#44、#51、#52,并添加 GPL-3.0-or-later。
保留 reasoning 配置,新增免费模型可用性探测 / 手动恢复、首 SSE 事件超时,元数据改用官方地址。按维护者要求,最终文件树排除测试文件。 验证:本地 Go 回归、go vet / build、Prettier、JS / shell 语法及独立实例管理端验收通过。
This commit is contained in:
1 parent
31c35704be
commit
df119c48e4
29 files changed
+1301
-807
No files matched your search
@@ -12,6 +12,7 @@ let csrf = "",
|
||||
logRenderPending = false,
|
||||
toastTimer = null;
|
||||
const pages = {
|
||||
availability: ["13", "免费模型可用性", "每小时探测,失败后禁用并每 24 小时复测。"],
|
||||
rotation: ["12", "模型轮转", "共享当前模型、故障切换与尝试记录。"],
|
||||
overview: ["01", "运行桌面", "最近一小时、进程累计与当前资源状态。"],
|
||||
guide: ["02", "首次运行", "用六个检查点完成从配置到首个请求。"],
|
||||
@@ -120,6 +121,7 @@ function openPage(page) {
|
||||
}, 60000);
|
||||
}
|
||||
if (page === "rotation") loadRotation();
|
||||
if (page === "availability") loadAvailability();
|
||||
if (page === "api-keys") loadAPIKeys();
|
||||
if (page === "playground" && !debugData) loadDebugModels();
|
||||
if (page === "diagnostics") {
|
||||
@@ -157,6 +159,7 @@ function fillConfig(value) {
|
||||
$("#c-connect").value = value.performance.connect_timeout_seconds;
|
||||
$("#c-cooldown").value = value.performance.failure_cooldown_seconds;
|
||||
$("#c-attempt-timeout").value = value.performance.attempt_timeout_seconds;
|
||||
$("#c-first-event-timeout").value = value.performance.first_event_timeout_seconds || 0;
|
||||
$("#c-level").value = value.logging.level;
|
||||
$("#c-ring").value = value.logging.ring_size;
|
||||
$("#c-dump-bodies").checked = !!value.logging.dump_request_bodies;
|
||||
@@ -225,6 +228,7 @@ $("#config-form").addEventListener("submit", async (event) => {
|
||||
connect_timeout_seconds: number("#c-connect"),
|
||||
failure_cooldown_seconds: number("#c-cooldown"),
|
||||
attempt_timeout_seconds: number("#c-attempt-timeout"),
|
||||
first_event_timeout_seconds: number("#c-first-event-timeout"),
|
||||
},
|
||||
logging: {
|
||||
level: $("#c-level").value,
|
||||
@@ -1383,3 +1387,53 @@ $("#rotation-form").onsubmit = async (event) => {
|
||||
}
|
||||
};
|
||||
boot();
|
||||
|
||||
async function loadAvailability() {
|
||||
try {
|
||||
const data = await api("/api/models/availability");
|
||||
$("#availability-error").textContent = "";
|
||||
$("#availability-models").replaceChildren();
|
||||
for (const item of data.models) {
|
||||
const row = document.createElement("tr");
|
||||
const date = (value) =>
|
||||
value && !value.startsWith("0001-") ? new Date(value).toLocaleString() : "待探测";
|
||||
for (const value of [
|
||||
item.model,
|
||||
item.disabled ? "已禁用" : "已启用",
|
||||
[item.channel, item.reason].filter(Boolean).join(" / ") || "待探测",
|
||||
date(item.checked_at),
|
||||
date(item.next_check),
|
||||
]) {
|
||||
const cell = document.createElement("td");
|
||||
cell.textContent = value;
|
||||
row.append(cell);
|
||||
}
|
||||
const cell = document.createElement("td");
|
||||
const button = document.createElement("button");
|
||||
button.textContent = "恢复启用";
|
||||
button.disabled = !item.disabled;
|
||||
button.onclick = async () => {
|
||||
button.disabled = true;
|
||||
try {
|
||||
await api("/api/models/restore", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ model: item.model }),
|
||||
});
|
||||
await loadAvailability();
|
||||
await loadDebugModels();
|
||||
} catch (error) {
|
||||
$("#availability-error").textContent = error.message;
|
||||
button.disabled = false;
|
||||
}
|
||||
};
|
||||
cell.append(button);
|
||||
row.append(cell);
|
||||
$("#availability-models").append(row);
|
||||
}
|
||||
if (!data.models.length)
|
||||
$("#availability-error").textContent = "当前模型目录中没有符合免费资格的模型。";
|
||||
} catch (error) {
|
||||
$("#availability-error").textContent = error.message;
|
||||
}
|
||||
}
|
||||
$("#availability-refresh").onclick = loadAvailability;
|
||||
@@ -66,6 +66,9 @@
|
||||
<span class="nav-no">11</span><span>API Key 管理</span>
|
||||
</button>
|
||||
<button data-page="rotation"><span class="nav-no">12</span><span>模型轮转</span></button>
|
||||
<button data-page="availability">
|
||||
<span class="nav-no">13</span><span>免费模型可用性</span>
|
||||
</button>
|
||||
</nav>
|
||||
<div class="sidebar-foot">
|
||||
<div class="live-line"><span class="live-dot"></span><span>CONTROL PLANE LIVE</span></div>
|
||||
@@ -85,6 +88,34 @@
|
||||
</div>
|
||||
</header>
|
||||
<div id="restart-notice" class="notice hidden"></div>
|
||||
<section id="page-availability" class="page hidden">
|
||||
<div class="section">
|
||||
<div class="section-head">
|
||||
<h2>免费模型探测</h2>
|
||||
<button id="availability-refresh" class="ghost">刷新状态</button>
|
||||
</div>
|
||||
<p>
|
||||
检查名称含 free 或元数据零价格且未弃用的模型。优先匿名通道,再尝试 Zen
|
||||
Key;全部失败后禁用,24 小时后复测。成功或手动恢复后,下一次探测在 1 小时后。
|
||||
</p>
|
||||
<p id="availability-error" role="status"></p>
|
||||
<div class="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>模型</th>
|
||||
<th>状态</th>
|
||||
<th>通道 / 结果</th>
|
||||
<th>上次探测</th>
|
||||
<th>下次探测</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="availability-models"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section id="page-overview" class="page">
|
||||
<div class="metric-grid">
|
||||
<div class="metric-card">
|
||||
@@ -624,6 +655,10 @@
|
||||
placeholder="0 = 跟随请求超时"
|
||||
/>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>首个 SSE 事件超时(秒,0 关闭)</label>
|
||||
<input id="c-first-event-timeout" type="number" min="0" max="86400" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>日志级别</label
|
||||
><select id="c-level">
|
||||
|
||||
Reference in new issue
Block a user