mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
fix(cognition): make Cognition selectable in the Add Model dropdown
The dropdown is driven by /public/providers/fields, so the provider needed an entry in provider_create_fields.json. Also document COGNITION_API_KEY/COGNITION_API_BASE (docs repo PR) and regenerate the dashboard API types, which had drifted on the base branch. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
bcb9d16eaa
commit
2c7264b308
4 changed files with 71 additions and 0 deletions
|
|
@ -772,6 +772,34 @@
|
|||
],
|
||||
"default_model_placeholder": "gpt-3.5-turbo"
|
||||
},
|
||||
{
|
||||
"provider": "Cognition",
|
||||
"provider_display_name": "Cognition",
|
||||
"litellm_provider": "cognition",
|
||||
"credential_fields": [
|
||||
{
|
||||
"key": "api_base",
|
||||
"label": "API Base",
|
||||
"placeholder": "https://api.cognition.ai/v1",
|
||||
"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": "cognition/swe-1.7"
|
||||
},
|
||||
{
|
||||
"provider": "Cohere",
|
||||
"provider_display_name": "Cohere",
|
||||
|
|
|
|||
|
|
@ -243,6 +243,37 @@ def test_bedrock_mantle_provider_fields():
|
|||
assert fields_by_key["api_base"]["field_type"] == "text"
|
||||
|
||||
|
||||
def test_cognition_provider_fields():
|
||||
"""Cognition must be selectable in the Add Model flow (LIT-5348).
|
||||
|
||||
The dropdown is driven entirely by /public/providers/fields, so without an
|
||||
entry here admins have to fall back to the generic OpenAI-compatible route,
|
||||
which is exactly the provider identity mix-up this feature removes.
|
||||
"""
|
||||
app_instance = FastAPI()
|
||||
app_instance.include_router(router)
|
||||
test_client = TestClient(app_instance)
|
||||
|
||||
response = test_client.get("/public/providers/fields")
|
||||
assert response.status_code == 200
|
||||
providers = response.json()
|
||||
|
||||
cognition = next((p for p in providers if p["provider"] == "Cognition"), None)
|
||||
assert cognition is not None, "Cognition provider entry not found"
|
||||
|
||||
assert cognition["provider_display_name"] == "Cognition"
|
||||
assert cognition["litellm_provider"] == "cognition"
|
||||
assert cognition["default_model_placeholder"].startswith("cognition/")
|
||||
|
||||
fields_by_key = {f["key"]: f for f in cognition["credential_fields"]}
|
||||
|
||||
assert fields_by_key["api_key"]["required"] is True
|
||||
assert fields_by_key["api_key"]["field_type"] == "password"
|
||||
|
||||
assert fields_by_key["api_base"]["field_type"] == "text"
|
||||
assert fields_by_key["api_base"]["required"] is False
|
||||
|
||||
|
||||
def test_google_ai_studio_provider_fields_expose_api_base():
|
||||
"""The Google AI Studio (gemini) credential form must let admins set a custom
|
||||
api_base so they can point at a Gemini-compatible gateway (e.g. a self-hosted
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ describe("provider_info_helpers", () => {
|
|||
Providers.AUTO_ROUTER,
|
||||
Providers.BYTEZ,
|
||||
Providers.CLARIFAI,
|
||||
Providers.Cognition,
|
||||
Providers.COMPACTIFAI,
|
||||
Providers.DATAROBOT,
|
||||
Providers.DOCKER_MODEL_RUNNER,
|
||||
|
|
@ -225,6 +226,10 @@ describe("provider_info_helpers", () => {
|
|||
expect(getPlaceholder(Providers.ZAI)).toBe("zai/glm-4.5");
|
||||
});
|
||||
|
||||
it("should return cognition/swe-1.7 placeholder for Cognition provider", () => {
|
||||
expect(getPlaceholder(Providers.Cognition)).toBe("cognition/swe-1.7");
|
||||
});
|
||||
|
||||
it("should return default gpt-3.5-turbo placeholder for unknown provider", () => {
|
||||
expect(getPlaceholder("UnknownProvider" as any)).toBe("gpt-3.5-turbo");
|
||||
});
|
||||
|
|
|
|||
7
ui/litellm-dashboard/src/lib/http/schema.d.ts
generated
vendored
7
ui/litellm-dashboard/src/lib/http/schema.d.ts
generated
vendored
|
|
@ -21391,6 +21391,13 @@ export interface components {
|
|||
* @description What the routed traffic actually cost
|
||||
*/
|
||||
spend: number;
|
||||
/**
|
||||
* Tier Turns
|
||||
* @description Turns per tier, keyed by the tier name the routing decision recorded at request time (never re-derived at read time, since the tier-to-model mapping is mutable config). Tier names are scoped to this group's router_type and are not comparable across types: a complexity router reports 'simple'/'medium'/'complex'/'reasoning', a quality router reports its numeric quality tier, and an adaptive router records no tier at all. Turns no tier served (the classifier fell back to default_model) are absent rather than pooled under a sentinel key, so the values may sum to less than turns
|
||||
*/
|
||||
tier_turns?: {
|
||||
[key: string]: number;
|
||||
};
|
||||
/** Turns */
|
||||
turns: number;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue