From 2c7264b30899ba46b878c263176fe5f37181bc77 Mon Sep 17 00:00:00 2001 From: shivam Date: Sat, 8 Aug 2026 02:00:38 +0000 Subject: [PATCH] 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> --- .../provider_create_fields.json | 28 +++++++++++++++++ .../public_endpoints/test_public_endpoints.py | 31 +++++++++++++++++++ .../components/provider_info_helpers.test.tsx | 5 +++ ui/litellm-dashboard/src/lib/http/schema.d.ts | 7 +++++ 4 files changed, 71 insertions(+) diff --git a/litellm/proxy/public_endpoints/provider_create_fields.json b/litellm/proxy/public_endpoints/provider_create_fields.json index fcc6aac1c14..453dc6c4ba0 100644 --- a/litellm/proxy/public_endpoints/provider_create_fields.json +++ b/litellm/proxy/public_endpoints/provider_create_fields.json @@ -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", diff --git a/tests/test_litellm/proxy/public_endpoints/test_public_endpoints.py b/tests/test_litellm/proxy/public_endpoints/test_public_endpoints.py index 88dc07e741b..8b8cb1fc144 100644 --- a/tests/test_litellm/proxy/public_endpoints/test_public_endpoints.py +++ b/tests/test_litellm/proxy/public_endpoints/test_public_endpoints.py @@ -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 diff --git a/ui/litellm-dashboard/src/components/provider_info_helpers.test.tsx b/ui/litellm-dashboard/src/components/provider_info_helpers.test.tsx index 777cdc62987..b206445a224 100644 --- a/ui/litellm-dashboard/src/components/provider_info_helpers.test.tsx +++ b/ui/litellm-dashboard/src/components/provider_info_helpers.test.tsx @@ -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"); }); diff --git a/ui/litellm-dashboard/src/lib/http/schema.d.ts b/ui/litellm-dashboard/src/lib/http/schema.d.ts index f1660e77ad9..8e950874a10 100644 --- a/ui/litellm-dashboard/src/lib/http/schema.d.ts +++ b/ui/litellm-dashboard/src/lib/http/schema.d.ts @@ -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; };