Fix stale WebUI provider model options#203
Merged
EterUltimate merged 1 commit intoJun 11, 2026
Merged
Conversation
Contributor
Reviewer's GuideAdds live model discovery for WebUI provider options by querying provider get_models() or OpenAI-compatible /v1/models endpoints, wiring the results into the config schema and provider option labels while caching lookups per schema request and falling back to configured models if live data is unavailable. Sequence diagram for live provider model discovery in get_config_schemasequenceDiagram
participant WebUI as WebUI
participant ConfigService as ConfigService
participant Provider as Provider
participant HTTP as OpenAI_Models_Endpoint
WebUI->>ConfigService: get_config_schema()
ConfigService->>ConfigService: _provider_options_async("chat_completion", model_cache)
loop for each provider
ConfigService->>ConfigService: _provider_option_async(provider, "chat_completion", model_cache)
ConfigService->>ConfigService: _provider_identity(provider, "chat_completion")
ConfigService->>ConfigService: _models_from_provider_instance(provider, provider_id, provider_type, model_cache)
alt provider has get_models
ConfigService->>Provider: get_models()
Provider-->>ConfigService: models_payload
ConfigService->>ConfigService: _normalize_model_list(models_payload)
else no get_models or empty result
ConfigService->>ConfigService: _models_from_provider_config(provider.provider_config, provider_type, model_cache)
ConfigService->>ConfigService: _provider_api_base(provider_config, provider_type)
ConfigService->>ConfigService: _models_url_from_api_base(api_base)
ConfigService->>ConfigService: _provider_api_key(provider_config, provider_type)
ConfigService->>HTTP: _fetch_models_from_endpoint(models_url, api_key, custom_headers)
HTTP-->>ConfigService: JSON models payload
ConfigService->>ConfigService: _models_payload_to_list(payload)
end
ConfigService->>ConfigService: _build_provider_option(provider_id, model_name, provider_type, models)
end
ConfigService->>ConfigService: _dedupe_options(provider_options)
ConfigService-->>WebUI: schema with groups, provider_options, provider_options_by_type
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
5087b2d to
d66383d
Compare
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The new asynchronous provider option flow duplicates much of the logic that still exists in the synchronous
_provider_optionspath; consider consolidating common pieces (e.g., iteration over provider_manager/context) to a single implementation to reduce maintenance overhead and the risk of divergence. - In
_provider_options_async, model discovery for each provider is performed sequentially with awaited calls; if you expect many providers, consider batching these withasyncio.gather(while still honoring the per-call timeout) to avoid slow schema generation under higher provider counts.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new asynchronous provider option flow duplicates much of the logic that still exists in the synchronous `_provider_options` path; consider consolidating common pieces (e.g., iteration over provider_manager/context) to a single implementation to reduce maintenance overhead and the risk of divergence.
- In `_provider_options_async`, model discovery for each provider is performed sequentially with awaited calls; if you expect many providers, consider batching these with `asyncio.gather` (while still honoring the per-call timeout) to avoid slow schema generation under higher provider counts.
## Individual Comments
### Comment 1
<location path="webui/services/config_service.py" line_range="1466-1467" />
<code_context>
field_spec["provider_type"] or "Provider",
)
- field_spec["options"] = self._provider_options(field_spec["provider_type"])
+ if provider_options_by_type is not None:
+ field_spec["options"] = provider_options_by_type.get(
+ field_spec["provider_type"],
+ [],
</code_context>
<issue_to_address>
**issue (bug_risk):** Fields with no explicit provider_type now get no options when provider_options_by_type is used.
With this change, when `field_spec["provider_type"]` is empty or not in `provider_options_by_type`, `field_spec["options"]` becomes an empty list, whereas previously `_provider_options(...)` returned a broad/default set so generic provider fields still had choices.
This affects fields where `_provider_expected_type_for_field` returns `None`, and any future field whose type isn’t in `{"chat_completion", "embedding", "rerank"}`. To avoid regressing those fields, you could:
- Fall back to a combined options list when `provider_type` is empty (e.g. the flattened `provider_options` from `get_config_schema`), or
- Use a default like `provider_options_by_type.get(provider_type) or provider_options_by_type.get("chat_completion", [])` when `provider_type` is falsey.
This preserves the async prefetching while ensuring generic provider fields still show options.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
d66383d to
5b69b55
Compare
Collaborator
Author
|
Addressed the Sourcery bug-risk note in 5b69b55: generic provider fields with no explicit provider_type now use the combined prefetched provider options, with a unit test covering the fallback. |
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
Tests
Notes
Summary by Sourcery
Fetch and surface live provider model lists in the WebUI config schema so provider options stay in sync with currently available models, falling back to configured models when live discovery is unavailable.
New Features:
Enhancements:
Tests: