feat(ui): add configuration tabs to the Cost Optimization page - #33899
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
|
Greptile SummaryTurns the Cost Optimization page into a four-tab hub (Usage, Prompt Compression, Autorouter, Prompt Caching) without removing any existing pages or routes. Each configuration tab reuses a mature existing component (
Confidence Score: 5/5UI-only additive change; no existing routes or backend contracts are modified. Both issues raised in the previous review are addressed: the Redis port form is gone (along with the NaN-validation gap), and the tab-switch test now asserts aria-selected state rather than mere DOM presence. The remaining no-op await in PromptCompressionTab was already surfaced as a style note in the prior round. No new logic defects are introduced; backend calls reuse the same endpoints as the standalone pages they mirror. No files require special attention.
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/CostOptimizationView.tsx | Refactored into a tabbed shell using antd Tabs; previous dashboard logic extracted to UsageTab, three new config tabs added alongside it |
| ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/CostOptimizationView.test.tsx | Tests updated to focus on tab structure; now properly asserts active tab via aria-selected before and after a click (previous vacuous pane-presence assertion resolved) |
| ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/UsageTab.tsx | Dashboard content extracted verbatim from CostOptimizationView; adds a collapsible methodology note; logic and rendering unchanged |
| ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/UsageTab.test.tsx | Previous CostOptimizationView logic tests (savings sums, time series, donut slices) moved here and now correctly target UsageTab; coverage is fully preserved |
| ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/PromptCompressionTab.tsx | New Headroom guardrail creation form; loadGuardrails does not return its promise so await loadGuardrails() in handleAdd is a no-op (flagged previously as P2, still present) |
| ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/PromptCachingTab.tsx | Wraps PromptCachingPanel from router-settings; previous P1 (port NaN validation) is fully resolved — the Redis form was removed entirely |
| ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/AutorouterTab.tsx | Thin wrapper around AddAutoRouterTab with a local antd form instance; userId is accepted in the interface but intentionally unused by this adapter layer |
| ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/helpers.ts | Pure helper functions for filtering headroom guardrails and building the create-guardrail payload; well-typed and straightforward |
| ui/litellm-dashboard/src/app/(dashboard)/cost-optimization/_components/helpers.test.ts | Unit tests for compressionGuardrailsOf (filtering) and buildCompressionGuardrailPayload (payload shape including trim); covers the meaningful edge cases |
| ui/litellm-dashboard/src/app/(dashboard)/router-settings/_components/general_settings.tsx | Minimal additive change: exports generalSettingsItem interface and PromptCachingPanel for reuse in PromptCachingTab; no behaviour change |
Reviews (2): Last reviewed commit: "test(ui): assert active tab state in Cos..." | Re-trigger Greptile
…l in Cost Optimization; clarify Headroom compression Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…link to Cost Optimization Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Screenshots of the four tabs, captured against a live proxy on this branch. The experimental-dashboard banner (with the feedback discussion link) sits above the tabs, so it shows on every tab. Usage Prompt Compression (Headroom copy + setup docs link) Autorouter (Auto-Router v2, reused from Models + Endpoints) Prompt Caching (Router Settings automatic Anthropic prompt-caching panel) |
…nterprise callout to Cost Optimization Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Follow-up: added a savings methodology note and an Enterprise callout. Usage tab now has a collapsible "How savings are calculated" note explaining that savings are priced per request at log time from the provider's reported usage and the model's pricing, then summed into the daily rollup (no raw-log scan), with the compression and prompt-caching formulas spelled out. Prompt Compression tab now clarifies that applying compression to all requests is available to everyone, while enabling it selectively per key or team is a LiteLLM Enterprise feature. |
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Both findings from the 3/5 review are addressed:
@greptileai please re-review. |
…AI#33899) * feat(ui): add configuration tabs to Cost Optimization page Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * feat(ui): reuse AutoRouter v2 and Router Settings prompt-caching panel in Cost Optimization; clarify Headroom compression Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * feat(ui): add experimental dashboard banner with feedback discussion link to Cost Optimization Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * feat(ui): add savings methodology note and per-key/team compression enterprise callout to Cost Optimization Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(ui): assert active tab state in Cost Optimization tab-switch test Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Krrish Dholakia <krrishdholakia@berri.ai> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> (cherry picked from commit 3456148)
Relevant issues
Follow-up to the Cost Optimization dashboard (#33810). Adds configuration tabs so the mechanisms that drive savings can be managed from the same page.
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
Screenshots / Proof of Fix
UI-only change. To exercise it against a live proxy (bundled UI at
http://localhost:4000/ui):http://localhost:4000/ui/?page=cost-optimization. The page shows four tabs: Usage, Prompt Compression, Autorouter, Prompt Caching/guardrailsendpoint as the standalone Guardrails page/model/new; confirm it also appears onhttp://localhost:4000/ui/?page=modelsType
🆕 New Feature
Changes
Turns the Cost Optimization page (
/ui/cost-optimization) into a tabbed hub. An info banner marks the page as an experimental dashboard and links the feedback discussion. The existing dashboard becomes the Usage tab, and three configuration tabs are added alongside it. Per review feedback, the config tabs reuse the existing mature components rather than reimplementing them, so there is a single source of truth for each config:UsageTab. Adds a collapsible "How savings are calculated" note documenting the per-request pricing methodology and the daily-rollup source.headroomguardrail. Copy now names Headroom explicitly, explains that it compresses prompts before they reach the model (savings shown on the Usage tab), clarifies that "API base" is the Headroom service URL, and links the setup docs. Adds a callout clarifying that enabling compression selectively per key or team is a LiteLLM Enterprise feature while applying it to all requests is available to everyone.AddAutoRouterTab(the Auto-Router v2 flow from Models + Endpoints): complexity-tier routing, optional keyword/semantic matching, model access groups, connection test, same/model/newsubmit path.PromptCachingPanel(automatic Anthropic prompt caching toggle + cache-lifetime TTL). The Redis global-cache form was removed; this panel writes through the sameupdateConfigFieldSetting/deleteConfigFieldSettingcalls as Router Settings.Design notes:
PromptCachingPanelis now exported from the Router Settings component and mounted here with a thin loader;AddAutoRouterTabis mounted with a local antd form instance. Both hit the exact backend contract as their standalone pages.helpers.tsand is unit-tested; tab wiring and switching are covered by component tests.localStorage.Files:
cost-optimization/_components/CostOptimizationView.tsx— antdTabsshellcost-optimization/_components/UsageTab.tsx(+ test) — extracted dashboardcost-optimization/_components/PromptCompressionTab.tsx— Headroom copy + doc linkcost-optimization/_components/AutorouterTab.tsx— wrapsAddAutoRouterTabcost-optimization/_components/PromptCachingTab.tsx— wrapsPromptCachingPanelcost-optimization/_components/helpers.ts(+ test) — compression payload/filter helpersrouter-settings/_components/general_settings.tsx— exportPromptCachingPanelfor reuseFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/2d6b95b424a047c4b6d177b6ddcd7f46
Requested by: @krrish-berri-2