🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(dashboard): round costs to cents (#15866)
Hassieb Pakzadf50617a11a20
diff --git a/web/src/utils/numbers.clienttest.ts b/web/src/utils/numbers.clienttest.tsnew file mode 100644index 0000000000..1ba145fab5--- /dev/null+++ b/web/src/utils/numbers.clienttest.ts@@ -0,0 +1,12 @@+import { describe, expect, it } from "vitest";++import { costFormatter } from "@/src/utils/numbers";++describe("costFormatter", () => {+ it("formats dashboard costs with cent precision", () => {+ expect(costFormatter(4.402973)).toBe("$4.40");+ expect(costFormatter(0.068415)).toBe("$0.07");+ expect(costFormatter(0.015427)).toBe("$0.02");+ expect(costFormatter(0)).toBe("$0.00");+ });+});diff --git a/web/src/utils/numbers.ts b/web/src/utils/numbers.tsindex 0a73193023..5b7e2f3bc2 100644--- a/web/src/utils/numbers.ts+++ b/web/src/utils/numbers.ts@@ -77,11 +77,7 @@ export const usdFormatter = (};export const costFormatter = (totalCost?: number) => {- return totalCost- ? totalCost < 5- ? usdFormatter(totalCost, 2, 6)- : usdFormatter(totalCost, 2, 2)- : usdFormatter(0);+ return usdFormatter(totalCost, 2, 2);};export const formatTokenCounts = (