Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cecli/helpers/model_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,10 @@ def _fetch_provider_models(self, provider: str) -> Optional[Dict]:
if "{account_id}" in models_url:
account_id = self._get_account_id(provider)
if not account_id:
print(f"Failed to fetch {provider} model list: account_id_env not set")
return None
models_url = models_url.replace("{account_id}", account_id)
# Remove /accounts/{account_id} portion from URL if account_id is not set
models_url = models_url.replace("/accounts/{account_id}", "")
else:
models_url = models_url.replace("{account_id}", account_id)
headers = {}
default_headers = config.get("default_headers") or {}
headers.update(default_headers)
Expand Down
21 changes: 17 additions & 4 deletions tests/basic/test_model_provider_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def _fake_get(url, *, headers=None, timeout=None, verify=None):
assert captured["url"] == "https://api.fireworks.ai/v1/accounts/my-account-id/models"


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

assert manager._fetch_provider_models("fireworks_ai") is None
captured = {}

def _fake_get(url, *, headers=None, timeout=None, verify=None):
captured["url"] = url
captured["headers"] = headers
captured["timeout"] = timeout
captured["verify"] = verify
return DummyResponse({"data": []})

monkeypatch.setattr("requests.get", _fake_get)

result = manager._fetch_provider_models("fireworks_ai")

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


def test_models_url_without_placeholder_unchanged(monkeypatch, tmp_path):
Expand Down