diff --git a/hermes_cli/model_setup_flows.py b/hermes_cli/model_setup_flows.py index be9ecd612ff..458b442c362 100644 --- a/hermes_cli/model_setup_flows.py +++ b/hermes_cli/model_setup_flows.py @@ -2275,7 +2275,7 @@ def _select_zai_endpoint(current_base: str) -> str: return current_base return override.rstrip("/") - return options[selected][1] + return options[selected][1].rstrip("/") def _model_flow_api_key_provider(config, provider_id, current_model=""): @@ -2400,7 +2400,7 @@ def _model_flow_api_key_provider(config, provider_id, current_model=""): chosen_base = _select_zai_endpoint(effective_base) if chosen_base and chosen_base != effective_base and base_url_env: save_env_value(base_url_env, chosen_base) - effective_base = chosen_base or effective_base + effective_base = chosen_base else: try: override = input(f"Base URL [{effective_base}]: ").strip() diff --git a/tests/hermes_cli/test_model_provider_persistence.py b/tests/hermes_cli/test_model_provider_persistence.py index bc4c1dfa32e..76d5ee7414d 100644 --- a/tests/hermes_cli/test_model_provider_persistence.py +++ b/tests/hermes_cli/test_model_provider_persistence.py @@ -462,8 +462,9 @@ class TestZaiEndpointPicker: monkeypatch.setenv("GLM_API_KEY", "test-key") - # Last option index = custom proxy - with patch("hermes_cli.main._prompt_provider_choice", return_value=4), \ + from hermes_cli.auth import ZAI_ENDPOINTS + custom_idx = len(ZAI_ENDPOINTS) # last option = custom proxy + with patch("hermes_cli.main._prompt_provider_choice", return_value=custom_idx), \ patch("hermes_cli.auth._prompt_model_selection", return_value="glm-5"), \ patch("hermes_cli.auth.deactivate_provider"), \ patch("builtins.input", return_value="https://proxy.example.com/glm/v4"): @@ -479,8 +480,10 @@ class TestZaiEndpointPicker: monkeypatch.setenv("GLM_API_KEY", "test-key") monkeypatch.delenv("GLM_BASE_URL", raising=False) + from hermes_cli.auth import ZAI_ENDPOINTS + custom_idx = len(ZAI_ENDPOINTS) - with patch("hermes_cli.main._prompt_provider_choice", return_value=4), \ + with patch("hermes_cli.main._prompt_provider_choice", return_value=custom_idx), \ patch("hermes_cli.auth._prompt_model_selection", return_value="glm-5"), \ patch("hermes_cli.auth.deactivate_provider"), \ patch("builtins.input", return_value="not-a-url"):