diff --git a/ui/litellm-dashboard/.eslintrc.json b/ui/litellm-dashboard/.eslintrc.json index 709a4352cd1..ccf3fa73dc3 100644 --- a/ui/litellm-dashboard/.eslintrc.json +++ b/ui/litellm-dashboard/.eslintrc.json @@ -66,6 +66,7 @@ "src/components/playground/chat_ui/SearchResultsDisplay.tsx", "src/components/team/member_permissions.tsx", "src/components/agent_management/AgentSelector.tsx", + "src/components/CostTrackingSettings/how_it_works.tsx", "src/components/UsagePage/components/EntityUsage/SpendByProvider.tsx", "src/components/view_logs/ToolsSection/FormattedToolView.tsx", "src/components/Settings/LoggingAndAlerts/LoggingCallbacks/LoggingCallbacksTable.tsx", diff --git a/ui/litellm-dashboard/src/components/CostTrackingSettings/how_it_works.tsx b/ui/litellm-dashboard/src/components/CostTrackingSettings/how_it_works.tsx index cdff800f9fb..43142e928f4 100644 --- a/ui/litellm-dashboard/src/components/CostTrackingSettings/how_it_works.tsx +++ b/ui/litellm-dashboard/src/components/CostTrackingSettings/how_it_works.tsx @@ -1,5 +1,5 @@ import React, { useState, useMemo } from "react"; -import { Text, TextInput } from "@tremor/react"; +import { Input } from "@/components/ui/input"; import CodeBlock from "@/app/(dashboard)/api-reference/components/CodeBlock"; const HowItWorks: React.FC = () => { @@ -9,7 +9,7 @@ const HowItWorks: React.FC = () => { const calculatedDiscount = useMemo(() => { const cost = parseFloat(responseCost); const discount = parseFloat(discountAmount); - + if (isNaN(cost) || isNaN(discount) || cost === 0 || discount === 0) { return null; } @@ -27,122 +27,156 @@ const HowItWorks: React.FC = () => { return (
final_cost = base_cost × (1 - discount%/100)
- + Cost Calculation +
+
+ Discounts are applied to provider costs:{" "}
+
+ final_cost = base_cost × (1 - discount%/100)
+
+
Example
++ A 5% discount on a $10.00 request results in: $10.00 × (1 - 0.05) = + $9.50 +
+Valid Range
++ Discount percentages must be between 0% and 100% +
++ Validating Discounts +
++ Make a test request and check the response headers to verify + discounts are applied: +
++ Look for these headers in the response: +
+
+ x-litellm-response-cost
+
+
+ Final cost after discount
+
+
+ x-litellm-response-cost-original
+
+
+ Original cost before discount
+
+
+ x-litellm-response-cost-discount-amount
+
+
+ Amount discounted
+
+ + Discount Calculator +
++ Enter values from your response headers to verify the discount: +
+
- x-litellm-response-cost
+ + Calculated Results +
+
+ ${calculatedDiscount.originalCost}
-
- x-litellm-response-cost-original
+
+
+ Final Cost:
+
+
+ ${calculatedDiscount.finalCost}
- Original cost before discount
-
-
- x-litellm-response-cost-discount-amount
+
+
+ Discount Amount:
+
+
+ ${calculatedDiscount.discountAmount}
- Amount discounted
+
+
+
+ Discount Applied:
+
+
+ {calculatedDiscount.discountPercentage}%
+
${calculatedDiscount.originalCost}
- ${calculatedDiscount.finalCost}
- ${calculatedDiscount.discountAmount}
-