Skip to content
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
169 changes: 66 additions & 103 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,136 +1,99 @@
# eac (evals-as-code)

Define evals as code and run them with one CLI. Supports both offline and online evals.
EAC is a command line tool & SDKs to write evals for AI systems. It handles fixtures, running and judging your AI system, all configurable through code.

You write the runner that calls your system, the cases, and the judges that score what it returns. eac sets up fixtures, runs every case, scores the outputs and saves each run.
📚 [Full Documentation](https://eac.sentry.dev)

The full docs are at [eac.sentry.dev](https://eac.sentry.dev).
## Get started

## Quick start
### 1. Install

[Examples](examples/) contains basic examples covering a range of cases.
```sh
git clone https://github.com/getsentry/eac.git && cd eac
make install # needs Rust 1.87+
pip install -e sdks/python # needs Python 3.11+
```

### Offline evals
### 2. Write an eval

1. Install the `eac` CLI and the SDK for your language. There are no packaged releases yet, so build the CLI from this repo. [`core/README.md`](core/README.md#build) lists what that needs.
Add a `dataset.yml` and the code it points to, anywhere in your repo.

```sh
make install # puts eac on your PATH
pip install -e sdks/python # into the environment your evals run in
```
```yaml
# evals/chat/dataset.yml
name: chat
runtime: python
offline:
runner: ./dataset.py:ChatRunner
cases: ./dataset.py:CASES
```

2. Add a dataset: a folder anywhere in your repo with a `dataset.yml` and its code. eac finds every `dataset.yml` under the repo's root, or under the nearest folder with an [`eac.yml`](core/README.md#eacyml) if you need shared settings.
```python
# evals/chat/dataset.py
from eac import Case, Judge, OfflineRunner, Score

```
evals/chat/
dataset.yml
dataset.py
```

```yaml
# evals/chat/dataset.yml
name: chat
runtime: python
offline:
runner: ./dataset.py:ChatRunner
cases: ./dataset.py:CASES
```
def reply(query: str) -> str:
return "hello there" if query == "hi" else "see you later" # call your AI agent here

```python
# evals/chat/dataset.py
from eac import Case, Judge, OfflineRunner, Score

class ChatRunner(OfflineRunner):
def run_case(self, case, *, seeds, conversation_id):
return {"response": reply(case.input["query"])}

def reply(query: str) -> str:
return "hello there" # call your system here

class Greets(Judge):
name = "greets_judge"

class ChatRunner(OfflineRunner):
def run_case(self, case, *, seeds, conversation_id):
return {"response": reply(case.input["query"])}
def judge(self, case, *, seeds, agent_trace=None):
response = case.output.get("response", "")
if "hello" in response:
return Score(name=self.name, score=1.0)

return Score(
name=self.name,
score=0.0,
explanation=f"no greeting in {response!r}",
)

class Greets(Judge):
name = "greets"

def judge(self, case, *, seeds, agent_trace=None):
ok = "hello" in case.output.get("response", "")
return Score(name=self.name, score=1.0 if ok else 0.0)
CASES = [
Case(name="greeting", input={"query": "hi"}, judges=[Greets()]),
Case(name="goodbye", input={"query": "bye"}, judges=[Greets()]),
]
```

### 3. Run it

CASES = [Case(name="greets", input={"query": "hi"}, judges=[Greets()])]
```
eac seeds fixtures, runs each case, judges the output and prints the results.

3. Run it from the repo's root:
```sh
eac offline run --dataset chat
```

```sh
eac list # the datasets and cases eac found
eac offline run --dataset chat # seed, execute and judge every case in the chat dataset
```text
RESULTS
+------------------+----------------+----------+
| Case | Status / score | Duration |
+==================+================+==========+
| chat/greeting | PASSED | 0.00s |
| └ greets_judge | 1 | |
| chat/goodbye | FAILED | 0.00s |
| └ greets_judge | 0 | |
+------------------+----------------+----------+

# Alternatively, run each step separately
eac offline seed --dataset chat # seed (create fixtures) into a new run
eac offline execute # execute (run each case) for the latest run
eac offline judge # judge (judge output of execute) for the latest run
```
Below 1
chat/goodbye › greets_judge: no greeting in 'see you later'

[`examples/basic-example-python`](examples/basic-example-python) is a fuller
project to start from.
2 cases 1 passed 1 failed 0 errored
```

### Online evals
`greeting` passes, `goodbye` fails.

Online evals judge what your system already did in production, so nothing is re-run and there are no seeds. You write the runner that collects production runs as cases, and the judges that score them.
## Learn more

1. Install the `eac` CLI and SDK as in step 1 above.
The [docs](https://eac.sentry.dev) cover judges, seeds, [online evals](https://eac.sentry.dev/online-evals) and the full CLI reference. [`examples/`](examples/) has complete projects to start from.

2. Add an `online` section to a dataset, with its runner and the judges `--judge` can pick from. A dataset can have both an `offline` and an `online` section:

```yaml
# evals/chat/dataset.yml
name: chat
runtime: python
online:
runner: ./dataset.py:ProdChats
judges:
- {name: greets, path: ./dataset.py:Greets}
```

```python
# evals/chat/dataset.py, next to the Greets judge above
from eac import Case, OnlineRunner


class ProdChats(OnlineRunner):
def collect_cases(self, window):
rows = [{"id": "trace-1", "query": "hi", "reply": "hello there"}] # query production here
return [
Case(name=row["id"], input={"query": row["query"]}, output={"response": row["reply"]})
for row in rows[: window.limit]
]
```

3. Run it from the repo's root:

```sh
eac online run --dataset chat --judge greets --since 24h # collect the last 24h of production runs and judge them

# Alternatively, run each step separately
eac online execute --dataset chat --since 24h # execute (collect production runs as cases) into a new run
eac online judge --judge greets # judge the latest collected run
```

The `assistant` dataset in [`examples/basic-example-python`](examples/basic-example-python) has an online section too.

## SDKs

Each SDK's README covers cases, runners, judges and seeds, including sharing seeds between machines and fetching agent traces.

- Python: [`sdks/python`](sdks/python/README.md)

## More

- [eac.sentry.dev](https://eac.sentry.dev): the full docs.
- [`core/README.md`](core/README.md): Covers the CLI and core framework details.
- [`core/PROTOCOL.md`](core/PROTOCOL.md): how the CLI talks to an SDK, for creating a new SDK.
For contributors: [`core/README.md`](core/README.md) covers the CLI, [`core/PROTOCOL.md`](core/PROTOCOL.md) how it talks to an SDK, and [`CONTRIBUTING.md`](CONTRIBUTING.md) releasing.

## License

Expand Down
9 changes: 9 additions & 0 deletions docs/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- BEGIN:nextjs-agent-rules -->

## This is NOT the Next.js you know

This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` (resolved from this file's directory; in monorepos the `next` package may not be visible from the repo root) before writing any code. Heed deprecation notices.

This block is written and re-added by `next dev` — verify at `node_modules/next/dist/server/lib/generate-agent-files.js`. Removing it from a diff only re-creates the uncommitted change; committing it with your work keeps the tree clean.

<!-- END:nextjs-agent-rules -->
6 changes: 6 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ pnpm typecheck # TypeScript
CI runs `pnpm lint` and `pnpm typecheck` on pull requests that change
`docs/` (`.github/workflows/docs.yml`).

## Landing page

`/` is a full-width landing page (`app/page.tsx`, `components/landing.tsx`) with
a short quick start and links into the docs, which start at `/introduction`.
`components/docsShell.tsx` leaves out the sidebar on it.

## Adding a page

1. Create `app/<slug>/page.mdx`, starting with `export const metadata = {title: '...'}`.
Expand Down
16 changes: 15 additions & 1 deletion docs/app/globals.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/*
* Roboto Mono has no box-drawing characters (│ └ ─ ...). next/font puts its
* generated "Roboto Mono Fallback" (a resized Arial) right after it, so that
* would draw them, too wide for the grid. This face covers only that range,
* from a system monospace font at the same width, and goes first in the mono
* stack. Everything else falls through to Roboto Mono.
*/
@font-face {
font-family: 'Mono Box Drawing';
src: local('Menlo Regular'), local('Menlo-Regular'), local('Menlo'), local('Monaco'),
local('DejaVu Sans Mono'), local('Consolas');
unicode-range: U+2500-257F;
}

*,
*::before,
*::after {
Expand All @@ -18,5 +32,5 @@ body {
pre,
code,
kbd {
font-family: var(--font-roboto-mono), Monaco, Consolas, monospace;
font-family: 'Mono Box Drawing', var(--font-roboto-mono), Monaco, Consolas, monospace;
}
File renamed without changes.
11 changes: 11 additions & 0 deletions docs/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type {Metadata} from 'next';

import {Landing} from '@/components/landing';

export const metadata: Metadata = {
title: {absolute: 'eac: evals as code'},
};

export default function Home() {
return <Landing />;
}
2 changes: 1 addition & 1 deletion docs/app/protocol/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ eac starts a worker process for your language and talks to it with JSON, one mes
]}
/>

The full spec, with every param and result, is in [`core/PROTOCOL.md`](https://github.com/getsentry/eve/blob/main/core/PROTOCOL.md).
The full spec, with every param and result, is in [`core/PROTOCOL.md`](https://github.com/getsentry/eac/blob/main/core/PROTOCOL.md).
2 changes: 1 addition & 1 deletion docs/app/quick-start/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ That's it. The results are saved in `.eac/runs/<id>/`.
Changed a judge? Run `eac offline judge` to re-score the last run without running your system again.
</Callout>

For a bigger example with seeds and online evals, see [`examples/basic-example-python`](https://github.com/getsentry/eve/tree/main/examples/basic-example-python).
For a bigger example with seeds and online evals, see [`examples/basic-example-python`](https://github.com/getsentry/eac/tree/main/examples/basic-example-python).
2 changes: 1 addition & 1 deletion docs/app/run-directory/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Every run is saved to its own folder:

## Uploading results

eac never sends results anywhere. If you want them in a dashboard, point a script at the run's `results/` folder. It's the one format meant for other tools: [`schemas/results.schema.json`](https://github.com/getsentry/eve/blob/main/schemas/results.schema.json) describes it, and its `schema_version` goes up whenever a change could break a reader. Commands that judge print the run id, so you can chain them:
eac never sends results anywhere. If you want them in a dashboard, point a script at the run's `results/` folder. It's the one format meant for other tools: [`schemas/results.schema.json`](https://github.com/getsentry/eac/blob/main/schemas/results.schema.json) describes it, and its `schema_version` goes up whenever a change could break a reader. Commands that judge print the run id, so you can chain them:

```sh
id=$(eac offline run); ./upload.py ".eac/runs/$id"
Expand Down
75 changes: 48 additions & 27 deletions docs/components/docsShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {usePathname} from 'next/navigation';
import {IconGithub} from '@sentry/icons/github';
import {IconMoon} from '@sentry/icons/moon';
import {IconSun} from '@sentry/icons/sun';
import {Badge} from '@sentry/scraps/badge';
import {Button, LinkButton} from '@sentry/scraps/button';
import {InlineCode} from '@sentry/scraps/code';
import {Flex, Stack} from '@sentry/scraps/layout';
import {Link} from '@sentry/scraps/link';
import {Prose, Text} from '@sentry/scraps/text';
Expand All @@ -23,34 +23,19 @@ export function DocsShell({children}: {children: React.ReactNode}) {
const prev = index > 0 ? PAGES[index - 1] : undefined;
const next = index >= 0 && index < PAGES.length - 1 ? PAGES[index + 1] : undefined;

// The landing page is full width, without the sidebar or pager.
if (pathname === '/') {
return (
<Page>
<SiteHeader />
{children}
</Page>
);
}

return (
<Page>
<Header>
<Flex align="center" gap="md">
<Link to="/">
<Text size="xl" bold>
eac
</Text>
</Link>
<Text variant="muted" size="sm">
evals-as-code
</Text>
<InlineCode aria-label={`Latest version ${process.env.EAC_VERSION}`}>
v{process.env.EAC_VERSION}
</InlineCode>
</Flex>
<Flex align="center" gap="xs">
<ThemeToggle />
<LinkButton
href="https://github.com/getsentry/eve"
external
size="sm"
variant="transparent"
icon={<IconGithub />}
aria-label="GitHub repository"
/>
</Flex>
</Header>
<SiteHeader />
<Body>
<Sidebar aria-label="Docs">
<Stack gap="xl">
Expand Down Expand Up @@ -111,6 +96,42 @@ export function DocsShell({children}: {children: React.ReactNode}) {
);
}

function SiteHeader() {
return (
<Header>
<Flex align="center" gap="md">
<Link to="/" aria-label="eac home">
<Stack gap="2xs">
<Text size="xl" bold density="compressed">
eac
</Text>
<Text size="xs" variant="muted" density="compressed">
evals as code
</Text>
</Stack>
</Link>
<Badge variant="muted" aria-label={`Latest version ${process.env.EAC_VERSION}`}>
v{process.env.EAC_VERSION}
</Badge>
</Flex>
<Flex align="center" gap="xs">
<LinkButton to="/introduction" size="sm" variant="transparent">
Docs
</LinkButton>
<LinkButton
href="https://github.com/getsentry/eac"
external
size="sm"
variant="transparent"
icon={<IconGithub />}
aria-label="GitHub repository"
/>
<ThemeToggle />
</Flex>
</Header>
);
}

function ThemeToggle() {
const {mode, toggle} = useThemeMode();
const label = mode === 'dark' ? 'Switch to light theme' : 'Switch to dark theme';
Expand Down
Loading
Loading