fix(commandcode): accept base_url kwarg in fetch_models overrides
The model picker's generic live-fetch path (hermes_cli/models.py provider_model_ids) calls profile.fetch_models(api_key=..., base_url=...). Both CommandCode overrides only accepted api_key/timeout, so every picker open raised TypeError, which was silently swallowed, leaving the provider with zero models. Match the base ProviderProfile.fetch_models signature (base_url kwarg) and add a regression test asserting both profiles accept it.
This commit is contained in:
@@ -79,6 +79,7 @@ class CommandCodeProfile(ProviderProfile):
|
||||
self,
|
||||
*,
|
||||
api_key: str | None = None,
|
||||
base_url: str | None = None,
|
||||
timeout: float = 8.0,
|
||||
) -> list[str] | None:
|
||||
"""Fetch from the public CommandCode /models endpoint."""
|
||||
@@ -126,6 +127,7 @@ class CommandCodeAnthropicProfile(ProviderProfile):
|
||||
self,
|
||||
*,
|
||||
api_key: str | None = None,
|
||||
base_url: str | None = None,
|
||||
timeout: float = 8.0,
|
||||
) -> list[str] | None:
|
||||
"""Fetch from the public CommandCode /models endpoint.
|
||||
|
||||
@@ -232,3 +232,27 @@ class TestCommandCodeModelFiltering:
|
||||
assert "startswith(\"claude-\")" in source or '"claude-" in m' in source, (
|
||||
"CommandCodeAnthropicProfile.fetch_models should filter to claude-* models"
|
||||
)
|
||||
|
||||
|
||||
# ── Picker contract ──────────────────────────────────────────────────────────
|
||||
|
||||
class TestCommandCodeFetchModelsPickerContract:
|
||||
"""``fetch_models`` must accept the kwargs the model picker passes.
|
||||
|
||||
Regression: the generic live-fetch path in ``hermes_cli/models.py``
|
||||
(``provider_model_ids``) calls ``profile.fetch_models(api_key=...,
|
||||
base_url=...)``. The original CommandCode overrides only accepted
|
||||
``api_key``/``timeout``, so every picker open raised TypeError, which
|
||||
was swallowed, leaving the provider with zero models.
|
||||
"""
|
||||
|
||||
@pytest.mark.parametrize("profile_name", ["commandcode", "commandcode-anthropic"])
|
||||
def test_accepts_base_url_kwarg(self, profile_name):
|
||||
import inspect
|
||||
|
||||
import model_tools # noqa: F401 — triggers discovery
|
||||
import providers
|
||||
|
||||
profile = providers.get_provider_profile(profile_name)
|
||||
assert profile is not None
|
||||
assert "base_url" in inspect.signature(profile.fetch_models).parameters
|
||||
|
||||
Reference in New Issue
Block a user