Skip to content

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

feat(datasets): show i/o and expected output on runitems (#1641)

Marc Klingenc3bdf519721f
diff --git a/web/src/components/table/use-cases/IOCell.tsx b/web/src/components/table/use-cases/IOCell.tsx
index 95482547ca..32b7ad733b 100644
--- a/web/src/components/table/use-cases/IOCell.tsx
+++ b/web/src/components/table/use-cases/IOCell.tsx
@@ -13,7 +13,7 @@ export const IOCell = ({
}) => {
return (
<>
- {isLoading ? (
+ {isLoading ? (
<JsonSkeleton className="h-[250px] w-[500px] px-3 py-1" />
) : (
<JSONView json={data} className="h-[250px] w-[500px] overflow-y-auto" />
@@ -42,10 +42,8 @@ export const JsonSkeleton = ({
return (
<div className={cn("w-[500px] rounded-md border", className)}>
<div className="flex flex-col gap-1">
- {[...Array<number>(numRows)].map((_) => (
- <>
- <Skeleton className={generateRandomSize()} />
- </>
+ {[...Array<number>(numRows)].map((_, i) => (
+ <Skeleton className={generateRandomSize()} key={i} />
))}
<br />
</div>
diff --git a/web/src/features/datasets/components/DatasetRunItemsTable.tsx b/web/src/features/datasets/components/DatasetRunItemsTable.tsx
index 27f70f849a..1a53ab707b 100644
--- a/web/src/features/datasets/components/DatasetRunItemsTable.tsx
+++ b/web/src/features/datasets/components/DatasetRunItemsTable.tsx
@@ -9,6 +9,7 @@ import { useQueryParams, withDefault, NumberParam } from "use-query-params";
import { type Score } from "@langfuse/shared";
import { usdFormatter } from "../../../utils/numbers";
+import { IOCell } from "@/src/components/table/use-cases/IOCell";
import useColumnVisibility from "@/src/features/column-visibility/hooks/useColumnVisibility";
import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";
@@ -20,6 +21,11 @@ type RowData = {
traceId: string;
observationId?: string;
};
+ // i/o not set explicitly, but fetched from the server from the cell
+ input?: unknown;
+ output?: unknown;
+ expectedOutput?: unknown;
+
scores: Score[];
latency?: number;
totalCost?: string;
@@ -40,7 +46,7 @@ export function DatasetRunItemsTable(
) {
const [paginationState, setPaginationState] = useQueryParams({
pageIndex: withDefault(NumberParam, 0),
- pageSize: withDefault(NumberParam, 50),
+ pageSize: withDefault(NumberParam, 20),
});
const runItems = api.datasets.runitemsByRunIdOrItemId.useQuery({
...props,
@@ -121,6 +127,55 @@ export function DatasetRunItemsTable(
return <GroupedScoreBadges scores={scores} variant="headings" />;
},
},
+ {
+ accessorKey: "input",
+ header: "Input",
+ id: "input",
+ enableHiding: true,
+ cell: ({ row }) => {
+ const trace: RowData["trace"] = row.getValue("trace");
+ return trace ? (
+ <TraceObservationIOCell
+ traceId={trace.traceId}
+ observationId={trace.observationId}
+ io="input"
+ />
+ ) : null;
+ },
+ },
+ {
+ accessorKey: "output",
+ header: "Output",
+ id: "output",
+ enableHiding: true,
+ cell: ({ row }) => {
+ const trace: RowData["trace"] = row.getValue("trace");
+ return trace ? (
+ <TraceObservationIOCell
+ traceId={trace.traceId}
+ observationId={trace.observationId}
+ io="output"
+ />
+ ) : null;
+ },
+ },
+ {
+ accessorKey: "expectedOutput",
+ header: "Expected Output",
+ id: "expectedOutput",
+ enableHiding: true,
+ cell: ({ row }) => {
+ const datasetItemId: string = row.getValue("datasetItemId");
+ return datasetItemId ? (
+ <DatasetItemIOCell
+ projectId={props.projectId}
+ datasetId={props.datasetId}
+ datasetItemId={datasetItemId}
+ io="expectedOutput"
+ />
+ ) : null;
+ },
+ },
];
const convertToTableRow = (
@@ -186,3 +241,87 @@ export function DatasetRunItemsTable(
</div>
);
}
+
+const TraceObservationIOCell = ({
+ traceId,
+ observationId,
+ io,
+}: {
+ traceId: string;
+ observationId?: string;
+ io: "input" | "output";
+}) => {
+ // conditionally fetch the trace or observation depending on the presence of observationId
+ const trace = api.traces.byId.useQuery(
+ { traceId: traceId },
+ {
+ enabled: !!traceId && !!!observationId,
+ trpc: {
+ context: {
+ skipBatch: true,
+ },
+ },
+ },
+ );
+ const observation = api.observations.byId.useQuery(
+ {
+ observationId: observationId as string, // disabled when observationId is undefined
+ traceId: traceId,
+ },
+ {
+ enabled: !!traceId && !!observationId,
+ trpc: {
+ context: {
+ skipBatch: true,
+ },
+ },
+ },
+ );
+
+ const data = observationId === undefined ? trace.data : observation.data;
+
+ return (
+ <IOCell
+ isLoading={!!!observationId ? trace.isLoading : observation.isLoading}
+ data={io === "output" ? data?.output : data?.input}
+ />
+ );
+};
+
+const DatasetItemIOCell = ({
+ projectId,
+ datasetId,
+ datasetItemId,
+ io,
+}: {
+ projectId: string;
+ datasetId: string;
+ datasetItemId: string;
+ io: "expectedOutput" | "input";
+}) => {
+ const datasetItem = api.datasets.itemById.useQuery(
+ {
+ projectId: projectId,
+ datasetId: datasetId,
+ datasetItemId: datasetItemId,
+ },
+ {
+ trpc: {
+ context: {
+ skipBatch: true,
+ },
+ },
+ },
+ );
+
+ return (
+ <IOCell
+ isLoading={datasetItem.isLoading}
+ data={
+ io === "expectedOutput"
+ ? datasetItem.data?.expectedOutput
+ : datasetItem.data?.input
+ }
+ />
+ );
+};