fix: /model command — bare provider names, custom endpoint display
Two issues with /model preventing proper provider switching: 1. Bare provider names not detected: typing '/model nous' treated 'nous' as a model name instead of triggering a provider switch. Fixed by adding step 0 in detect_provider_for_model() that checks if the input matches a known provider name/alias (excluding 'custom'/'openrouter' which need explicit model names) and returns that provider's default model. 2. Custom endpoint details hidden: /model (no args) showed '[custom]' with just a usage hint but no endpoint URL or model name. Now displays the configured base_url for custom providers in both CLI and gateway. Note: config base_url and OPENAI_BASE_URL are intentionally NOT cleared on provider switch — dedicated provider paths (nous, anthropic, codex) have their own credential resolution that ignores these, and clearing them would destroy the user's custom endpoint config, preventing switching back. Co-authored-by: Test <test@test.com>
This commit is contained in:
@@ -389,6 +389,7 @@ def detect_provider_for_model(
|
||||
Returns ``None`` when no confident match is found.
|
||||
|
||||
Priority:
|
||||
0. Bare provider name → switch to that provider's default model
|
||||
1. Direct provider with credentials (highest)
|
||||
2. Direct provider without credentials → remap to OpenRouter slug
|
||||
3. OpenRouter catalog match
|
||||
@@ -399,6 +400,21 @@ def detect_provider_for_model(
|
||||
|
||||
name_lower = name.lower()
|
||||
|
||||
# --- Step 0: bare provider name typed as model ---
|
||||
# If someone types `/model nous` or `/model anthropic`, treat it as a
|
||||
# provider switch and pick the first model from that provider's catalog.
|
||||
# Skip "custom" and "openrouter" — custom has no model catalog, and
|
||||
# openrouter requires an explicit model name to be useful.
|
||||
resolved_provider = _PROVIDER_ALIASES.get(name_lower, name_lower)
|
||||
if resolved_provider not in {"custom", "openrouter"}:
|
||||
default_models = _PROVIDER_MODELS.get(resolved_provider, [])
|
||||
if (
|
||||
resolved_provider in _PROVIDER_LABELS
|
||||
and default_models
|
||||
and resolved_provider != normalize_provider(current_provider)
|
||||
):
|
||||
return (resolved_provider, default_models[0])
|
||||
|
||||
# Aggregators list other providers' models — never auto-switch TO them
|
||||
_AGGREGATORS = {"nous", "openrouter"}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user