Skip to content

Commit 34942dc

Browse files
committed
feat: drop /accounts/{account_id} from model URL if env var missing
Co-authored-by: cecli (synthetic/hf:zai-org/GLM-4.7)
1 parent 930eeb2 commit 34942dc

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

cecli/helpers/model_providers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,10 @@ def _fetch_provider_models(self, provider: str) -> Optional[Dict]:
518518
if "{account_id}" in models_url:
519519
account_id = self._get_account_id(provider)
520520
if not account_id:
521-
print(f"Failed to fetch {provider} model list: account_id_env not set")
522-
return None
523-
models_url = models_url.replace("{account_id}", account_id)
521+
# Remove /accounts/{account_id} portion from URL if account_id is not set
522+
models_url = models_url.replace("/accounts/{account_id}", "")
523+
else:
524+
models_url = models_url.replace("{account_id}", account_id)
524525
headers = {}
525526
default_headers = config.get("default_headers") or {}
526527
headers.update(default_headers)

tests/basic/test_model_provider_manager.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ def _fake_get(url, *, headers=None, timeout=None, verify=None):
505505
assert captured["url"] == "https://api.fireworks.ai/v1/accounts/my-account-id/models"
506506

507507

508-
def test_models_url_account_id_missing_skips_fetch(monkeypatch, tmp_path, capsys):
508+
def test_models_url_account_id_missing_removes_account_path(monkeypatch, tmp_path):
509509
config = {
510510
"fireworks_ai": {
511511
"api_base": "https://api.fireworks.ai/inference/v1",
@@ -519,10 +519,23 @@ def test_models_url_account_id_missing_skips_fetch(monkeypatch, tmp_path, capsys
519519
manager = _make_manager(tmp_path, config)
520520
monkeypatch.delenv("FIREWORKS_AI_ACCOUNT_ID", raising=False)
521521

522-
assert manager._fetch_provider_models("fireworks_ai") is None
522+
captured = {}
523+
524+
def _fake_get(url, *, headers=None, timeout=None, verify=None):
525+
captured["url"] = url
526+
captured["headers"] = headers
527+
captured["timeout"] = timeout
528+
captured["verify"] = verify
529+
return DummyResponse({"data": []})
530+
531+
monkeypatch.setattr("requests.get", _fake_get)
532+
533+
result = manager._fetch_provider_models("fireworks_ai")
523534

524-
captured = capsys.readouterr()
525-
assert "account_id_env not set" in captured.out
535+
# Should return the payload, not None
536+
assert result == {"data": []}
537+
# URL should have /accounts/{account_id} removed
538+
assert captured["url"] == "https://api.fireworks.ai/v1/models"
526539

527540

528541
def test_models_url_without_placeholder_unchanged(monkeypatch, tmp_path):

0 commit comments

Comments
 (0)