feat(agents): 模型改为页面可选(方案 A)+ 修引擎模型读不到的静默 bug(版本 2.5.4 → 2.6.0)
推翻旧结论:模型不是全局唯一,而是每个 profile 各存一份 active_model (PUT /api/models/active scope=agent → workspaces/<profile>/agent.json), 改完即时生效不用重启 —— 实测切模型后真对话 turn_usage 的 model_name 确实变了。 真 bug:refresh_engine_live() 读的是 /api/providers/active,那条是 404, 异常被吞 → engine_live['model'] 恒为空串 → 配置页模型栏一直显示「—」。 改用 ACTIVE_MODEL_PATH=/api/models/active + get_active_model()。 新增: - 适配器 get_active_model / set_active_model(4xx 抛 EngineError 并透传引擎原文) - GET /agents/engine/models(只列真能用的;实时 current,不走 TTL 缓存) - PUT /agents/engine/model(带防自指护栏,不得指向 agent/*) - 前端配置页模型栏:只读 → 可搜索下拉(按供应商分组 + 视觉标)+ 刷新;失败回滚 - i18n 删过期键、加 5 新键(中英 883/883 对称) - 测试 +5(端点/路径常量回归/body 与头/4xx 抛错/防自指),224 passed 语义:方案 A = 所有智能体共用这一个模型(一个 profile 一个 active_model), 做不到 A 用 flash 且 B 用 pro 并存;那需方案 B(一智能体一 profile)。
This commit is contained in:
1 parent
a92fc3c788
commit
678b984b95
9 files changed
+428
-27
No files matched your search
@@ -89,6 +89,29 @@ export const testAgent = (slug: string) =>
|
||||
export const agentSessions = (slug: string) =>
|
||||
req<{ slug: string; kind: string; items: any[] }>(`/agents/${slug}/sessions`)
|
||||
|
||||
/** 引擎可选模型清单 + 当前生效模型(第四十轮 · 方案 A:所有智能体共用)。 */
|
||||
export interface EngineModelOption {
|
||||
provider_id: string
|
||||
provider_name: string
|
||||
model: string
|
||||
vision: boolean
|
||||
}
|
||||
export interface EngineModelsResp {
|
||||
options: EngineModelOption[]
|
||||
current: { provider_id: string; model: string }
|
||||
engine: { base_url: string; agent_id: string; ready: boolean }
|
||||
scope_note: string
|
||||
}
|
||||
|
||||
export const engineModels = () => req<EngineModelsResp>('/agents/engine/models')
|
||||
|
||||
/** 切换引擎模型(即时生效,不用重启)。 */
|
||||
export const setEngineModel = (providerId: string, model: string) =>
|
||||
req<{ status: string; current: { provider_id: string; model: string } }>(
|
||||
'/agents/engine/model',
|
||||
{ method: 'PUT', body: JSON.stringify({ provider_id: providerId, model }) },
|
||||
)
|
||||
|
||||
export const stopAgent = (slug: string, chatId: string) =>
|
||||
req<{ status: string }>(`/agents/${slug}/stop?chat_id=${encodeURIComponent(chatId)}`, { method: 'POST' })
|
||||
|
||||
|
||||
Reference in new issue
Block a user