Repository navigation
Conversation
现象:供应商 baseUrl 配成 Anthropic 兼容端点(如 https://api.deepseek.com/anthropic)时, 界面「拉取模型」报「获取模型失败,请检查 api key」,实际 key 有效、同域名根路径 https://api.deepseek.com/models 返回 200。 原因:三处取模型列表的逻辑都只在 baseUrl 后面拼 /v1/models 与 /models, 带子路径的 baseUrl 在子路径下没有 /models,全部 404。 改动:在保留原有候选顺序的前提下,追加同域名根路径作为兜底候选: - zcode_patcher.py(注入主进程的 fetch handler) - zcode-model-puller.js(渲染层无 IPC 时的兜底路径) - model_pull.py(CLI) 验证:python -m unittest discover -s tests 全绿(282 passed, 6 skipped); 用 DeepSeek 实际配置的 baseUrl 调用 fetch_models_from_api 成功,自动回退到 https://api.deepseek.com/v1/models 并取回模型列表。
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.
现象
供应商 Base URL 使用 Anthropic 兼容端点(例如
https://api.deepseek.com/anthropic)时,设置页「⚡️ 自动拉取模型」报 “未能获取到模型列表,请检查 Base URL 和 API Key”,但 Key 本身有效。同一 Key 实测:
https://api.deepseek.com/anthropic/v1/modelshttps://api.deepseek.com/anthropic/modelshttps://api.deepseek.com/v1/modelshttps://api.deepseek.com/models原因
三处拉取逻辑都只在给定 baseUrl 后拼接
/v1/models与/models。带子路径的 baseUrl(/anthropic、/openai、各类网关前缀)在子路径下通常没有模型列表接口,于是全部 404,界面统一提示“检查 API Key”。改动
保留原有候选顺序,仅追加同域名根路径作为兜底(不走子路径,Key 仍发往同一 host):
zcode_patcher.py:注入主进程的zcode:fetch-models-from-urlhandlerzcode-model-puller.js:渲染层无 IPC 时的兜底 fetch 路径model_pull.py:CLI 的fetch_models_from_api以
https://api.deepseek.com/anthropic为例,候选顺序变为:对原有 OpenAI 兼容 baseUrl 行为无影响:根路径候选已存在时会去重,且只会在前面的子路径候选失败后才被请求。
验证
python -m unittest discover -s tests:282 passed, 6 skippedfetch_models_from_api():成功回退到https://api.deepseek.com/v1/models并取回模型列表node --check zcode-model-puller.js通过