mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
fix(gateway): preserve model picker current context
This commit is contained in:
parent
629d8b843d
commit
466f3a11de
2 changed files with 51 additions and 2 deletions
|
|
@ -1687,9 +1687,11 @@ def list_authenticated_providers(
|
|||
|
||||
def list_picker_providers(
|
||||
current_provider: str = "",
|
||||
current_base_url: str = "",
|
||||
user_providers: dict = None,
|
||||
custom_providers: list | None = None,
|
||||
max_models: int = 8,
|
||||
current_model: str = "",
|
||||
) -> List[dict]:
|
||||
"""Interactive-picker variant of :func:`list_authenticated_providers`.
|
||||
|
||||
|
|
@ -1714,9 +1716,11 @@ def list_picker_providers(
|
|||
|
||||
providers = list_authenticated_providers(
|
||||
current_provider=current_provider,
|
||||
current_base_url=current_base_url,
|
||||
user_providers=user_providers,
|
||||
custom_providers=custom_providers,
|
||||
max_models=max_models,
|
||||
current_model=current_model,
|
||||
)
|
||||
|
||||
filtered: List[dict] = []
|
||||
|
|
|
|||
|
|
@ -190,8 +190,11 @@ def test_max_models_caps_openrouter_live_output(monkeypatch):
|
|||
|
||||
|
||||
def test_passthrough_kwargs_to_base(monkeypatch):
|
||||
"""All kwargs (current_provider, user_providers, custom_providers, max_models)
|
||||
must be forwarded to ``list_authenticated_providers`` unchanged.
|
||||
"""All kwargs must be forwarded to ``list_authenticated_providers`` unchanged.
|
||||
|
||||
The gateway /model picker passes ``current_base_url`` and ``current_model``
|
||||
so custom endpoint grouping can mark the current row. Dropping those kwargs
|
||||
regressed Telegram/Discord into the text-list fallback.
|
||||
"""
|
||||
captured = {}
|
||||
|
||||
|
|
@ -205,12 +208,54 @@ def test_passthrough_kwargs_to_base(monkeypatch):
|
|||
|
||||
model_switch.list_picker_providers(
|
||||
current_provider="openrouter",
|
||||
current_base_url="http://x",
|
||||
current_model="openai/gpt-5.4",
|
||||
user_providers={"foo": {"api": "http://x"}},
|
||||
custom_providers=[{"name": "bar", "base_url": "http://y"}],
|
||||
max_models=12,
|
||||
)
|
||||
|
||||
assert captured["current_provider"] == "openrouter"
|
||||
assert captured["current_base_url"] == "http://x"
|
||||
assert captured["current_model"] == "openai/gpt-5.4"
|
||||
assert captured["user_providers"] == {"foo": {"api": "http://x"}}
|
||||
assert captured["custom_providers"] == [{"name": "bar", "base_url": "http://y"}]
|
||||
assert captured["max_models"] == 12
|
||||
|
||||
|
||||
def test_current_custom_endpoint_passthrough_marks_current_row(monkeypatch):
|
||||
"""Interactive picker should preserve current custom endpoint semantics."""
|
||||
monkeypatch.setattr("agent.models_dev.fetch_models_dev", lambda: {})
|
||||
monkeypatch.setattr("agent.models_dev.PROVIDER_TO_MODELS_DEV", {})
|
||||
monkeypatch.setattr("hermes_cli.providers.HERMES_OVERLAYS", {})
|
||||
monkeypatch.setattr("hermes_cli.models.fetch_openrouter_models",
|
||||
lambda *a, **kw: [])
|
||||
|
||||
result = model_switch.list_picker_providers(
|
||||
current_provider="custom:ollama",
|
||||
current_base_url="http://localhost:11434/v1",
|
||||
current_model="glm-5.1",
|
||||
user_providers={},
|
||||
custom_providers=[
|
||||
{
|
||||
"name": "Ollama — GLM 5.1",
|
||||
"base_url": "http://localhost:11434/v1",
|
||||
"api_key": "ollama",
|
||||
"model": "glm-5.1",
|
||||
},
|
||||
{
|
||||
"name": "Ollama — Qwen3",
|
||||
"base_url": "http://localhost:11434/v1",
|
||||
"api_key": "ollama",
|
||||
"model": "qwen3",
|
||||
},
|
||||
],
|
||||
max_models=50,
|
||||
)
|
||||
|
||||
custom_rows = [p for p in result if p.get("is_user_defined")]
|
||||
assert len(custom_rows) == 1
|
||||
row = custom_rows[0]
|
||||
assert row["slug"] == "custom:ollama"
|
||||
assert row["is_current"] is True
|
||||
assert row["models"] == ["glm-5.1", "qwen3"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue