Skip to content

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

style(scores): always display scores as aggregates in dataset runs table (#9922)

marliessophiec5c34e2ada86
diff --git a/web/src/components/scores-table-cell.tsx b/web/src/components/scores-table-cell.tsx
index d21ae05c2f..becde9d4d0 100644
--- a/web/src/components/scores-table-cell.tsx
+++ b/web/src/components/scores-table-cell.tsx
@@ -43,18 +43,18 @@ const ScoreValueCounts = ({
export const ScoresTableCell = ({
aggregate,
- showSingleValue = false,
+ displayFormat,
wrap = true,
hasMetadata,
}: {
aggregate: AggregatedScoreData;
- showSingleValue?: boolean;
+ displayFormat: "smart" | "aggregate";
wrap?: boolean;
hasMetadata?: boolean;
}) => {
const projectId = useProjectIdFromURL();
- if (showSingleValue && aggregate.values.length === 1 && projectId) {
+ if (displayFormat === "smart" && aggregate.values.length === 1 && projectId) {
const value =
aggregate.type === "NUMERIC"
? aggregate.average.toFixed(4)
diff --git a/web/src/features/datasets/components/DatasetRunsTable.tsx b/web/src/features/datasets/components/DatasetRunsTable.tsx
index 5ed778d739..0e3b4f03fb 100644
--- a/web/src/features/datasets/components/DatasetRunsTable.tsx
+++ b/web/src/features/datasets/components/DatasetRunsTable.tsx
@@ -276,6 +276,7 @@ export function DatasetRunsTable(props: {
const { scoreColumns, isLoading: isColumnLoading } =
useScoreColumns<DatasetRunRowData>({
+ displayFormat: "aggregate",
scoreColumnKey: "runItemScores",
projectId: props.projectId,
filter: runs.data?.runs?.length
diff --git a/web/src/features/scores/hooks/useScoreColumns.ts b/web/src/features/scores/hooks/useScoreColumns.ts
index 1bb9811a93..261d5b8df7 100644
--- a/web/src/features/scores/hooks/useScoreColumns.ts
+++ b/web/src/features/scores/hooks/useScoreColumns.ts
@@ -19,6 +19,7 @@ function createScoreColumns<T extends Record<string, any>>(
dataType: ScoreDataType;
}>,
scoreColumnKey: keyof T & string,
+ displayFormat: "smart" | "aggregate",
prefix?: string,
): LangfuseColumnDef<T>[] {
return scoreColumns.map(({ key, name, source, dataType }) => {
@@ -43,7 +44,7 @@ function createScoreColumns<T extends Record<string, any>>(
return ScoresTableCell({
aggregate: value,
- showSingleValue: true,
+ displayFormat,
hasMetadata: value.hasMetadata ?? false,
});
},
@@ -51,6 +52,13 @@ function createScoreColumns<T extends Record<string, any>>(
});
}
+/**
+ * Hook to fetch and create score columns for tables.
+ *
+ * @param displayFormat Controls how scores are displayed:
+ * - "smart" (default): Shows single value when there's only one score, aggregate stats when multiple
+ * - "aggregate": Always shows aggregate format (count, avg, etc.) regardless of score count
+ */
export function useScoreColumns<T extends Record<string, any>>({
projectId,
scoreColumnKey,
@@ -59,6 +67,7 @@ export function useScoreColumns<T extends Record<string, any>>({
toTimestamp,
prefix,
isFilterDataPending = false,
+ displayFormat = "smart",
}: {
projectId: string;
scoreColumnKey: keyof T & string;
@@ -67,6 +76,7 @@ export function useScoreColumns<T extends Record<string, any>>({
toTimestamp?: Date;
prefix?: string;
isFilterDataPending?: boolean;
+ displayFormat?: "smart" | "aggregate";
}) {
const scoreColumnsQuery = api.scores.getScoreColumns.useQuery(
{
@@ -86,9 +96,15 @@ export function useScoreColumns<T extends Record<string, any>>({
return createScoreColumns<T>(
toOrderedScoresList(scoreColumnsQuery.data.scoreColumns),
scoreColumnKey,
+ displayFormat,
prefix,
);
- }, [scoreColumnsQuery.data?.scoreColumns, scoreColumnKey, prefix]);
+ }, [
+ scoreColumnsQuery.data?.scoreColumns,
+ scoreColumnKey,
+ prefix,
+ displayFormat,
+ ]);
return {
scoreColumns,