Skip to content

Commit

Permalink
Moved input/output/expected to the bottom of traces
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpocock committed Jan 1, 2025
1 parent e575a76 commit 5676b2a
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 39 deletions.
6 changes: 6 additions & 0 deletions .changeset/clean-suits-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"evalite": patch
"@evalite/core": patch
---

Improved the display of inputs and outputs in traces when custom columns are used.
96 changes: 57 additions & 39 deletions apps/evalite-ui/app/routes/eval.$name.trace.$index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Evalite } from "@evalite/core";
import { getResult } from "@evalite/core/sdk";
import { sum } from "@evalite/core/utils";
import {
Expand Down Expand Up @@ -98,6 +99,37 @@ export default function Page() {
completion_tokens: sum(result.traces, (t) => t.completion_tokens),
}
: undefined;

const hasCustomColumns = isArrayOfRenderedColumns(result.rendered_columns);

const inputOutputSection = (
<>
<MainBodySection title="Input">
<DisplayInput
shouldTruncateText={false}
input={result.input}
></DisplayInput>
</MainBodySection>
<MainBodySeparator />
{result.expected ? (
<>
<MainBodySection title="Expected">
<DisplayInput
shouldTruncateText={false}
input={result.expected}
></DisplayInput>
</MainBodySection>
<MainBodySeparator />
</>
) : null}
<MainBodySection title="Output">
<DisplayInput
shouldTruncateText={false}
input={result.output}
></DisplayInput>
</MainBodySection>
</>
);
return (
<>
<SidebarHeader>
Expand Down Expand Up @@ -199,45 +231,24 @@ export default function Page() {
<MainBodySeparator />
</>
)}
<MainBodySection title="Input">
<DisplayInput
shouldTruncateText={false}
input={result.input}
></DisplayInput>
</MainBodySection>
<MainBodySeparator />
{result.expected ? (
<>
<MainBodySection title="Expected">
<DisplayInput
shouldTruncateText={false}
input={result.expected}
></DisplayInput>
</MainBodySection>
<MainBodySeparator />
</>
) : null}
<MainBodySection title="Output">
<DisplayInput
shouldTruncateText={false}
input={result.output}
></DisplayInput>
</MainBodySection>
{isArrayOfRenderedColumns(result.rendered_columns) &&
result.rendered_columns.map((column) => (
<Fragment key={column.label}>
<MainBodySeparator />
<MainBodySection
title={column.label}
description={undefined}
>
<DisplayInput
shouldTruncateText={false}
input={column.value}
></DisplayInput>
</MainBodySection>
</Fragment>
))}
{!hasCustomColumns && inputOutputSection}
{hasCustomColumns &&
(result.rendered_columns as Evalite.RenderedColumn[]).map(
(column, index) => (
<Fragment key={column.label}>
{index > 0 && <MainBodySeparator />}
<MainBodySection
title={column.label}
description={undefined}
>
<DisplayInput
shouldTruncateText={false}
input={column.value}
></DisplayInput>
</MainBodySection>
</Fragment>
)
)}

{result.scores.map((score) => (
<Fragment key={score.name}>
Expand Down Expand Up @@ -270,6 +281,13 @@ export default function Page() {
) : null}
</Fragment>
))}

{hasCustomColumns && (
<>
<MainBodySeparator />
{inputOutputSection}
</>
)}
</>
)}
{traceBeingViewed && (
Expand Down

0 comments on commit 5676b2a

Please sign in to comment.