release v0.9.7-rc.1: Ollama 本地模型发现/使用 + 模型测试选模型 + context window fallback - #296
Merged
Conversation
- chatDirect 支持 altModel:临时 configure 切换模型并恢复,测试接口可指定被测模型 - POST /api/settings/llm/providers/:name/test 读取 body.model 并回显实际被测模型 - Settings 页测试按钮旁新增「测试用模型」下拉(数据源=live/catalog/已配置/本地 detect) - GET /api/models/live/ollama 探测本地 /api/tags,让 Ollama 真实模型进入选择器(此前无 key 落到静态 catalog) - OllamaProvider.chat/chatStream 请求体尊重 request.model(此前硬编码 this.model) - 新增单测:chatDirect 切换/恢复模型;Ollama 上线模型覆盖;/api/models/live/ollama
- 移除页面中独立的 Local Ollama 检测区块 - 展开 Ollama provider 时自动检测本地服务并列出本地模型 - 未配置:一键选用模型配置 Ollama(无需 API Key) - 已配置:一键切换当前模型,模型列表保留可反复切换 - 复用 ollama.* i18n key,无新增文案
根因:getEnhancedSettings().providers[name].models 只来自内置 catalog +
customModelCatalog,从不探测真实可用模型:
- 内置 catalog 无 ollama 条目 → Ollama picker 为空 → chat 模型选择器把它过滤掉('只能选 markus')
- 新增自定义 provider 无 catalog → models 空同样被过滤
修复:
- getProviderModels('ollama') 优先返回本地探测到的模型(替换静态 catalog)
- 新增 refreshOllamaLocalModels():探测 /api/tags 把本地模型写入 customModelCatalog
- 新增 refreshProviderLiveModels():对无 catalog 的 provider 拉 /v1/models 填充
- GET /api/settings/llm 与 POST/PUT provider 时触发同步(可选调用,测试 mock 安全)
验证:新增 5 个单测全绿(含真实 localhost:11434 集成验证:qwen3.8:27b-mlx、
qwen3.6:latest 进入 enhanced settings);org-manager 1126 测试通过;typecheck/lint 0 errors
Local models synced from /api/tags had hardcoded contextWindow:0 /
maxOutputTokens:0, which tripped the fail-loud getModelContextWindow
guard during agent budget planning ("Cannot resolve context_window ... unknown
to the built-in catalog") as soon as a local model (e.g. qwen3.8:27b-mlx)
was selected as the active model.
- refreshOllamaLocalModels now probes each model via /api/show and reads
model_info["*.context_length"] (family-agnostic key) into the catalog
- probe failure falls back to a sane default (8192 ctx / 4096 max out)
instead of poisoning the catalog with 0
- verified against a real local Ollama: qwen3.8:27b-mlx -> 262144 ctx
… defaults The fail-loud policy broke ANY model absent from the built-in/Hub catalog (private BYOK, self-hosted, unknown ids): getModelContextWindow / getModelMaxOutput threw 'No default is substituted', aborting the whole agent turn. New policy (all providers, all models): 1. custom model config (user-tuned override) — highest priority 2. built-in / Hub catalog entry — real value when known 3. fallback defaults + warn log — NEVER throw, so any real model still works Fallbacks: context_window=128k, max_output=32k (kept deliberately larger so the derived message budget is never negative). Verified: unknown model -> 128k, real local Ollama -> 262144 (true value still preferred), markus empty catalog -> 128k.
… context window fallback)
- router.ts refreshOllamaLocalModels: 新增 probeOllamaModel 读取 /api/show 的 capabilities, 将 vision->inputTypes['text','image']、thinking->reasoning、 tools->capabilities, 修复 ollama 本地视觉模型被硬编码 vision:false 导致无法在'图片识别'能力下拉中选中的问题 - router.ts refreshProviderLiveModels: 防御性读取 OpenAI 兼容网关 /v1/models 的 architecture.input_modalities / capabilities / vision 字段 - api-server.ts: ollama 列模型分支去掉硬编码 vision:false, 逐个探测能力; Google Gemini generateContent 模型标 vision:true; extractApiMetadata 兜底 扩展读取能力字段 - test: 新增 ollama vision 能力映射单测 Close: 本地 qwen3.8:27b-mlx 等视觉模型现在可正确出现在图片识别候选列表
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Version bump v0.9.7-rc.0 → v0.9.7-rc.1