桌面端自定义模型添加缺少「根据 Base URL + API Key 自动获取可用模型」功能
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.7k
- Forks
- 719
- Avg merge
- 4h 30m
- Merged PRs (30d)
- 83
Description
问题描述
桌面端(MonkeyCode work)「设置 → 模型」中添加自定义模型时,只能手工填写模型标识(模型 ID 字符串),缺少根据 Base URL + API Key 自动获取可用模型列表的功能。
作为对比,Web 控制台(frontend)的「配置大模型」表单已有此能力:填写 API Token 与 Base URL 后,可一键拉取该服务商支持的模型列表并在下拉框中选择。桌面端缺失同一能力,两端体验不一致。
影响
- 手工填写模型标识极易出错(填错一个字符模型即不可用),需要用户自己去服务商文档查模型 ID;
- 对本地 Ollama / 开源网关等没有"官方模型名单"认知的场景,用户无从得知正确 ID;
- 与 Web 端已具备的交互相比,桌面端模型接入门槛明显偏高。
证据(代码位置)
桌面端自定义模型表单(纯手填,无获取逻辑):
desktop/ui-next/src/features/settings/ModelsSection.tsx— 展开表单仅含:名称 / 协议 / 接口地址 / API Key / 模型标识 / 上下文窗口 / 最大输出 / 思考深度 / 图片输入,无"获取模型"入口;desktop/ui-next/src/lib/ipc/config.ts— 设置域 IPC 只有get_config/save_config,无获取模型列表命令;desktop/src/config.rs— 壳仅把models数组物化进引擎设置,无探测逻辑;- i18n 文案(
desktop/ui-next/src/lib/i18n/zh.ts的settings.models.customEmpty)也明确写的是"手工接入……需要名称、接口地址、API Key 与模型标识"。
Web 控制台已有该能力:
frontend/src/components/console/settings/add-model.tsx/edit-model.tsx—fetchModelList()调GET /api/v1/users/models/providers?api_key=...&base_url=...&provider=...,结果在ProviderModelCombobox中选择;- 后端接口已在
backend/docs/swagger.json中登记(get-provider-model-list)。
建议方案
在桌面端自定义模型的「模型标识」字段旁增加「获取模型列表」按钮,点击后:
- 由 Tauri 壳(Rust)直接请求供应商接口(而不是复用后端
/api/v1/users/models/providers):- openai / openai_responses:
GET {base_url}/models,Authorization: Bearer {api_key}; - anthropic:
GET {base_url}/v1/models(兼容回退{base_url}/models),x-api-key: {api_key}; - 兼容 Ollama 等本地服务(
{base_url}/models,无鉴权或 Bearer)。
- openai / openai_responses:
- 解析
data[].id/models[]返回模型 ID 列表,在下拉框中展示,选择后填入「模型标识」;失败时保留手工输入并展示明确错误信息。
选择壳侧直连的原因:
- 桌面端自定义模型本就存储在本地
config.json、由本地引擎消费,不依赖 MonkeyCode 后端登录态; - 可绕开 #904(后端 SSRF 加固把合法地址也报成"参数无效"的回归 bug),本地应用直接请求用户自填地址也不存在服务端 SSRF 风险。
关联
- #904:Web 端同一功能的 SSRF 加固回归问题(若走后端复用会继承该 bug)。
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with desktop/ui-next/src/features/settings/ModelsSection.tsx and desktop/ui-next/src/lib/ipc/config.ts, then trace the Rust shell in desktop/src/config.rs. Compare the existing provider flow in frontend/src/components/console/settings/add-model.tsx and edit-model.tsx with the documented provider responses. Done means custom-model users can fetch, select, and save model IDs, while failed requests preserve manual input and show a clear error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ollama, rust, tauri, typescript
- Domain
- api, desktop
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 64/100