fix(routing): strip provider prefix from model ID when custom base_url is configured (fixes #433)
This commit is contained in:
committed by
Hermes Agent
parent
85d8aad0ae
commit
b3ad60d2c9
@@ -637,7 +637,10 @@ def resolve_model_provider(model_id: str) -> tuple:
|
|||||||
# just because the model name contains a slash (e.g. google/gemma-4-26b-a4b).
|
# just because the model name contains a slash (e.g. google/gemma-4-26b-a4b).
|
||||||
# The user has explicitly pointed at a base_url, so trust their routing config.
|
# The user has explicitly pointed at a base_url, so trust their routing config.
|
||||||
if config_base_url:
|
if config_base_url:
|
||||||
return model_id, config_provider, config_base_url
|
# Strip provider prefix (e.g. 'openai/gpt-5.4' -> 'gpt-5.4') so prefixed
|
||||||
|
# model IDs from previous sessions don't break custom endpoint routing.
|
||||||
|
bare_model = model_id.split('/', 1)[-1]
|
||||||
|
return bare_model, config_provider, config_base_url
|
||||||
# If prefix does NOT match config provider, the user picked a cross-provider model
|
# If prefix does NOT match config provider, the user picked a cross-provider model
|
||||||
# from the OpenRouter dropdown (e.g. config=anthropic but picked openai/gpt-5.4-mini).
|
# from the OpenRouter dropdown (e.g. config=anthropic but picked openai/gpt-5.4-mini).
|
||||||
# In this case always route through openrouter with the full provider/model string.
|
# In this case always route through openrouter with the full provider/model string.
|
||||||
|
|||||||
@@ -403,8 +403,10 @@ def test_custom_endpoint_slash_model_routes_to_custom_not_openrouter():
|
|||||||
assert base_url == 'http://127.0.0.1:1234/v1', (
|
assert base_url == 'http://127.0.0.1:1234/v1', (
|
||||||
"Expected base_url 'http://127.0.0.1:1234/v1', got '{}'.".format(base_url)
|
"Expected base_url 'http://127.0.0.1:1234/v1', got '{}'.".format(base_url)
|
||||||
)
|
)
|
||||||
assert model == 'google/gemma-4-26b-a4b', (
|
# Fix #433: provider prefix is now stripped for custom endpoints so stale
|
||||||
"Model name should be preserved as-is, got '{}'.".format(model)
|
# prefixed model IDs from previous sessions do not break custom endpoint routing.
|
||||||
|
assert model == 'gemma-4-26b-a4b', (
|
||||||
|
"Model name prefix should be stripped for custom base_url endpoint, got '{}'.".format(model)
|
||||||
)
|
)
|
||||||
|
|
||||||
# --- openrouter with slash model name MUST still route to openrouter -----
|
# --- openrouter with slash model name MUST still route to openrouter -----
|
||||||
|
|||||||
Reference in New Issue
Block a user