From 1bb5f0a428cb1d64f604e4e7a300148e1ed56a95 Mon Sep 17 00:00:00 2001 From: Ryan Brooks Date: Thu, 19 Nov 2026 10:14:14 -0800 Subject: [PATCH] Docs and versioning --- .github/workflows/ci.yml | 11 + .github/workflows/docs.yml | 41 + Makefile | 8 +- VERSION | 1 + core/README.md | 3 + core/src/cli/args.rs | 1 + docs/.gitignore | 5 + docs/README.md | 58 + docs/app/cases-and-runners/page.mdx | 79 + docs/app/cli/page.mdx | 51 + docs/app/concepts/page.mdx | 37 + docs/app/configuration/page.mdx | 43 + docs/app/credentials/page.mdx | 42 + docs/app/globals.css | 22 + docs/app/judges/page.mdx | 69 + docs/app/layout.tsx | 37 + docs/app/online-evals/page.mdx | 64 + docs/app/page.mdx | 37 + docs/app/protocol/page.mdx | 40 + docs/app/quick-start/page.mdx | 108 + docs/app/run-directory/page.mdx | 27 + docs/app/seeds/page.mdx | 62 + docs/components/docsShell.tsx | 236 + docs/components/emotionRegistry.tsx | 55 + docs/components/languageContext.tsx | 83 + docs/components/languages.ts | 25 + docs/components/mdx.tsx | 416 ++ docs/components/nav.ts | 39 + docs/components/providers.tsx | 46 + docs/components/themeContext.tsx | 95 + docs/components/themeMode.ts | 19 + docs/eslint.config.mjs | 18 + docs/mdx-components.tsx | 42 + docs/next.config.ts | 20 + docs/package.json | 39 + docs/pnpm-lock.yaml | 6263 +++++++++++++++++++++++++++ docs/tsconfig.json | 41 + scripts/version.py | 116 + sdks/python/eac/__init__.py | 4 +- sdks/python/eac/_version.py | 3 + sdks/python/pyproject.toml | 6 +- 41 files changed, 8408 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/docs.yml create mode 100644 VERSION create mode 100644 docs/.gitignore create mode 100644 docs/README.md create mode 100644 docs/app/cases-and-runners/page.mdx create mode 100644 docs/app/cli/page.mdx create mode 100644 docs/app/concepts/page.mdx create mode 100644 docs/app/configuration/page.mdx create mode 100644 docs/app/credentials/page.mdx create mode 100644 docs/app/globals.css create mode 100644 docs/app/judges/page.mdx create mode 100644 docs/app/layout.tsx create mode 100644 docs/app/online-evals/page.mdx create mode 100644 docs/app/page.mdx create mode 100644 docs/app/protocol/page.mdx create mode 100644 docs/app/quick-start/page.mdx create mode 100644 docs/app/run-directory/page.mdx create mode 100644 docs/app/seeds/page.mdx create mode 100644 docs/components/docsShell.tsx create mode 100644 docs/components/emotionRegistry.tsx create mode 100644 docs/components/languageContext.tsx create mode 100644 docs/components/languages.ts create mode 100644 docs/components/mdx.tsx create mode 100644 docs/components/nav.ts create mode 100644 docs/components/providers.tsx create mode 100644 docs/components/themeContext.tsx create mode 100644 docs/components/themeMode.ts create mode 100644 docs/eslint.config.mjs create mode 100644 docs/mdx-components.tsx create mode 100644 docs/next.config.ts create mode 100644 docs/package.json create mode 100644 docs/pnpm-lock.yaml create mode 100644 docs/tsconfig.json create mode 100644 scripts/version.py create mode 100644 sdks/python/eac/_version.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e6fd21..c3a64b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,3 +36,14 @@ jobs: - name: Lint run: make lint + + version: + name: make version-check + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + # No Python setup: the script only needs the image's python3. + - name: Check versions match VERSION + run: make version-check diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..f3edaca --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,41 @@ +name: Docs + +on: + pull_request: + paths: + - docs/** + - .github/workflows/docs.yml + +permissions: + contents: read + +jobs: + lint: + name: docs lint + runs-on: ubuntu-latest + timeout-minutes: 10 + defaults: + run: + working-directory: docs + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + # Uses the pnpm version in docs/package.json's packageManager field. + - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1 + with: + package_json_file: docs/package.json + + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: 24 + cache: pnpm + cache-dependency-path: docs/pnpm-lock.yaml + + - name: Install + run: pnpm install --frozen-lockfile + + - name: Lint + run: pnpm lint + + - name: Typecheck + run: pnpm typecheck diff --git a/Makefile b/Makefile index eaec3e2..0dc33e6 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ PYTHON ?= python3 MANIFEST := core/Cargo.toml .DEFAULT_GOAL := help -.PHONY: help build install test lint generate generate-check +.PHONY: help build install test lint generate generate-check version version-check help: ## list the targets @awk -F ':.*## ' '/^[a-z-]+:.*## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST) @@ -25,3 +25,9 @@ generate: ## regenerate protocol.schema.json and the Python SDK's protocol.py generate-check: ## fail if a generated file is out of date $(PYTHON) scripts/generate.py --check + +version: ## copy the version in VERSION into the CLI and SDKs + $(PYTHON) scripts/version.py + +version-check: ## fail if the CLI or an SDK doesn't match VERSION + $(PYTHON) scripts/version.py --check diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..6e8bf73 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.0 diff --git a/core/README.md b/core/README.md index 4dc0193..3343225 100644 --- a/core/README.md +++ b/core/README.md @@ -123,6 +123,8 @@ make test # unit and end-to-end tests make lint # clippy, failing on any warning make generate # regenerate the files derived from src/schema/ make generate-check # fail if a generated file is out of date +make version # copy the version in VERSION into the CLI and SDKs +make version-check # fail if the CLI or an SDK doesn't match VERSION ``` `cargo run` builds and runs the CLI in one step, and the example project makes a handy target: @@ -139,6 +141,7 @@ Unit tests sit next to the code they test. The end-to-end tests in `tests/cli.rs - **New flag or command** - define it in `src/cli/args.rs` (shared flags go in `flags.rs`), route it in `dispatch.rs` and implement it in `src/commands/`. - **New config key** - add it to `eac_yml.rs` or `dataset_yml.rs` in `src/eac/config/` and check it in that module's `impl Loader`, so mistakes fail before anything runs. Then document it below. +- **New version** - change `VERSION` at the repo root and run `make version`, which updates `Cargo.toml`, `Cargo.lock` and each SDK's version. CI's `make version-check` fails if they drift. `eac --version` prints it. - **Protocol change** - edit the types in `src/schema/` and run `make generate` (needs Python 3.9+), which rewrites `protocol.schema.json` and the Python SDK's `protocol.py`. Then update [PROTOCOL.md](PROTOCOL.md), the Python SDK and the stand-in worker in `tests/fixtures/project`. ## Reference diff --git a/core/src/cli/args.rs b/core/src/cli/args.rs index 73bb348..dd92373 100644 --- a/core/src/cli/args.rs +++ b/core/src/cli/args.rs @@ -14,6 +14,7 @@ use crate::schema::Object; #[derive(Parser)] #[command( name = "eac", + version, about = "Run evals defined in code", after_help = "exit codes: 0 all passed, 1 failures or errors, 2 eac itself failed" )] diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..29c353c --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,5 @@ +node_modules/ +.next/ +out/ +next-env.d.ts +*.tsbuildinfo diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..3693fbe --- /dev/null +++ b/docs/README.md @@ -0,0 +1,58 @@ +# docs + +eac docs - a Next.js app with pages written in MDX and styled with [`@sentry/scraps`](https://www.npmjs.com/package/@sentry/scraps). + +```sh +pnpm install +pnpm dev # http://localhost:3000 +pnpm build +pnpm lint # ESLint, failing on any warning +pnpm typecheck # TypeScript +``` + +CI runs `pnpm lint` and `pnpm typecheck` on pull requests that change +`docs/` (`.github/workflows/docs.yml`). + +## Adding a page + +1. Create `app//page.mdx`, starting with `export const metadata = {title: '...'}`. +2. Add it to the sidebar in `components/nav.ts`. + +## Languages + +The dropdown at the top of the sidebar picks the SDK language, and pages show code for that language. The list lives in `components/languages.ts`. To add one: + +1. Add it to `LANGUAGES`, with the code fence names that count as it. +2. Add its version of each sample next to the existing ones: + + ````mdx + + + ```python + ... + ``` + + ```typescript + ... + ``` + + + ```` + +`` shows the sample whose label matches the selected language. For a sample whose label doesn't say the language, like a shell command, wrap it in `` or give its `` a `lang`. When a language has no sample yet, the first one shows with a note. + +`` also works on its own, for examples that only apply to some languages. + +## Light and dark + +The switcher in the header toggles Scraps' `lightTheme` and `darkTheme` +(`components/themeContext.tsx`). Until a reader picks one, the site follows +their OS. The choice is kept in a cookie that `app/layout.tsx` reads, so the +server renders the right theme and there's no flash of the wrong one. Reading +the cookie makes pages render per request rather than at build time. + +## Version + +The version in the header comes from `VERSION` at the repo root, which +`next.config.ts` reads at build time. Run `make version` from the root after +changing it, so the CLI and SDKs match. diff --git a/docs/app/cases-and-runners/page.mdx b/docs/app/cases-and-runners/page.mdx new file mode 100644 index 0000000..f5fc2ba --- /dev/null +++ b/docs/app/cases-and-runners/page.mdx @@ -0,0 +1,79 @@ +export const metadata = {title: 'Cases and runners'}; + +# Cases and runners + +A **case** is one input to test. A **runner** takes a case, calls your system, and returns whatever it got back. + +## Cases + + + +```python +from eac import Case +from eac.judges import Contains, Equals + +CASES = [ + Case( + name="greets", + input={"query": "hi"}, + expected_output={"response": "hello"}, + judges=[Contains(["hello"]), Equals()], + splits=["smoke"], + ), +] +``` + + + +A few other options you might want: + +- `seeds=[...]` for fixtures the case needs. See [Seeds](/seeds). +- `enabled=False` to skip a case unless you ask for it by name. +- `splits` to group cases, then run a group with `--split smoke`. + + + +Prefer keeping cases in data files? `from_jsonl("cases/*.jsonl", judges=[...])` loads one case per line. + + + +## Runners + + + +```python +from eac import OfflineRunner + +class ChatRunner(OfflineRunner): + def execute(self, case, ctx): + reply = my_chatbot(case.input["query"], tag=ctx.conversation_id) + return {"response": reply} +``` + + + +Return plain JSON and leave the scoring to your judges. The `ctx` gives you: + +- `ctx.seed("name")` to get a fixture. +- `ctx.args` for anything passed with `--args`. +- `ctx.conversation_id` to tag your agent's run, so judges can find its trace later. + + + Runners, judges and seeds can be sync or async. Use whichever fits your code. + + +## Comparing variants + +Want to compare two models or agents on the same cases? Add a comparison to `dataset.yml`: + +```yaml +offline: + comparisons: + - name: models + arms: + - name: small + - name: big + args: {model: big} +``` + +Then run `eac offline compare models`. Each arm gets its own run, and they share fixtures. diff --git a/docs/app/cli/page.mdx b/docs/app/cli/page.mdx new file mode 100644 index 0000000..74f833d --- /dev/null +++ b/docs/app/cli/page.mdx @@ -0,0 +1,51 @@ +export const metadata = {title: 'CLI'}; + +# CLI + +Run `eac --help` any time for the full list. + +## Commands + + + +## Common flags + +
+ +`--dataset`, `--case`, `--split` and `--judge` can be repeated. + +## Exit codes + +`0` means everything passed, `1` means a case failed, and `2` means eac itself hit a problem. diff --git a/docs/app/concepts/page.mdx b/docs/app/concepts/page.mdx new file mode 100644 index 0000000..f128c82 --- /dev/null +++ b/docs/app/concepts/page.mdx @@ -0,0 +1,37 @@ +export const metadata = {title: 'How eac works'}; + +# How eac works + +## Projects and datasets + +A **project** is any folder with an `eac.yml` in it. A **dataset** is a `dataset.yml` and the code next to it. eac finds every dataset under the project root on its own, so adding one never means editing shared config. + +## Workers + +The CLI doesn't run your code itself. Instead, it starts a **worker** process for your language and sends it work over a small JSON protocol. That's what lets eac support more than one language. + +Workers handle one thing at a time, so you never have to think about thread safety. To run cases in parallel, set `concurrency` and eac starts more workers. + +## Runs + +Every run gets its own folder, and each phase reads the previous phase's output from there. So you can: + +- Seed in one CI job and collect in another. +- Re-judge an old run after tweaking a judge. +- Point your own scripts at the folder to upload results. + +An offline run has three phases: + + + +`eac offline run` does all three in one go. Online runs skip seeding: they **collect** records from production and **judge** them. + +## Passing and failing + +A case passes when every judge gives it a 1. Anything lower is a failure, and if your runner throws, the case errors. Online runs just report average scores, so they never fail. diff --git a/docs/app/configuration/page.mdx b/docs/app/configuration/page.mdx new file mode 100644 index 0000000..d267c60 --- /dev/null +++ b/docs/app/configuration/page.mdx @@ -0,0 +1,43 @@ +export const metadata = {title: 'Configuration'}; + +# Configuration + +## eac.yml + +This file marks your project's root. Every key is optional, so an empty file works fine. + +```yaml +artifacts: .eac # where runs are saved +exclude: [legacy_evals] # folders to skip when looking for datasets + +runtimes: + python: + command: [uv, run, python] + env: {PYTHONPATH: src} + +online: + judges: # judges every online dataset can use + - {name: polite, path: "evals.judges:Polite"} +``` + +If you don't set a Python command, eac uses your active virtualenv, then the nearest `.venv`, then `uv run python` if there's a `uv.lock`, then `python3`. It also loads a `.env` file next to `eac.yml`. + +## dataset.yml + +```yaml +name: chat # lowercase, digits and underscores +runtime: python +agent: chat_agent # optional, used to look up traces + +offline: + runner: ./dataset.py:ChatRunner + cases: ./dataset.py:CASES + concurrency: 4 # optional, defaults to 1 + +online: + runner: ./dataset.py:ProdChats + judges: + - {name: polite, path: ./judges.py:Polite} +``` + +A dataset needs `offline`, `online`, or both. Code can be referenced as `./file.py:name` (relative to the YAML file) or `module.path:name`. diff --git a/docs/app/credentials/page.mdx b/docs/app/credentials/page.mdx new file mode 100644 index 0000000..8bb023c --- /dev/null +++ b/docs/app/credentials/page.mdx @@ -0,0 +1,42 @@ +export const metadata = {title: 'Credentials'}; + +# Credentials + +If your evals need a token or a login, declare it as a credential. eac checks them all before starting, so you don't find out halfway through a run that a token is missing. + + + +```python +from dataclasses import dataclass +from eac import Credential + +@dataclass(frozen=True) +class GitHub(Credential): + name = "github" + repo: str + + def is_authenticated(self, env) -> bool: + return bool(env.get("GITHUB_TOKEN")) + + def authenticate(self) -> dict[str, str]: + token = run_login_flow() + return {"GITHUB_TOKEN": token} + + @property + def setup_instructions(self) -> str: + return "Set GITHUB_TOKEN in .env." +``` + + + +Then add it to whatever needs it: a seed's or judge's `credentials`, or a runner's `credentials(args)` method. + +## Logging in + +If a credential isn't set up, eac offers to run `authenticate()` for you. Whatever it returns is saved to `.eac/credentials/saved.json` (never your `.env`) and reused next time. If there's no `authenticate()`, eac shows the `setup_instructions` instead. + +Run `eac auth` on a new machine to log in to everything at once. In CI, where `$CI` is set, the checks are skipped. + + + Create API clients when you first use them, not in `__init__`. eac checks credentials after building your seeds and judges. + diff --git a/docs/app/globals.css b/docs/app/globals.css new file mode 100644 index 0000000..2f98395 --- /dev/null +++ b/docs/app/globals.css @@ -0,0 +1,22 @@ +*, +*::before, +*::after { + box-sizing: border-box; +} + +html { + -webkit-font-smoothing: antialiased; + scroll-padding-top: 72px; +} + +body { + margin: 0; + font-family: var(--font-rubik), 'Avenir Next', sans-serif; + font-size: 14px; +} + +pre, +code, +kbd { + font-family: var(--font-roboto-mono), Monaco, Consolas, monospace; +} diff --git a/docs/app/judges/page.mdx b/docs/app/judges/page.mdx new file mode 100644 index 0000000..c7933a6 --- /dev/null +++ b/docs/app/judges/page.mdx @@ -0,0 +1,69 @@ +export const metadata = {title: 'Judges'}; + +# Judges + +A judge looks at one output and gives it a score between 0 and 1. + +## Built-in judges + + + +```python +from eac.judges import Contains, Equals +from eac.common.judges.regex_judge import Regex + +Contains(["hello", "world"]) # how many of these appear in the response +Equals() # response matches expected_output exactly +Regex([r"https://\S+"], output_lambda=lambda out: out.get("response", "")) +``` + + + +## Writing your own + +Subclass `Judge` and return a `Score`: + + + +```python +from eac import Judge, Score + +class CalledTool(Judge): + name = "called_tool" + + def __init__(self, tool: str): + self.tool = tool + + def judge(self, *, case_output, case, seed_results, agent_trace=None): + ok = self.tool in case_output.get("tool_calls", []) + return Score( + name=self.name, + score=1.0 if ok else 0.0, + explanation=None if ok else f"{self.tool} wasn't called", + ) +``` + + + +If the judge doesn't apply to a case, return `None`. A score of `None` is saved but doesn't count toward pass or fail. + +Need settings that change per run, like a rubric? Give the judge an `args_model` (a pydantic model) and pass values with `--judge-args`. + +## Reading agent traces + +Some judges need more than the final output, like the agent's full conversation or the tools it called. Implement `get_agent_trace()` to fetch it: + + + +```python +from eac import AgentTrace, Judge + +class TraceJudge(Judge): + def get_agent_trace(self, run): + trace = fetch_trace(run.conversation_id) + return AgentTrace(trace=trace.spans) if trace else None +``` + + + +eac fetches the trace once per case and hands it to every judge as `agent_trace`. It's saved with the run, so re-judging doesn't fetch it again. diff --git a/docs/app/layout.tsx b/docs/app/layout.tsx new file mode 100644 index 0000000..2154fd3 --- /dev/null +++ b/docs/app/layout.tsx @@ -0,0 +1,37 @@ +import type {Metadata} from 'next'; +import {cookies} from 'next/headers'; +import {Roboto_Mono, Rubik} from 'next/font/google'; + +import {DocsShell} from '@/components/docsShell'; +import {Providers} from '@/components/providers'; +import {LANGUAGE_COOKIE} from '@/components/languages'; +import {modeFromCookie, THEME_COOKIE} from '@/components/themeMode'; + +import './globals.css'; + +const rubik = Rubik({subsets: ['latin'], variable: '--font-rubik'}); +const robotoMono = Roboto_Mono({subsets: ['latin'], variable: '--font-roboto-mono'}); + +export const metadata: Metadata = { + title: {default: 'eac docs', template: '%s · eac docs'}, + description: 'Define evals as code and run them with one CLI.', +}; + +export default async function RootLayout({children}: {children: React.ReactNode}) { + const cookieStore = await cookies(); + const themeCookie = cookieStore.get(THEME_COOKIE)?.value; + const languageCookie = cookieStore.get(LANGUAGE_COOKIE)?.value; + return ( + + + + {children} + + + + ); +} diff --git a/docs/app/online-evals/page.mdx b/docs/app/online-evals/page.mdx new file mode 100644 index 0000000..49dde7b --- /dev/null +++ b/docs/app/online-evals/page.mdx @@ -0,0 +1,64 @@ +export const metadata = {title: 'Online evals'}; + +# Online evals + +Online evals score what your system already did in production. There are no cases or fixtures. You fetch recent records and judge them. + +## Set it up + +Add an `online` section to your dataset, with a runner and the judges you want to use: + + + + + +```yaml +name: chat +runtime: python +online: + runner: ./dataset.py:ProdChats + judges: + - {name: greets, path: ./dataset.py:GREETS} +``` + + + + + +The runner's `fetch` returns records from a time window: + + + + + +```python +from eac import OnlineRunner, Record +from eac.judges import Contains + + +class ProdChats(OnlineRunner): + def fetch(self, since, until, limit): + return [ + Record(id=row.id, input={"query": row.query}, output={"response": row.reply}) + for row in query_production(since, until, limit) + ] + + +GREETS = Contains(["hello"]) +``` + + + + + +## Run it + +```sh +eac online run --judge greets --since 24h +``` + + + Production records don't have an expected output, so judges like `Equals` won't work here. Online runs report average scores and never fail. + + +Judges you want in every dataset can go under `online.judges` in `eac.yml`. diff --git a/docs/app/page.mdx b/docs/app/page.mdx new file mode 100644 index 0000000..ab9fc9d --- /dev/null +++ b/docs/app/page.mdx @@ -0,0 +1,37 @@ +export const metadata = {title: 'Introduction'}; + +# eac: evals as code + +eac lets you write evals as plain code and run them with a single CLI. + +You bring three things: + +- A **runner** that calls your system. +- Some **cases** to run it on. +- **Judges** that score what comes back. + +eac handles everything else: setting up fixtures, running each case, scoring the results and saving the run so you can look at it later. + + + +## Offline and online + +**Offline evals** run your system on cases you wrote. Use them in development and CI to catch regressions. + +**Online evals** score what your system already did in production. Nothing gets re-run. eac just pulls recent records and judges them. + +## Why eac? + +- **Evals live with your code.** A dataset is a `dataset.yml` plus some code, anywhere in your repo. +- **Phases are separate commands.** Seed in one CI job and judge in another, or re-judge an old run without running it again. +- **Your results stay yours.** Each run is just a folder of JSON. eac never uploads anything. + +## Next steps + +Start with the [Quick start](/quick-start), or read [how eac works](/concepts) first. diff --git a/docs/app/protocol/page.mdx b/docs/app/protocol/page.mdx new file mode 100644 index 0000000..c97252e --- /dev/null +++ b/docs/app/protocol/page.mdx @@ -0,0 +1,40 @@ +export const metadata = {title: 'Worker protocol'}; + +# Worker protocol + +You only need this page if you're adding support for a new language. If you just want to write evals, head to [Cases and runners](/cases-and-runners). + +## The short version + +eac starts a worker process for your language and talks to it with JSON, one message per line: + +- Requests come in on **fd 3** and responses go out on **fd 4**, so stdout and stderr stay free for logs. +- The worker's first line says which protocol it speaks: `{"protocol": 1}`. +- eac sends one request at a time and waits for the answer. +- When eac closes fd 3, the worker should exit. + +```json +{"id": 1, "method": "case.execute", "params": {}} +{"id": 1, "result": {"output": {}}} +``` + +## Methods + +
+ +The full spec, with every param and result, is in [`core/PROTOCOL.md`](https://github.com/getsentry/eve/blob/main/core/PROTOCOL.md). diff --git a/docs/app/quick-start/page.mdx b/docs/app/quick-start/page.mdx new file mode 100644 index 0000000..2161223 --- /dev/null +++ b/docs/app/quick-start/page.mdx @@ -0,0 +1,108 @@ +export const metadata = {title: 'Quick start'}; + +# Quick start + +Let's set up a project and run a first eval. It takes about five minutes. + +## Install + +eac doesn't have packaged releases yet, so build the CLI from the repo. You'll need Rust 1.87+. + +```sh +make install # puts eac on your PATH +``` + +Then install the SDK into the environment your evals run in: + + + + + +```sh +pip install -e sdks/python # needs Python 3.11+ +``` + + + + + +## Create a project + +An `eac.yml` marks the root of your project. It can be empty. Each dataset gets its own folder: + + + + + +```text +eac.yml +evals/chat/ + dataset.yml + dataset.py +``` + + + + + +The `dataset.yml` tells eac where your code is: + + + + + +```yaml +name: chat +runtime: python +offline: + runner: ./dataset.py:ChatRunner + cases: ./dataset.py:CASES +``` + + + + + +Then write the runner and cases: + + + + + +```python +from eac import Case, OfflineRunner +from eac.judges import Contains + + +def reply(query: str) -> str: + return "hello there" # call your system here + + +class ChatRunner(OfflineRunner): + def execute(self, case, ctx): + return {"response": reply(case.input["query"])} + + +CASES = [ + Case(name="greets", input={"query": "hi"}, judges=[Contains(["hello"])]), +] +``` + + + + + +## Run it + +```sh +eac list # see what eac found +eac offline run # seed, collect and judge +``` + +That's it. The results are saved in `.eac/runs//`. + + + Changed a judge? Run `eac offline judge` to re-score the last run without running your system again. + + +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). diff --git a/docs/app/run-directory/page.mdx b/docs/app/run-directory/page.mdx new file mode 100644 index 0000000..3ed8461 --- /dev/null +++ b/docs/app/run-directory/page.mdx @@ -0,0 +1,27 @@ +export const metadata = {title: 'Run directory'}; + +# Run directory + +Every run is saved to its own folder: + +```text +.eac/runs// + manifest.json what ran, with which args, at which commit + seeds.json the fixtures it used + outputs/ what your runner returned, per case + traces/ agent traces the judges fetched + scores/ each judge's scores, per case + summary.json the overall results +``` + +## Uploading results + +eac never sends results anywhere. If you want them in a dashboard, point a script at the run folder. Commands that judge print the run id, so you can chain them: + +```sh +id=$(eac offline run); ./upload.py ".eac/runs/$id" +``` + + + eac exits with `1` when a case fails, so make sure your script runs either way. + diff --git a/docs/app/seeds/page.mdx b/docs/app/seeds/page.mdx new file mode 100644 index 0000000..2ca836d --- /dev/null +++ b/docs/app/seeds/page.mdx @@ -0,0 +1,62 @@ +export const metadata = {title: 'Seeds'}; + +# Seeds + +Seeds set up the fixtures your cases need, like a test project or user, and clean them up afterwards. + + + +```python +from eac import Seed, stable_hash + +class Project(Seed): + name = "project" + + def __init__(self, slug: str = "demo"): + super().__init__() + self.slug = slug + + def key(self) -> str: + return stable_hash({"seed": self.name, "slug": self.slug}) + + def setup(self) -> dict: + project = create_project(self.slug) + return {"id": project.id, "slug": self.slug} + + def cleanup(self, handle: dict) -> None: + delete_project(handle["id"]) +``` + + + +Attach it with `Case(seeds=[Project()])`, then read it in your runner with `ctx.seed("project")`. + +## Caching + +Setting up fixtures can be slow, so eac caches them between runs: + +- Seeds with the same `key()` are set up once and shared. +- By default, the key changes when you edit the seed's code. +- `eac offline prune` cleans up seeds nothing uses anymore. + +If a case changes its fixtures, use `Case(cache=False)` to get a fresh one each run. If a seed can never be reused, set `cacheable = False` on it. + +## Sharing across machines + +The cache lives on your machine by default. To share fixtures across CI jobs, store them somewhere shared by implementing `load_cached`, `save_cached` and `delete_cached`: + + + +```python +class SharedSeed(Seed): + def load_cached(self, key): + return bucket.get(f"seeds/{self.name}/{key}") + + def save_cached(self, key, handle): + bucket.put(f"seeds/{self.name}/{key}", handle) + + def delete_cached(self, key): + bucket.delete(f"seeds/{self.name}/{key}") +``` + + diff --git a/docs/components/docsShell.tsx b/docs/components/docsShell.tsx new file mode 100644 index 0000000..3f1e75c --- /dev/null +++ b/docs/components/docsShell.tsx @@ -0,0 +1,236 @@ +'use client'; + +import styled from '@emotion/styled'; +import {usePathname} from 'next/navigation'; +import {IconGithub} from '@sentry/icons/github'; +import {IconMoon} from '@sentry/icons/moon'; +import {IconSun} from '@sentry/icons/sun'; +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'; + +import {LanguageSelect} from './languageContext'; +import {NAV} from './nav'; +import {useThemeMode} from './themeContext'; + +const PAGES = NAV.flatMap(section => section.items); + +export function DocsShell({children}: {children: React.ReactNode}) { + const pathname = usePathname(); + const index = PAGES.findIndex(page => page.href === pathname); + const prev = index > 0 ? PAGES[index - 1] : undefined; + const next = index >= 0 && index < PAGES.length - 1 ? PAGES[index + 1] : undefined; + + return ( + +
+ + + + eac + + + + evals-as-code + + + v{process.env.EAC_VERSION} + + + + + } + aria-label="GitHub repository" + /> + +
+ + + + + + Language + + + + {NAV.map(section => ( + + + {section.title} + + + {section.items.map(item => ( +
  • + + {item.title} + +
  • + ))} +
    +
    + ))} +
    +
    +
    + {children} + {(prev || next) && ( + + {prev ? ( + + + Previous + + {prev.title} + + ) : ( + + )} + {next ? ( + + + Next + + {next.title} + + ) : null} + + )} +
    + +
    + ); +} + +function ThemeToggle() { + const {mode, toggle} = useThemeMode(); + const label = mode === 'dark' ? 'Switch to light theme' : 'Switch to dark theme'; + return ( +