Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(dataset-compare): diff label colors are inverted for cost and latency (#10694)

marliessophiee034611073ef
diff --git a/web/src/features/datasets/components/DatasetAggregateTableCell.tsx b/web/src/features/datasets/components/DatasetAggregateTableCell.tsx
index 6f6c17ca7e..ab421c4ddd 100644
--- a/web/src/features/datasets/components/DatasetAggregateTableCell.tsx
+++ b/web/src/features/datasets/components/DatasetAggregateTableCell.tsx
@@ -207,6 +207,7 @@ const DatasetAggregateCellContent = ({
(latencyDiff ? (
<DiffLabel
diff={latencyDiff}
+ preferNegativeDiff={true}
formatValue={(value) => formatIntervalSeconds(value)}
className="ml-1"
/>
@@ -222,6 +223,7 @@ const DatasetAggregateCellContent = ({
(totalCostDiff ? (
<DiffLabel
diff={totalCostDiff}
+ preferNegativeDiff={true}
formatValue={(value) => usdFormatter(value, 2, 4)}
className="ml-1"
/>
diff --git a/web/src/features/datasets/components/DiffLabel.tsx b/web/src/features/datasets/components/DiffLabel.tsx
index acc3be49ab..c3864b16d2 100644
--- a/web/src/features/datasets/components/DiffLabel.tsx
+++ b/web/src/features/datasets/components/DiffLabel.tsx
@@ -5,6 +5,13 @@ import {
} from "@/src/features/datasets/lib/calculateBaselineDiff";
import { cn } from "@/src/utils/tailwind";
+const getVariant = (direction: "+" | "-", preferNegativeDirection: boolean) => {
+ if (preferNegativeDirection) {
+ return direction === "-" ? "success" : "error";
+ }
+ return direction === "+" ? "success" : "error";
+};
+
/**
* Displays a diff value with color coding
* Used for scores, latency, and cost diffs in compare view
@@ -13,16 +20,18 @@ export function DiffLabel({
diff,
formatValue,
className,
+ preferNegativeDiff = false,
}: {
diff: NumericDiff | CategoricalDiff;
formatValue: (value: number) => string;
className?: string;
+ preferNegativeDiff?: boolean;
}) {
if (diff.type === "NUMERIC") {
return (
<Badge
size="sm"
- variant={diff.direction === "+" ? "success" : "error"}
+ variant={getVariant(diff.direction, preferNegativeDiff)}
className={cn("font-semibold", className)}
>
{diff.direction}