Fix custom provider support for base_url and list-format models#12045
Closed
PaulMa-Lab wants to merge 1 commit into
Closed
Fix custom provider support for base_url and list-format models#12045PaulMa-Lab wants to merge 1 commit into
PaulMa-Lab wants to merge 1 commit into
Conversation
- Add dynamic provider loading in CLI argparse (main.py)
- Support base_url field in model picker (model_switch.py)
- Accept list-format models in normalization (config.py)
Fixes custom providers configured with:
providers:
custom-name:
base_url: https://...
models: [model1, model2, ...]
Before: CLI rejected provider, picker showed duplicates with 0 models
After: Provider works correctly with all models loaded
Contributor
|
Closing in favor of #13509, which solves the same |
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.
Summary
This PR fixes three bugs that prevent custom providers from working correctly when using the v12+
providers:configuration format withbase_urlfield and list-formatmodels.Problem
Users configuring custom providers like this:
Experience three issues:
hermes chat --provider alibaba-codingfails with "invalid choice"Root Causes
Bug 1: Hardcoded provider choices in CLI (main.py:6427)
The
--providerargument used a hardcoded list of builtin providers, rejecting any custom providers defined in config.Bug 2: Missing base_url field check (model_switch.py:1043)
The user_providers section only checked
apiandurlfields, but the newer config format usesbase_url(matching OpenAI-compatible API conventions).Bug 3: Models field type mismatch (config.py:1831)
The normalization function only accepted dict-format models:
But list-format (which is more intuitive for simple provider configs) was rejected, causing models to be dropped during normalization.
Changes
1. Dynamic provider loading (main.py)
_get_provider_choices()function that loads config at argparse setup timeconfig.yaml2. Support base_url field (model_switch.py)
base_urlfirst, thenapi, thenurl3. Accept list-format models (config.py)
dictto(dict, list)Testing
Before fix:
After fix:
Impact
Checklist