' +
- '
' + esc(m.display_name || m.mid || m.id) + '
' +
+ '
' + esc(m.display_name || m.mid || m.id) +
+ (title ? ' ' + title.trim() + '' : '') + '
' +
'
' +
(m.vision ? '
Vision' : '') +
'
Thinking' +
@@ -824,17 +822,16 @@ const ui = {
}).join('');
return '
' +
'' +
itemHtml +
'
';
}).join('');
- footer && (footer.textContent = '共 ' + totalAvailable + ' / ' + totalAll + ' 个模型可用');
+ footer && (footer.textContent = '共 ' + avail + ' 个模型可用');
} catch (e) {
list.innerHTML = '
读取模型列表失败:' + e.message + '
';
- footer && (footer.textContent = '');
}
},
closeModelSwitch() { $('bind-model-modal').classList.add('hidden'); },
diff --git a/app/server/server.js b/app/server/server.js
index e099f47..75cef15 100644
--- a/app/server/server.js
+++ b/app/server/server.js
@@ -43,11 +43,30 @@ app.use('/api/config', require('./routes/config'));
app.use('/api/platforms', require('./routes/platforms'));
app.use('/api/system', require('./routes/system'));
-// 模型池状态(前端可展示空闲/占用)+ 每模型 token 用量(今日/累计,输入/输出分开)
+// 模型池状态(前端可展示空闲/占用)+ 每模型 token 用量(今日/累计,输入/输出分开)。
+// 从生效配置补齐平台维度字段(platform/mid/vision/type + 平台 key 数 key_count):
+// model_pool 表只有 id/display_name/占用态,会话页「选择模型」弹窗需要按平台分组展示。
+// 配置里新增但重启前未进池的模型不在此返回(池才是运行时真相)。
app.get('/api/models', (req, res) => {
const rows = db.prepare('SELECT id, display_name, is_busy, current_session_id FROM model_pool ORDER BY id').all();
const stats = engine.modelUsageStats();
+ // 配置视图:模型唯一键 → 平台/原始 id/vision;平台名 → key 数(cfg.models 含 key 副本,不能直接拿来用)
+ const cfgNow = engine.getConfig();
+ const infoById = {};
+ const keyCountByPlat = {};
+ for (const p of cfgNow.platforms || []) {
+ keyCountByPlat[p.name] = (p.keys || []).length;
+ for (const m of p.models || []) {
+ infoById[p.name + '/' + m.id] = { platform: p.name, mid: m.id, vision: !!m.vision, type: p.type };
+ }
+ }
for (const r of rows) {
+ const info = infoById[r.id] || {};
+ r.platform = info.platform || '';
+ r.mid = info.mid || '';
+ r.vision = info.vision || false;
+ r.type = info.type || '';
+ r.key_count = keyCountByPlat[r.platform] || 0;
const s = stats[r.id] || {};
r.today_prompt = s.today_prompt || 0;
r.today_completion = s.today_completion || 0;
diff --git a/app/test/config.test.yml b/app/test/config.test.yml
index 24c7167..a807b64 100644
--- a/app/test/config.test.yml
+++ b/app/test/config.test.yml
@@ -4,22 +4,22 @@ platforms:
- name: mock-a
url: "http://127.0.0.1:9999/v1"
type: openai
+ models:
+ - id: ds1
+ display_name: "Mock Model 1"
+ vision: true
keys:
- api_key: ""
- models:
- - id: ds1
- display_name: "Mock Model 1"
- vision: true
- name: mock-b
url: "http://127.0.0.1:9999/v1"
type: custom
+ models:
+ - id: ds2
+ display_name: "Mock Model 2"
+ vision: true
keys:
- api_key: ""
concurrency: 1
- models:
- - id: ds2
- display_name: "Mock Model 2"
- vision: true
workspace_root: "./test/tmp/tasks"
# 隔离数据目录:db/启动 prompt dump 落 tmp(随每次运行的 rm -rf 一同清掉),
diff --git a/app/test/smoke.js b/app/test/smoke.js
index 8820a21..436ca0d 100644
--- a/app/test/smoke.js
+++ b/app/test/smoke.js
@@ -258,7 +258,7 @@ async function main() {
try { await api('PUT', '/api/config', { text: 'models: [unclosed' }); } catch (e) { bad400 = /400/.test(e.message); }
ok(bad400, 'PUT 非法配置被 400 拒绝');
ok(fs.readFileSync(cfgPath, 'utf8') === rawBeforeBadPut, '非法写入未动文件');
- const mpatch = await api('PATCH', '/api/config', { path: 'platforms.0.keys.0.models.0.display_name', value: '改名模型' });
+ const mpatch = await api('PATCH', '/api/config', { path: 'platforms.0.models.0.display_name', value: '改名模型' });
const mtext = (await api('GET', '/api/config')).text;
ok(mpatch.ok && mtext.includes('改名模型'), 'PATCH 支持 platforms 嵌套数组下标');
const restored = await api('PUT', '/api/config', { text: origText });