Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(traces): show all evaluations in the table" #1819

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/components/trace/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export interface ISpanItem {
startTime: string;
parentId: string | null;
context: ISpanContext;
[otherKeys: string]: unknown;
tokenCountTotal?: number | null;
tokenCountPrompt?: number | null;
tokenCountCompletion?: number | null;
[otherKeys: string]: unknown;
}

interface ISpanContext {
Expand Down
27 changes: 27 additions & 0 deletions app/src/pages/tracing/EvaluationLabel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from "react";

import { Flex, Label, Text } from "@arizeai/components";

import { formatFloat } from "@phoenix/utils/numberFormatUtils";

interface Evaluation {
name: string;
label?: string | null;
score?: number | null;
}
export function EvaluationLabel({ evaluation }: { evaluation: Evaluation }) {
const labelValue =
evaluation.label ||
(typeof evaluation.score == "number" && formatFloat(evaluation.score)) ||
"n/a";
return (
<Label color="cyan-1000">
<Flex direction="row" gap="size-50">
<Text weight="heavy" textSize="small" color="inherit">
{evaluation.name}
</Text>
<Text textSize="small">{labelValue}</Text>
</Flex>
</Label>
);
}
31 changes: 31 additions & 0 deletions app/src/pages/tracing/SpansTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { TimestampCell } from "@phoenix/components/table/TimestampCell";
import { LatencyText } from "@phoenix/components/trace/LatencyText";
import { SpanKindLabel } from "@phoenix/components/trace/SpanKindLabel";
import { SpanStatusCodeIcon } from "@phoenix/components/trace/SpanStatusCodeIcon";
import { useFeatureFlag } from "@phoenix/contexts/FeatureFlagsContext";
import { useStreamState } from "@phoenix/contexts/StreamStateContext";
import { useTracingContext } from "@phoenix/contexts/TracingContext";

Expand All @@ -38,6 +39,7 @@ import {
SpanSort,
SpansTableSpansQuery,
} from "./__generated__/SpansTableSpansQuery.graphql";
import { EvaluationLabel } from "./EvaluationLabel";
import { SpanColumnSelector } from "./SpanColumnSelector";
import { SpanFilterConditionField } from "./SpanFilterConditionField";
import { spansTableCSS } from "./styles";
Expand All @@ -57,6 +59,7 @@ export function SpansTable(props: SpansTableProps) {
const tableContainerRef = useRef<HTMLDivElement>(null);
const [sorting, setSorting] = useState<SortingState>([]);
const [filterCondition, setFilterCondition] = useState<string>("");
const isEvalsEnabled = useFeatureFlag("evals");
const columnVisibility = useTracingContext((state) => state.columnVisibility);
const navigate = useNavigate();
const { data, loadNext, hasNext, isLoadingNext, refetch } =
Expand Down Expand Up @@ -101,6 +104,11 @@ export function SpansTable(props: SpansTableProps) {
value
mimeType
}
spanEvaluations {
name
label
score
}
}
}
}
Expand All @@ -115,6 +123,28 @@ export function SpansTable(props: SpansTableProps) {
return tableData;
}, [data]);
type TableRow = (typeof tableData)[number];
const evaluationColumns: ColumnDef<TableRow>[] = [
{
header: "evaluations",
accessorKey: "spanEvaluations",
enableSorting: false,

cell: ({ row }) => {
return (
<Flex direction="row" gap="size-50" wrap="wrap">
{row.original.spanEvaluations.map((evaluation) => {
return (
<EvaluationLabel
key={evaluation.name}
evaluation={evaluation}
/>
);
})}
</Flex>
);
},
},
];
const columns: ColumnDef<TableRow>[] = [
{
header: "kind",
Expand Down Expand Up @@ -149,6 +179,7 @@ export function SpansTable(props: SpansTableProps) {
cell: TextCell,
enableSorting: false,
},
...(isEvalsEnabled ? evaluationColumns : []),
{
header: "start time",
accessorKey: "startTime",
Expand Down
38 changes: 37 additions & 1 deletion app/src/pages/tracing/TracesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { SpanKindLabel } from "@phoenix/components/trace/SpanKindLabel";
import { SpanStatusCodeIcon } from "@phoenix/components/trace/SpanStatusCodeIcon";
import { ISpanItem } from "@phoenix/components/trace/types";
import { createSpanTree, SpanTreeNode } from "@phoenix/components/trace/utils";
import { useFeatureFlag } from "@phoenix/contexts/FeatureFlagsContext";
import { useStreamState } from "@phoenix/contexts/StreamStateContext";
import { useTracingContext } from "@phoenix/contexts/TracingContext";

Expand All @@ -44,6 +45,7 @@ import {
SpanSort,
TracesTableQuery,
} from "./__generated__/TracesTableQuery.graphql";
import { EvaluationLabel } from "./EvaluationLabel";
import { SpanColumnSelector } from "./SpanColumnSelector";
import { SpanFilterConditionField } from "./SpanFilterConditionField";
import { spansTableCSS } from "./styles";
Expand Down Expand Up @@ -89,7 +91,7 @@ export function TracesTable(props: TracesTableProps) {
const tableContainerRef = useRef<HTMLDivElement>(null);
const [sorting, setSorting] = useState<SortingState>([]);
const [filterCondition, setFilterCondition] = useState<string>("");

const isEvalsEnabled = useFeatureFlag("evals");
const navigate = useNavigate();
const { fetchKey } = useStreamState();
const { data, loadNext, hasNext, isLoadingNext, refetch } =
Expand Down Expand Up @@ -134,6 +136,11 @@ export function TracesTable(props: TracesTableProps) {
spanId
traceId
}
spanEvaluations {
name
label
score
}
descendants {
spanKind
name
Expand All @@ -154,6 +161,11 @@ export function TracesTable(props: TracesTableProps) {
spanId
traceId
}
spanEvaluations {
name
label
score
}
}
}
}
Expand All @@ -175,6 +187,29 @@ export function TracesTable(props: TracesTableProps) {
return tableData;
}, [data]);
type TableRow = (typeof tableData)[number];

const evaluationColumns: ColumnDef<TableRow>[] = [
{
header: "evaluations",
accessorKey: "spanEvaluations",
enableSorting: false,

cell: ({ row }) => {
return (
<Flex direction="row" gap="size-50" wrap="wrap">
{row.original.spanEvaluations.map((evaluation) => {
return (
<EvaluationLabel
key={evaluation.name}
evaluation={evaluation}
/>
);
})}
</Flex>
);
},
},
];
const columns: ColumnDef<TableRow>[] = [
{
header: () => {
Expand Down Expand Up @@ -241,6 +276,7 @@ export function TracesTable(props: TracesTableProps) {
enableSorting: false,
cell: TextCell,
},
...(isEvalsEnabled ? evaluationColumns : []),
{
header: "start time",
accessorKey: "startTime",
Expand Down
55 changes: 41 additions & 14 deletions app/src/pages/tracing/__generated__/SpansTableSpansQuery.graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading