Skip to content

Commit

Permalink
Added customColumns to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpocock committed Dec 17, 2024
1 parent 4f3d446 commit 9c2415d
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/evalite-docs/astro.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ export default defineConfig({
label: "CLI",
slug: "guides/cli",
},
{
label: "Customizing The UI",
slug: "guides/customizing-the-ui",
},
],
},
{
Expand Down
48 changes: 48 additions & 0 deletions apps/evalite-docs/src/content/docs/guides/customizing-the-ui.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: Customizing The UI
---

import { Aside } from "@astrojs/starlight/components";

## Creating Custom Columns

By default, the Evalite UI renders the input, expected and output columns:

| Input | Expected | Output |
| ------------------------ | --------------------------- | ---------------- |
| `input` passed to `data` | `expected` passed to `data` | Result of `task` |

You can customize the columns shown by the UI by passing an `experimental_customColumns` attribute to the `evalite` function:

```ts
import { evalite } from "evalite";

evalite("My Eval", {
data: async () => {
return [
{ input: { a: 1, b: 2, c: 3, theOnlyPropertyWeWantToShow: "Hello" } },
];
},
task: async (input) => {
return input.theOnlyPropertyWeWantToShow + " World!";
},
experimental_customColumns: async (result) => {
return [
{
label: "Custom Input",
value: result.input.theOnlyPropertyWeWantToShow, // "Hello"
},
{
label: "Output",
value: result.output, // "Hello World!"
},
];
},
});
```

This will show two columns:

| Custom Input | Output |
| ------------ | ------------ |
| Hello | Hello World! |

0 comments on commit 9c2415d

Please sign in to comment.