fix: hermes apply switch defaults updates base url from settings#2333
fix: hermes apply switch defaults updates base url from settings#2333lehug wants to merge 1 commit intofarion1231:mainfrom
Conversation
|
❯ 假如config.yaml中这样配置,model:
● 我需要先理解代码结构,搜索相关的provider和api_key选择逻辑。 Searched for 14 patterns, read 4 files, listed 1 directory (ctrl+o to expand) ● 根据代码分析,当 model.provider: provider1 时,使用的是 custom_providers 中的 api_key: xxx2。 完整执行逻辑
resolve_runtime_provider → _get_named_custom_provider("provider1") 在 hermes_cli/runtime_provider.py:318-430 中查找逻辑: 1. 先检查 providers: dict(新格式)- 不匹配providers = config.get("providers") # 用户配置没有这个 2. 查找 custom_providers: list(legacy格式)custom_providers = get_compatible_custom_providers(config)
_resolve_named_custom_runtime(hermes_cli/runtime_provider.py:435-484): api_key_candidates = [
{ 关键点 ┌──────────────────────────────────┬────────┬───────────────────────────┬─────────────────┐ 结论: 当 model.provider: provider1 时,代码通过 resolve_custom_provider 匹配到 custom_providers |
|
本地验证了, #2301 这个问题 能解决。即使他的provider应该是 mimimax-cn,然后通过.env匹配key。但是因为有provider匹配到了api_key。然后api_key, base_url,model_name都匹配,接口能通 |
|
考虑切换的时候,舍弃base_url,但是发现test model这块对于当前使用的,会因为缺失base_url而失败。所以当前这个方案虽然数据多余,但是比舍弃base_url的方案更好 |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9922b66f25
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| // Extract base_url from new provider's settings if present. | ||
| let base_url = settings_config | ||
| .get("base_url") |
There was a problem hiding this comment.
Handle legacy baseUrl when applying switch defaults
apply_switch_defaults only reads settings_config["base_url"], but this codebase explicitly supports legacy Hermes provider records with camelCase keys (see the sanitizer comments/tests around baseUrl handling). When such a provider is switched to, this branch returns None and falls back to the previous model.base_url, so requests can keep targeting the old provider endpoint even after a successful switch. Consider checking both base_url and baseUrl (or normalizing first) before merging.
Useful? React with 👍 / 👎.
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
|
@farion1231 changed |
Summary / 概述
hermes切换时,model的baseUrl未变更,导致配置不完整,不可用。
Related Issue / 关联 Issue
Fixes #
Screenshots / 截图
Checklist / 检查清单
pnpm typecheckpasses / 通过 TypeScript 类型检查pnpm format:checkpasses / 通过代码格式检查cargo clippypasses (if Rust code changed) / 通过 Clippy 检查(如修改了 Rust 代码)