mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
fix(ui): render Z.AI API Key and API Base on the credential form
The Add Credential provider list comes from the UI enum, so Z.AI (Zhipu AI) already appears. GET /public/providers/fields reads provider_create_fields.json, which had 117 rows and none with litellm_provider=zai, so the form rendered no fields. Add Model uses that same catalog and never listed Z.AI. Add the missing catalog row (required api_key, optional api_base) and a regression on TestZAIDashboardRegistration. Revert-check: the new test fails with assert 0 == 1 when the row is removed.
This commit is contained in:
parent
168a0055a2
commit
980ecf943c
2 changed files with 54 additions and 0 deletions
|
|
@ -3414,6 +3414,34 @@
|
|||
],
|
||||
"default_model_placeholder": "gpt-3.5-turbo"
|
||||
},
|
||||
{
|
||||
"provider": "ZAI",
|
||||
"provider_display_name": "Z.AI (Zhipu AI)",
|
||||
"litellm_provider": "zai",
|
||||
"credential_fields": [
|
||||
{
|
||||
"key": "api_base",
|
||||
"label": "API Base",
|
||||
"placeholder": "https://api.z.ai/api/paas/v4",
|
||||
"tooltip": null,
|
||||
"required": false,
|
||||
"field_type": "text",
|
||||
"options": null,
|
||||
"default_value": null
|
||||
},
|
||||
{
|
||||
"key": "api_key",
|
||||
"label": "API Key",
|
||||
"placeholder": null,
|
||||
"tooltip": null,
|
||||
"required": true,
|
||||
"field_type": "password",
|
||||
"options": null,
|
||||
"default_value": null
|
||||
}
|
||||
],
|
||||
"default_model_placeholder": "zai/glm-4.5"
|
||||
},
|
||||
{
|
||||
"provider": "CURSOR",
|
||||
"provider_display_name": "Cursor",
|
||||
|
|
|
|||
|
|
@ -172,3 +172,29 @@ def test_zai_sync_completion(respx_mock, zai_response, monkeypatch):
|
|||
|
||||
assert response.choices[0].message.content == "Hello! How can I help you today?"
|
||||
assert response.usage.total_tokens == 25
|
||||
|
||||
|
||||
class TestZAIDashboardRegistration:
|
||||
@staticmethod
|
||||
def _provider_create_fields():
|
||||
from pathlib import Path
|
||||
|
||||
path = Path(litellm.__file__).parent / "proxy" / "public_endpoints" / "provider_create_fields.json"
|
||||
with open(path) as f:
|
||||
return json.load(f)
|
||||
|
||||
def test_zai_is_selectable_in_the_add_model_form(self):
|
||||
entries = [e for e in self._provider_create_fields() if e["litellm_provider"] == "zai"]
|
||||
assert len(entries) == 1, "zai must appear exactly once in provider_create_fields.json"
|
||||
|
||||
entry = entries[0]
|
||||
assert entry["provider"] == "ZAI"
|
||||
assert entry["provider_display_name"] == "Z.AI (Zhipu AI)"
|
||||
assert entry["default_model_placeholder"].startswith("zai/")
|
||||
|
||||
fields = {f["key"]: f for f in entry["credential_fields"]}
|
||||
assert fields["api_key"]["required"] is True
|
||||
assert fields["api_key"]["field_type"] == "password"
|
||||
assert fields["api_base"]["required"] is False
|
||||
assert fields["api_base"]["field_type"] == "text"
|
||||
assert fields["api_base"]["placeholder"] == "https://api.z.ai/api/paas/v4"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue