evalblink 0.1.4__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- evalblink-0.2.0/CHANGELOG.md +102 -0
- evalblink-0.2.0/CLAUDE.md +95 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/MANIFEST.in +2 -1
- evalblink-0.2.0/PKG-INFO +473 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/PRD.md +88 -62
- evalblink-0.2.0/README.md +437 -0
- evalblink-0.2.0/benchmarks/cases/labeled_conversations.csv +21 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/benchmarks/classification.yaml +3 -3
- {evalblink-0.1.4 → evalblink-0.2.0}/benchmarks/csv_classification.yaml +1 -1
- {evalblink-0.1.4 → evalblink-0.2.0}/benchmarks/llm_as_judge.yaml +1 -1
- evalblink-0.2.0/benchmarks/llmaas_labeling.yaml +63 -0
- evalblink-0.2.0/benchmarks/local_models.yaml +80 -0
- evalblink-0.2.0/benchmarks/scorers.py +28 -0
- evalblink-0.2.0/benchmarks/structured_output.yaml +65 -0
- evalblink-0.2.0/benchmarks/text_checks.yaml +60 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/benchmarks/weighted_match_config.yaml +1 -1
- evalblink-0.2.0/docs/reference.md +640 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/evalblink/__init__.py +1 -1
- evalblink-0.2.0/evalblink/analysis.py +300 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/evalblink/compare.py +46 -14
- {evalblink-0.1.4 → evalblink-0.2.0}/evalblink/dataset.py +8 -5
- {evalblink-0.1.4 → evalblink-0.2.0}/evalblink/estimate.py +15 -5
- evalblink-0.2.0/evalblink/evaluator.py +486 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/evalblink/main.py +125 -11
- evalblink-0.2.0/evalblink/openrouter.py +842 -0
- evalblink-0.2.0/evalblink/providers.py +393 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/evalblink/reporter.py +115 -19
- {evalblink-0.1.4 → evalblink-0.2.0}/evalblink/runner.py +150 -39
- {evalblink-0.1.4 → evalblink-0.2.0}/evalblink/schemas.py +39 -4
- {evalblink-0.1.4 → evalblink-0.2.0}/evalblink/starter.py +3 -2
- evalblink-0.2.0/evalblink/validator.py +985 -0
- evalblink-0.2.0/evalblink.egg-info/PKG-INFO +473 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/evalblink.egg-info/SOURCES.txt +12 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/evalblink.egg-info/requires.txt +4 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/pyproject.toml +3 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/tests/test_dataset.py +18 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/tests/test_docs_drift.py +27 -1
- {evalblink-0.1.4 → evalblink-0.2.0}/tests/test_evaluator.py +83 -0
- evalblink-0.2.0/tests/test_gateway.py +1017 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/tests/test_init.py +2 -2
- evalblink-0.2.0/tests/test_latency_repeats.py +374 -0
- evalblink-0.2.0/tests/test_local_providers.py +419 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/tests/test_main.py +3 -1
- {evalblink-0.1.4 → evalblink-0.2.0}/tests/test_models_live.py +5 -4
- {evalblink-0.1.4 → evalblink-0.2.0}/tests/test_no_crash.py +68 -1
- {evalblink-0.1.4 → evalblink-0.2.0}/tests/test_openrouter.py +23 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/tests/test_reporter.py +13 -1
- {evalblink-0.1.4 → evalblink-0.2.0}/tests/test_run_pipeline.py +35 -0
- evalblink-0.2.0/tests/test_structured_scorers.py +273 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/tests/test_validator.py +56 -4
- evalblink-0.1.4/CHANGELOG.md +0 -66
- evalblink-0.1.4/CLAUDE.md +0 -87
- evalblink-0.1.4/PKG-INFO +0 -763
- evalblink-0.1.4/README.md +0 -730
- evalblink-0.1.4/evalblink/analysis.py +0 -133
- evalblink-0.1.4/evalblink/evaluator.py +0 -250
- evalblink-0.1.4/evalblink/openrouter.py +0 -416
- evalblink-0.1.4/evalblink/validator.py +0 -487
- evalblink-0.1.4/evalblink.egg-info/PKG-INFO +0 -763
- {evalblink-0.1.4 → evalblink-0.2.0}/CONTRIBUTING.md +0 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/LICENSE +0 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/benchmarks/cases/support_tickets.csv +0 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/benchmarks/exact_match_classification.yaml +0 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/evalblink/__main__.py +0 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/evalblink/cache.py +0 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/evalblink.egg-info/dependency_links.txt +0 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/evalblink.egg-info/entry_points.txt +0 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/evalblink.egg-info/top_level.txt +0 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/setup.cfg +0 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/tests/conftest.py +0 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/tests/test_analysis.py +0 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/tests/test_cache.py +0 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/tests/test_compare.py +0 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/tests/test_estimate.py +0 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/tests/test_runner.py +0 -0
- {evalblink-0.1.4 → evalblink-0.2.0}/tests/test_workflows.py +0 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to evalblink. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow [Semantic Versioning](https://semver.org/).
|
|
4
|
+
|
|
5
|
+
## [Unreleased]
|
|
6
|
+
|
|
7
|
+
## [0.2.0] — 2026-12-01
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- **Latency.** Every candidate call's latency is measured: the wall time of the attempt that returned the reply, without retries, backoff or judge calls. It shows on each progress line (`pass 0.62s`), as p50 in the results table, p50 and p95 in the Markdown report, per case and per combo in the JSON (`latency_s`, `latency_p50_s`, `latency_p95_s`, `latency_mean_s`), as a **Fastest** line in the recommendation, and as a `p50 latency Δ` column in `compare`. A cached reply keeps the latency measured when it was fetched.
|
|
11
|
+
- **Confidence intervals and noise.** Each score comes with its 95 % interval (Wilson, over the number of test cases): `96.0% (87–99)` in the table, `score_ci` in the JSON. The recommendation lists the combos **within noise** of the best one (not distinguishable at 95 %), and `compare` marks quality changes within noise and says how many gains are beyond it.
|
|
12
|
+
- **`repeats: N`** runs every model × prompt × test case N times (each repeat with its own cache entry). The score covers every repeat, cases whose repeats disagree are reported as **flaky**, and `--dry-run` multiplies the estimate by N.
|
|
13
|
+
- **`json_match`**: the reply's JSON must hold the values in `expected_output` (extra keys ignored, strings ignore case, partial credit shown). **`json_schema`**: the reply's JSON must satisfy a JSON Schema. **`python`**: your own scorer, `scorer: "scorers.py:my_check"`, returning `True`/`False` or `{passed, score, reason}`; a scorer that raises is a pipeline error (`scorer error`), not a failed case. Example: `benchmarks/structured_output.yaml`.
|
|
14
|
+
- **GitHub Action** (`action.yml`): `uses: alexandre-darmon/evalblink@<tag>` runs a benchmark, puts the report in the job summary, and fails the job on the quality gate or, with `baseline`, on a regression.
|
|
15
|
+
- **Local and self-hosted models.** A model id `ollama:llama3.2` (or `lmstudio:…`, `llamacpp:…`, `vllm:…`) runs on that server at its default local address, next to OpenRouter models in the same run; a `providers:` block moves a built-in server or adds any OpenAI-compatible one (`base_url`, optional `api_key_env`, `concurrency`, `timeout`). The data stays on your machine, local calls cost $0, and a run of local models needs no OpenRouter key (`--dry-run` then makes no network call). Before the first call, `run` checks each server and model and says how to fix a problem (`Start it: ollama serve`, `Get it: ollama pull llama3.2`). Each built-in server gets one request at a time by default, so its queue never counts as latency. The judge can be local too. Example: `benchmarks/local_models.yaml`.
|
|
16
|
+
- **Company LLM gateways** (an internal "LLM as a service", LiteLLM, a proxy in front of Azure OpenAI) as providers. A `providers:` entry can send the key in another header (`api_key_header: X-API-Key`, `api_key_prefix: ""`), add fixed `headers`, trust a company CA (`ca_bundle: ca.pem`, or `system` for the OS certificates with `pip install "evalblink[truststore]"`), and read `${VAR}` from the environment in `base_url`, `headers` and `ca_bundle`. `check_models: false` skips the model-list check, and a query in `base_url` (`?api-version=…`) stays at the end of each request URL. A provider you add shares the run's `concurrency` unless it sets a lower one (built-in servers keep 1). Messages and records show a provider URL without its user:password (`***@`) or query (`?…`), and a proxy without its credentials; a key or header value with a line break inside it is refused without being echoed. Certificate errors get a specific hint (unknown CA, another host name, expired), and an unreachable proxy — from the environment or the OS settings — is named. Before the first call, `run` names every unset variable, stops on refused credentials, and gives the real cause of a connection failure with its fix (an untrusted certificate, a proxy, a host that doesn't resolve, a server that is down). `validate` rejects a `base_url` that ends in `/chat/completions` (and gives the root) or isn't a usable URL (a bad port, even from `${VAR}`), a request parameter that isn't plain JSON (a YAML date, `.nan`), and warns on a plain-http URL that carries credentials. Example: `benchmarks/llmaas_labeling.yaml` (conversation labeling). Reference: [Company LLM gateways](docs/reference.md#company-llm-gateways).
|
|
17
|
+
- **Request parameters** for candidate calls: `inference.response_format` (`json_object`, or a JSON Schema), `top_p`, `seed`, and any other body field in `inference.extra_body`. They are part of the cache key; the judge keeps its own request.
|
|
18
|
+
- `docs/reference.md`: the full reference (every config key, validation rule, mode, statistic and output file).
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
- The README is an overview (about a third of its former length), opens with a banner, and its terminal samples are visuals in the same style (`docs/assets/`), each with the full text output in a collapsible block. The details moved to `docs/reference.md`.
|
|
22
|
+
- The terminal results table fits an 80-column terminal: `Score (95% CI)`, `Tokens in/out` and `p50 latency` columns. The Markdown report keeps separate columns.
|
|
23
|
+
- The comparison with promptfoo was rechecked against its documentation and corrected.
|
|
24
|
+
- The roadmap adds evaluating your own application (an HTTP endpoint or a command) for V1.1.
|
|
25
|
+
- Run records are `schema_version` 2 (additive: version 1 records still load, compare and report, with no latency).
|
|
26
|
+
- New dependency: `jsonschema`.
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
- OpenRouter retired `cohere/north-mini-code:free` and `dots-studio/dots-3-note-preview:free`, so the shipped examples failed ("Unknown model" in a dry run, 404 in a run). The new default (`init` and the example benchmarks) is the free `particle-ai/particle-1:free`, picked by running the examples on every free text model outside the judge's vendor: it tied the best (17/20) with no errors and was the faster of the two. `classification.yaml` compares it with `liquid/lfm-3-1.7b:free` (15/20, no errors). Both are full releases, not previews, which OpenRouter retires more often.
|
|
30
|
+
- A run whose test cases have no tags no longer prints an empty **Quality by tag** table.
|
|
31
|
+
- An empty reply only suggests raising `max_tokens` (or `evaluation.judge_max_tokens`) when the reply ran out of tokens (`finish_reason: length`, or none given). A model that stopped on its own with no text, as free judges sometimes do, now gets “retry, or try another model” instead.
|
|
32
|
+
|
|
33
|
+
## [0.1.5] — 2026-11-02
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
- `poolside/laguna-xs-2.1:free` was retired by OpenRouter, so every shipped example failed with a 404. The new default (`init` and the example benchmarks) is the free `cohere/north-mini-code:free`, picked by running the examples on every free text model plus the cheapest paid ones: it tied the best (34/38 cases over two rounds) with no errors, and isn't from the judge's vendor. The suggested paid option is now `openai/gpt-oss-20b`: as accurate here, and cheaper than `google/gemma-4-31b-it` ($0.03 / $0.13 per 1M tokens in / out, against $0.20 / $0.40).
|
|
37
|
+
|
|
38
|
+
### Added
|
|
39
|
+
- Three free, deterministic scorers for free-text replies, using `expected_output`: `contains` (every text appears, ignoring case; one string or a list), `not_contains` (none appears) and `regex` (Python `re.search`; `(?i)` to ignore case). `contains` / `not_contains` compare text as a reader sees it: Unicode spaces, line breaks and dashes count as ` ` and `-`, and invisible characters are ignored. `regex` sees the reply as written (surrounding whitespace ignored). `validate` rejects a missing or empty text and a pattern that doesn't compile. Example: `benchmarks/text_checks.yaml`.
|
|
40
|
+
|
|
41
|
+
## [0.1.4] — 2026-10-31
|
|
42
|
+
|
|
43
|
+
### Changed
|
|
44
|
+
- `run` shows one progress line per finished case, `[3/12] model / prompt / case pass`, with the 0–1 score for `llm_judge` and `weighted_match` and the reason for a pipeline error (`⚠ API error: …`), after a `Running 12 cases (2 models × 2 prompts × 3 test cases), 5 at a time` line. It replaces the `Test case: <id>` lines and the separate per-error warnings.
|
|
45
|
+
- Progress and warnings (retry notices, which now name the model, cache warnings, the judge self-preference warning, the pipeline-error count) go to stderr; the results table, saved paths and PASS/FAIL stay on stdout, so `run … > results.txt` keeps only the results.
|
|
46
|
+
- The per-combo totals printed before the table (a second copy of it) are gone.
|
|
47
|
+
- The `init` starter's comment now holds a ready-to-save `cases.csv` with its own test cases, and the one line to switch to it.
|
|
48
|
+
- CI builds the release artifact with the same workflow as a release (`.github/workflows/build.yml`), downloads it the way `publish.yml` does, checks it holds exactly this version's wheel and sdist, installs both and runs the test suite from the sdist. A broken artifact hand-off now fails on a pull request instead of mid-release.
|
|
49
|
+
- GitHub Actions upgraded to Node 24: `checkout` v7, `setup-python` v7, `upload-artifact` v7, `download-artifact` v8.
|
|
50
|
+
|
|
51
|
+
### Added
|
|
52
|
+
- `evalblink init --csv` writes the starter with its test cases in a spreadsheet next to it (`benchmarks/my-benchmark.yaml` + `benchmarks/my-benchmark.csv`), ready to edit in any spreadsheet app. Shown in `evalblink --help`, `init --help` and the README Quickstart.
|
|
53
|
+
|
|
54
|
+
## [0.1.3] — 2026-10-30
|
|
55
|
+
|
|
56
|
+
### Added
|
|
57
|
+
- Test cases from a CSV, TSV or JSONL file: `test_cases: {file: cases.csv, evaluation: exact_match}`, relative to the YAML. Case-field columns keep their meaning (headers match whatever their case), every other column is a template variable, Excel exports (BOM, `;`-separated) work, and errors — a short row, an unclosed quote — name the file and line. Example: `benchmarks/csv_classification.yaml`.
|
|
58
|
+
- The `init` starter shows how to switch to a file.
|
|
59
|
+
|
|
60
|
+
## [0.1.2] — 2026-10-30
|
|
61
|
+
|
|
62
|
+
### Added
|
|
63
|
+
- `run --model / --prompt / --tag / --limit` run part of a benchmark without editing the YAML.
|
|
64
|
+
- A top-level `gate: {model, prompt}` makes the CI gate check one combo instead of the best one.
|
|
65
|
+
- `compare` with no arguments diffs the two latest runs of a benchmark, and with one run uses it as the baseline for the latest run; `report` with none uses the latest run. Both accept a run ID or a unique prefix of one. Only runs with the same `run` filters (now recorded in the JSON) are paired.
|
|
66
|
+
- `compare --fail-on-regression POINTS` exits 1 when a combo's pass rate, with unscored cases counted as failures, drops by more than `POINTS`, and when no combo could be compared at all — for CI against a kept baseline.
|
|
67
|
+
- `python -m evalblink`.
|
|
68
|
+
- A bare `evalblink` prints the help with a quickstart and the environment variables; every subcommand's help ends with examples.
|
|
69
|
+
- `cache clear --all` also drops the cached model catalog.
|
|
70
|
+
|
|
71
|
+
### Changed
|
|
72
|
+
- `validate` rejects unknown top-level keys and warns about unknown nested ones, with a "did you mean" suggestion (`qualty_threshold` used to switch the CI gate off silently). Keys starting with `_` or `x-` are free.
|
|
73
|
+
- `run --dry-run` exits 1 on a model ID that isn't in the OpenRouter catalog and suggests the closest one.
|
|
74
|
+
- Table cells wrap instead of ending in `…`, so model and run IDs can always be copied.
|
|
75
|
+
- `cache stats` and `cache clear` count cached responses apart from the model catalog, which `clear` keeps unless `--all` is given.
|
|
76
|
+
- A rate limit (HTTP 429) backs off 5 s / 10 s / 20 s with jitter, or the server's `Retry-After`; when retries run out the error says what to do. The `init` starter sets `concurrency: 2`.
|
|
77
|
+
- Jinja2 ≥ 3.1.6 is required (sandbox escape fixes).
|
|
78
|
+
|
|
79
|
+
## [0.1.1] — 2026-10-30
|
|
80
|
+
|
|
81
|
+
### Added
|
|
82
|
+
- `init` asks three questions and writes a commented starter that validates and runs as-is; `init [path]` and `init --yes`.
|
|
83
|
+
- `models --text` (text in, text-only out); `init` suggests free text models and a small paid option.
|
|
84
|
+
- `run` and `validate` with no path use the only YAML in `benchmarks/`.
|
|
85
|
+
|
|
86
|
+
### Changed
|
|
87
|
+
- `compare` notes each combo's pipeline-error count and leaves combos whose count changed out of the verdict.
|
|
88
|
+
- `--dry-run` caps budgets at each model's output limit and warns when `max_tokens` or `judge_max_tokens` exceeds it.
|
|
89
|
+
- `insights.passed` is `false` whenever nothing could be scored, matching exit code 1.
|
|
90
|
+
|
|
91
|
+
## [0.1.0] — 2026-10-29
|
|
92
|
+
|
|
93
|
+
First release: `run`, `validate`, `compare` (`--detailed`), `report`, `history`, `models`, `init` and `cache`, with exact-match, weighted-match and LLM-as-judge scoring through OpenRouter.
|
|
94
|
+
|
|
95
|
+
[Unreleased]: https://github.com/alexandre-darmon/evalblink/compare/v0.2.0...HEAD
|
|
96
|
+
[0.2.0]: https://github.com/alexandre-darmon/evalblink/compare/v0.1.5...v0.2.0
|
|
97
|
+
[0.1.5]: https://github.com/alexandre-darmon/evalblink/compare/v0.1.4...v0.1.5
|
|
98
|
+
[0.1.4]: https://github.com/alexandre-darmon/evalblink/compare/v0.1.3...v0.1.4
|
|
99
|
+
[0.1.3]: https://github.com/alexandre-darmon/evalblink/compare/v0.1.2...v0.1.3
|
|
100
|
+
[0.1.2]: https://github.com/alexandre-darmon/evalblink/compare/v0.1.1...v0.1.2
|
|
101
|
+
[0.1.1]: https://github.com/alexandre-darmon/evalblink/compare/v0.1.0...v0.1.1
|
|
102
|
+
[0.1.0]: https://github.com/alexandre-darmon/evalblink/releases/tag/v0.1.0
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## What this is
|
|
6
|
+
|
|
7
|
+
evalblink benchmarks LLM prompts × models on your own data, routing every call through [OpenRouter](https://openrouter.ai) — or, for a `provider:model` id (`ollama:llama3.2`), to a local or self-hosted OpenAI-compatible server. A run takes a YAML benchmark config, executes `model × prompt × test_case` (× `repeats`), scores each response, measures each call's latency, and writes a results matrix (Rich table: score with its 95 % interval, cost, p50 latency), a JSON record, and a Markdown report. The README is the overview; `docs/reference.md` is the full user reference (every config key, validation rule, mode, statistic and output file) — a user-visible change usually touches both. `action.yml` at the root is a composite GitHub Action (install, run, report in the job summary, optional `compare --fail-on-regression`); CI's `action` job runs it from the checkout on a `--dry-run`.
|
|
8
|
+
|
|
9
|
+
## Commands
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Setup
|
|
13
|
+
pip install -e ".[dev]" # installs evalblink + dev tools (ruff, pytest)
|
|
14
|
+
export OPENROUTER_API_KEY=... # or put it in .env (loaded via python-dotenv)
|
|
15
|
+
|
|
16
|
+
# Run a benchmark
|
|
17
|
+
evalblink run benchmarks/classification.yaml
|
|
18
|
+
evalblink run # the only YAML in benchmarks/, else benchmarks/exact_match_classification.yaml
|
|
19
|
+
evalblink run benchmarks/classification.yaml -v # verbose: per-test-case detail
|
|
20
|
+
evalblink run benchmarks/classification.yaml --no-cache # bypass the response cache (candidate and judge calls)
|
|
21
|
+
evalblink run my_benchmark.yaml -m openai/gpt-4o-mini -p v2 --tag edge_case --limit 5
|
|
22
|
+
evalblink run benchmarks/classification.yaml --dry-run # estimate cost: no completion calls, no API key (fetches the public /models catalog)
|
|
23
|
+
evalblink run benchmarks/local_models.yaml # Ollama on this machine: no OpenRouter key
|
|
24
|
+
evalblink run benchmarks/llmaas_labeling.yaml # company gateway: LLMAAS_URL + LLMAAS_API_KEY in .env
|
|
25
|
+
|
|
26
|
+
# Validate a config (errors and warnings, no API calls)
|
|
27
|
+
evalblink validate benchmarks/classification.yaml
|
|
28
|
+
|
|
29
|
+
# Compare two finished runs (quality + cost deltas; offline, no API calls)
|
|
30
|
+
evalblink compare results/<run_a>.json results/<run_b>.json
|
|
31
|
+
evalblink compare results/<run_a>.json results/<run_b>.json --detailed # per-test-case transitions + global summary
|
|
32
|
+
evalblink compare # the two latest runs of a benchmark; `compare <baseline> --fail-on-regression POINTS` for CI
|
|
33
|
+
|
|
34
|
+
# Other commands
|
|
35
|
+
evalblink report results/<run>.json # regenerate Markdown from existing JSON
|
|
36
|
+
evalblink history # list all past runs
|
|
37
|
+
evalblink models # list OpenRouter models + pricing
|
|
38
|
+
evalblink models --provider anthropic --free --min-context 100k
|
|
39
|
+
evalblink models --free --text # text in, text-only out
|
|
40
|
+
evalblink models --no-cache # refetch the 24h catalog cache
|
|
41
|
+
evalblink init [path] [--yes] [--csv] # 3 questions → a commented starter benchmark (runs as-is); --csv: cases in <stem>.csv next to it
|
|
42
|
+
evalblink cache stats
|
|
43
|
+
evalblink cache clear --yes
|
|
44
|
+
|
|
45
|
+
# Tests
|
|
46
|
+
pytest -q
|
|
47
|
+
|
|
48
|
+
# Lint (ruff is the only dev tool; no config file, uses defaults)
|
|
49
|
+
ruff check .
|
|
50
|
+
ruff format .
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Tests live in `tests/` and run offline (a fake `httpx.Client`, no API key). Beyond unit tests, verify end-to-end by running configs and inspecting the generated `results/<timestamp>_<slug>.{json,md}` files. Runs hit the live OpenRouter API (free models cost $0 but are rate-limited).
|
|
54
|
+
|
|
55
|
+
## Architecture
|
|
56
|
+
|
|
57
|
+
A run flows through one linear pipeline; module boundaries are deliberate, not incidental:
|
|
58
|
+
|
|
59
|
+
- **`main.py`** — `argparse` subcommand dispatcher (`load_dotenv(find_dotenv(usecwd=True), encoding="utf-8-sig")` — `.env` from the cwd or a parent, never the package dir; a non-UTF-8 `.env` is ignored with a warning — then `args.func`, with `KeyboardInterrupt` → exit 130 and `EOFError` → "No input — aborted.", exit 1). Subcommands: `run`, `validate`, `compare`, `report`, `history`, `models`, `init`, `cache stats`, `cache clear`. `run --model/--prompt/--tag/--limit` narrow the already-validated config in `_filtered` (unknown names exit with the available ones; a gate on a filtered-out combo is dropped with a note). `compare`/`report` take paths, run IDs (exact first) or unique prefixes (`_record_path`). `report` alone uses the latest record; `compare` alone diffs the two latest runs, and with one run uses it as the baseline for the latest run — pairing only runs of the same benchmark and the same recorded `filters` (`_run_records` sorts by timestamp, then the reporter's `-N` rerun suffix, then file mtime). `compare --fail-on-regression POINTS` (finite, ≥ 0) exits 1 on `compare.regressions`: a drop of the fail-safe pass rate (`analysis.fail_safe_score`) beyond POINTS on a shared combo with the same test cases (printed as the pass-rate delta); it exits 1 when no combo could be compared (`compare.compared` is 0), and 0 with a note when there is no other run. Filters run after validation of the whole config and are recorded as `_filters` → the record's `filters`. A bare `evalblink` prints the help (quickstart epilog) and exits 0; `python -m evalblink` works via `__main__.py`. Every table column uses `overflow="fold"` so IDs are never cut with `…`. `run`/`validate` without a path use `_default_config` (the only YAML in `benchmarks/`, else `DEFAULT_CONFIG`; several and no `DEFAULT_CONFIG` → exit with the list), announced as `Using <path>` on stderr. `models --text` keeps text models (`_is_text_model`: catalog `text` not `False`). `run` validates the config via `validator.validate` before touching the API — exits 1 with error details on bad config — and (except `--dry-run`) exits 1 with a clear message before any API call if `OPENROUTER_API_KEY` is unset, empty or whitespace-only while `providers.called_models` includes an OpenRouter id, if `_check_local_servers` finds a local server down (`openrouter.fetch_local_models` raises), missing a model it lists (Ollama's `x` matches `x:latest`; `llamacpp`, `check_models: false` and a server that lists nothing are trusted, with a dim note), refusing the credentials (`openrouter.Rejected`, 401/403/407 — only a warning with `check_models: false`), or reading an unset variable (`Endpoint.missing()`: `api_key_env` and every `${VAR}`); a connection failure prints its cause plus `openrouter.connect_hint` (by `verify_code`: another host (62/64) → fix `base_url`, expired (9/10) → clock, unknown CA (2/18–21 or no code) → `ca_bundle`, or "isn't signed by" when one is set; `ProxyError` or the proxy httpx would use (`_env_proxy`: `urllib.request.getproxies()` + `NO_PROXY` with host:port, shown as scheme://host:port) → `NO_PROXY`; DNS → VPN; refused → start hint), and if `results/` can't be created/written. `--dry-run` skips the catalog fetch when every called model is local. After the run: if any pipeline errors occurred it prints a prominent warning with their count (excluded from scores); if *every* case is a pipeline error (nothing scored) it exits 1; otherwise the top-level `quality_threshold` gate decides (absent → exit 0) on `analysis.summarize`'s fail-safe `gate_score` (passed / total cases: unscored cases count as failures). `load_config` expands a `test_cases: {file: …}` spec via `dataset.expand` and exits with a clear message on missing/invalid YAML or test-case files (including the `ValueError` PyYAML raises on a >4300-digit int and `RecursionError` on deep nesting). Write failures in `run`/`report`/`history`/`cache` exit with a one-line message. `report`/`compare` exit with `compare.RecordError`'s one-line reason on a bad results file; `history` prints `⚠ Skipping <reason>` and continues, and recomputes insights (best score, run-total errors) from `results`. `models --min-context` uses `_parse_context` as its argparse type (bad value → usage error, exit 2). `init` asks three questions (name, mode, comma-separated models; `--yes` skips them), re-asks on invalid answers via `_ask`, warns on a model absent from the catalog, continues without suggestions if the catalog fetch fails, and writes `starter.render`'s text after running `validate` on it (errors → exit 1, nothing written). `--csv` also writes `starter.cases_csv` as `<path stem>.csv` next to the YAML and renders the starter with `test_cases: {file: <that name>}`; every target goes through `_check_writable` (directory → exit, existing → `--yes` exits / interactive confirm) before anything is written, a `.csv` YAML path (any case) and a path with no file name are refused, and `_starter_config` validates the YAML + CSV pair as they will load (the CSV expanded from a scratch copy). `main()` reconfigures stdout/stderr with `errors="replace"`. Every console comes from `reporter.make_console()` (`markup=False, emoji=False`): user/model text is printed literally, so style whole lines with `style=`, never inline `[markup]`.
|
|
60
|
+
- **`runner.py`** — owns the single `httpx.Client` and the `model × prompt × test_case` (× sample) loop. With `repeats` > 1 each case runs once per sample index (passed to `openrouter_request(sample=…)` and recorded as the case's `sample`; without repeats no `sample` key is written). Each case records the candidate call's `latency_s`; each combo gets `score_ci`, `latency_p50_s` / `latency_p95_s` / `latency_mean_s`, `repeats` and `flaky` from `analysis`. `python` cases load the scorer relative to `config["_base_dir"]` (set by `main.load_config`); a `ScorerError` makes the case a `scorer_error` pipeline error. Renders Jinja2 templates (`template` and `system`) in a `jinja2.sandbox.SandboxedEnvironment` — unsafe attribute access is blocked: a lone unsafe attribute (`{{ x.__class__ }}`) renders empty, calls/chained access through one raise `SecurityError`. Dispatches work to `ThreadPoolExecutor` (default 5 workers, config key `concurrency`, 1–100; Ctrl-C sets `openrouter.CANCELLED`, cancels queued futures without waiting, and `main()` exits 130 via `os._exit`), routes each response to the right evaluator, accumulates per-prompt token/cost totals; `use_cache` is passed to both the candidate call and `evaluate_llm_judge`. A failed call never aborts the run. A candidate API failure (`openrouter_request` raising `RuntimeError`/`httpx.HTTPError` after its retries) is caught: the case is recorded with `match_score=None`, `match_result=False`, `status="api_error"`, `response=""`, an `error` message and 0 tokens/cost, its progress line shows the error, and it counts in the `Errors` column (excluded from the score) like a judge failure. `_run_case` wraps `_evaluate_case`: any other exception becomes an `internal_error` case, so no single case can crash a run. A non-ASCII API key is a `RuntimeError` from `openrouter._auth_headers`. Each finished case prints one `_progress_line` to stderr from a future done-callback (`[i/N] model / prompt / case pass|fail (score)` or `⚠ <ERROR_LABELS label>: <error>` — the only per-case warning; suppressed once `CANCELLED` is set), after a `Running N cases (…), C at a time` line; the per-combo totals are only in the reporter's table. Per-case detail prints (stdout) are gated behind `verbose`. Diagnostics (progress, retry notices, cache warnings, the judge self-preference warning, `run`'s closing pipeline-error warning) go to stderr; results (table, saved paths, PASS/FAIL) to stdout.
|
|
61
|
+
- **`validator.py`** — static validation of benchmark YAML configs; no API calls, and no side effects beyond importing a `python` case's scorer file (to check the function exists). `repeats` must be an int 1–`MAX_REPEATS` (100). Returns `(errors, warnings)`. Called by `cmd_run`, `cmd_validate` and `cmd_init` (before writing). `KNOWN_KEYS` lists every key the code reads per section: an unknown top-level (or `gate`) key is an error, an unknown nested one a warning, both with a `difflib` suggestion; keys starting with `_`/`x-` are free. A `gate` must name a model/prompt of the config. Adding a config key means adding it to `KNOWN_KEYS`. Checks required fields, eval-mode-specific constraints, Jinja2 template variable coverage, and heuristic warnings (single-brace syntax, low max_tokens for llm_judge, long expected_output). Type/shape mistakes are errors with actionable messages, not later crashes: empty or non-mapping file, non-string `name`, top-level `quality_threshold` not a number in 0–100, `concurrency` not an int in 1–100, a self-referencing YAML alias (the config must `json.dumps`), `inference`/`evaluation` present but not a mapping (a null value is treated as absent everywhere in the code), non-numeric `inference.temperature`, `inference.max_tokens` not a positive int (`50.5`, `100.0`, `true` rejected; "must be a positive whole number like 100"), any number that fails `openrouter.is_number` (non-bool int/float that converts to a finite float — so `.inf`/`.nan` and a 400-digit int are rejected in every numeric field, `concurrency` included), `evaluation.judge_model` not a string whenever present, duplicate `models` entries, non-string model/prompt/test-case ids, Jinja syntax errors in `template`/`system`, `exact_match` `expected_output` not a string (YAML `yes`/`true`/`3` — quote it), and `weighted_match` `evaluation.variables` missing any of `use_case`/`percent`/`order` or `expected_output` empty / not a list / an item whose `use_case` is unhashable. Once the rest is valid, it trial-renders every prompt (`template` + `system`) against every test case with the runner's own `render_template` and sandbox; any exception is an error naming the prompt id and test case id, so a deterministic template that would fail at run time fails `validate` first.
|
|
62
|
+
- **`providers.py`** — lookup of where a model id runs (reads env vars, never the network): `split` (`ollama:llama3.2:3b` → `("ollama", "llama3.2:3b")`; an id with a `/` before its first colon is OpenRouter's), `resolve(model, config["providers"])` → `Endpoint` (raw `base_url` — `url()` expands `${VAR}` via `expand` and checks it with `url_problem` (no unencoded `/?#` before an `@`, scheme, host, port, no fragment, `httpx.URL(...).host`; reasons never quote the URL), raising `ProviderError`; `join(path)` adds a path before any `?query`; `label()` is `safe_url(url())` with each non-URL `${VAR}` value put back as `${NAME}` (a token in the path) — `scheme://host:port/path`, `***@` for a user:password, `?…` for a query — or `display_url` (masks up to the last `@`) of the raw text, so no message or record shows a secret read through `${VAR}` (`shown_url` masks a URL as written, for `validate`); every `httpx.Client` comes from `openrouter.make_client`, whose `ClientSetupError` (a proxy URL httpx can't parse) never quotes it and `main()` turns into a one-line exit; a null setting counts as absent (`_entries`) — the name sent to the server, `api_key_env` / `api_key_header` (default `Authorization`) / `api_key_prefix` (default `Bearer` only in `Authorization`; `""` = bare key), `headers` (`request_headers()` expands them and adds the key; non-ASCII or `has_control` → `ProviderError` naming the setting, never the value), `ca_bundle` (`ca_path()`: `system`, or a path relative to `_base_dir`, which `main.load_config` writes into each provider entry that has a `ca_bundle`), `concurrency` (default 1 for a `BUILTIN` server, `None` = the run's for a provider you add), `timeout` default 600 s, `check_models` (the user's setting), `any_model` (llama.cpp: serves whatever it loaded), start/pull hints, `missing()` = unset variables), `is_loopback`, `BUILTIN` (`ollama`, `lmstudio`, `llamacpp`, `vllm` at their localhost defaults; the `providers:` block overrides or adds), `KEYS` (a provider entry's keys, in `validator.KNOWN_KEYS["providers.*"]`), `called_models` (candidates + the judge when an `llm_judge` case uses it). `ProviderError` for an unknown prefix.
|
|
63
|
+
- **`openrouter.py`** — the *single API choke point*, for OpenRouter and local servers alike: `openrouter_request(..., providers_config=)` resolves the endpoint, sends the bare model name to `{url()}/chat/completions` (no OpenRouter headers; the provider's `request_headers()`), through `client_for(client, endpoint)` (a provider with `ca_bundle` gets its own `httpx.Client(verify=ssl_context)`, one per bundle, built by `_tls_client` — tests monkeypatch it — and closed by `close_clients()` at the end of `runner.run`; `system` uses the optional `truststore` package), adds `params` (`runner.request_params(inference)`: `top_p`, `seed`, `response_format` — `json_object` shorthand — and `extra_body`; never overriding model/messages/temperature/max_tokens; candidate calls only) to the body, uses the provider `timeout`, holds a per-server `BoundedSemaphore` (`_slot`, sized by the provider's `concurrency`) around each attempt *before* the latency timer starts, names the server in every error (`_label`: `ollama (http://localhost:11434/v1) …`, with `connect_hint` on a transport error and `auth_hint` on a 401/403; no `RATE_LIMIT_HINT`), and lets a local reply omit usage fields (0; so cost 0). The cache key carries the full id plus a local server's expanded `base_url` (and `params` when set), so OpenRouter keys are unchanged and two servers' same-named models — or one provider name on two gateways — never collide. `fetch_local_models` is the local `GET /models` (`None` when unusable; `Rejected` on 401/403/407). Each result carries `latency_s`: the wall time (`time.perf_counter`) of the attempt that succeeded, request → parsed JSON, without earlier attempts or backoff; it is stored in the cache entry, so a hit reports the original latency (`None` for an older entry or a bad stored value, via `_latency`). `sample` > 0 adds `"sample"` to the cache-key payload only (never sent), so repeats get their own entries while sample 0 keeps old keys. Every completion call (candidate responses AND the LLM judge) goes through `openrouter_request`; the only other request is the public `GET /models` catalog in `fetch_models` (cached 24h with a `format` version — a cache from an older release is refetched — no key needed — `_auth_headers` omits `Authorization` when no key is set). It lives in its own leaf module specifically to avoid a `runner ↔ evaluator` import cycle. Responsibilities: build the request, consult the SHA256 cache, **retry transient failures** (`RETRYABLE_CODES = {408,429,502,503,504}` from the HTTP status line or the JSON error body, + local `httpx.TransportError` (timeouts included), `MAX_RETRIES` attempts, exponential backoff 1/2/4 s; a 429 waits `_backoff`'s 5/10/20 s + jitter, or `Retry-After` capped at `MAX_BACKOFF`, and its final error carries `RATE_LIMIT_HINT`). Every other failure — any other `httpx.HTTPError` (no retry), HTTP error status, non-JSON body, missing/empty `choices` or `message`, null or empty content (`_empty_hint`: "Increase max_tokens." only for `finish_reason` `length` or none; otherwise retry / another model), missing or non-finite usage — raises `RuntimeError` with a clear message (HTTP status included when known), which both callers catch. `_result_problem` applies the same checks to fresh and cached results (a bad cache entry is a miss and is refetched); cache writes go through `_cache_set`, which warns once and continues. `clean_text` replaces lone surrogates in the outgoing model/prompt/system text (before the cache key) and in incoming/cached content and error messages. `is_number` is the single numeric check. `_price` maps a negative, non-numeric or non-finite catalog price to `None` (unknown), also on re-reading the models cache. Each catalog entry also carries `max_output` (`top_provider.max_completion_tokens`, a positive int or `None`), which `estimate` caps budgets at and reports in `over_output_limit`, and `text` (`_is_text`: text in, text-only out; `None` when the catalog gives no modalities), which `init` uses to suggest free text models only.
|
|
64
|
+
- **`evaluator.py`** — the scorers: the pass/fail text checks in `TEXT_CHECKS` (`exact_match`, `contains`, `not_contains`, `regex` — each `(response, expected_output) -> bool`, scored 1.0/0.0; `contains`/`not_contains` compare `plain_text` of both sides (NFKC, Unicode dashes → `-`, format chars dropped, whitespace collapsed, casefold — models emit `30\u202fdays` / `STAFF\u00ad50`; the validator rejects a text whose `plain_text` is empty), while `regex` searches the raw reply, only stripped, so patterns can ban `—` or count characters; the runner dispatches through the dict and `validator.KNOWN_EVAL_TYPES` is built from it plus the other modes, so a new text check is one function plus one entry), `json_match` (share of `expected_output`'s leaves the reply's JSON reproduces — objects key by key with extra keys ignored, arrays same length and in order, strings case/space-insensitive, numbers by value, bools never equal numbers; passes at 1.0), `json_schema` (`(valid, reason)` via `jsonschema`'s `validator_for`; `schema_problem` is the validator's check), the Python scorers (`load_scorer("file.py:fn", base_dir)` imports each file once per process under a lock, `python_score(fn, response, case)` accepts a bool or `{passed, score?, reason?}` — anything else or an exception raises `ScorerError`), `weighted_match`, `evaluate_llm_judge`, plus `_extract_json` (strips markdown code fences before parsing). Pure scoring; `evaluate_llm_judge` makes an API call but receives the `httpx.Client` as a parameter (never creates one) so it stays free of any runner dependency. Judge failures (API error, malformed JSON) return a result with `score=None` and a `status` flag — a pipeline failure is distinguished from a real score of 0. `weighted_match` returns `0.0` on unparseable candidate output (a task failure, not a pipeline error); `_extract_json` turns any `ValueError`/`RecursionError` from `json.loads` (deep nesting, a 5000-digit int) into `JSONDecodeError`. `evaluate_llm_judge` takes `use_cache`, so `--no-cache` covers judge calls too. **`exact_match` is a plain case-insensitive string comparison** (`response.strip().lower() == expected.strip().lower()`) — no JSON parsing. `_extract_json` is called by `json_match`, `json_schema`, `weighted_match` and `evaluate_llm_judge`.
|
|
65
|
+
- **`analysis.py`** — pure insights and statistics over a finished run's `results` (no I/O). Statistics: `wilson` (95 % score interval), `score_interval(combo)` (over the number of distinct scored test cases — repeats don't narrow it — computed from `test_cases`, so v1 records work), `within_noise(a, b)` (Newcombe's hybrid-score interval for the difference contains 0), `latency_stats` / `latency_p50` (linear-interpolated percentiles over non-null `latency_s`), `flaky_cases` (ids whose scored repeats disagree), `case_key` / `case_label` (`(id, sample)` / `conv_001 #2`). `summarize` adds `best_interval`, `within_noise` (combos tied with the best, by score), `fastest` (lowest p50) and `flaky` (run total). Insights: `best_quality` (highest score, ties → lower cost), `best_value` (score per dollar, cost floored at `1e-4` so free models fall back to the top score), and `tag_breakdown` (per-tag pass-rate over scored cases only — `match_score is None` counts as an error, not a fail — sorted warnings-first then by tag, warn below 70 %). `summarize` is the single entry point and also computes the CI `passed` verdict against the top-level `quality_threshold`, over the combos the optional `gate` names (else the best combo); its `errors` is the run total over all combos, and `passed` is `False` whenever nothing at all was scored (matching `run`'s exit 1). The reporter only formats it.
|
|
66
|
+
- **`estimate.py`** — offline cost estimation for `--dry-run`. Pure logic: given a config and pricing catalog from `openrouter.fetch_models`, estimates total cost without making any completion calls. Returns per-combo rows plus the `over_budget` verdict against `max_cost_usd`. A model absent from the catalog or priced `None` there (see `openrouter._price`) goes in `missing_pricing`: excluded and warned. Candidate and judge budgets are capped at the model's catalog `max_output`; each excess goes in `over_output_limit`, which `render_estimate` warns about. A model absent from a non-empty catalog goes in `unknown_models` (with a `difflib` suggestion) and makes `--dry-run` exit 1.
|
|
67
|
+
- **`cache.py`** — SHA256 file cache under `.evalblink_cache/<key>.json`. The cache key is the full request payload (model, messages, temperature, max_tokens). `temperature: 0` + cache = reproducible runs. `--no-cache` bypasses it for candidate and judge calls. `get` treats an unreadable/corrupt entry (`OSError`, `ValueError`, `RecursionError`) as a miss. `cache stats`/`cache clear` count cached responses apart from the model catalog (`CATALOG_FILE`, `models.json`), which `clear` keeps unless `--all`; `cache clear` without `--yes` only prints the count.
|
|
68
|
+
- **`reporter.py`** — all output (terminal Rich table, JSON, Markdown to `results/`). Formats only; makes no decisions. The JSON is serialized before the file is opened (no truncated file), and a same-second rerun gets a `-2` suffix instead of overwriting. `write` is the single entry point for a run; `render_comparison` formats the `compare` delta table; `render_estimate` formats the `--dry-run` output; `make_console()` is the one console factory. `write_from_record` recomputes insights from `results` and uses only the basename of `run_id`. Markdown is written with `errors="replace"`. Filenames are slugified (capped at 60 chars, `benchmark` when empty). In the Markdown per-case table a pipeline-error case shows its status (`API error` / `judge API error` / `judge error` / `scorer error` / `internal error`) instead of a score. The terminal table is compact for 80 columns (`Score (95% CI)`, `Tokens in/out`, `p50 latency`); the Markdown summary splits them (`95% CI`, prompt/completion tokens, p50 and p95 latency) and its per-case table has a Latency column. Intervals and latency are read from the combo or recomputed from its cases (`_fmt_ci`, `_latency`), so old records render. JSON records carry a `schema_version` (from `schemas.SCHEMA_VERSION`).
|
|
69
|
+
- **`compare.py`** — pure run-to-run diff (no I/O beyond `load_record`). `diff` keys combos by `(model, prompt_id)`, emits per-combo quality/cost/p50-latency deltas (`latency_delta` is `None` when either side has no latency) plus each side's pipeline-error count, and `noise` (the quality Δ is non-zero but `analysis.within_noise`) — rendered as `within noise`, counted in the verdict ("None of these gains is beyond noise"); `--fail-on-regression` is unchanged (points-based); a shared combo whose error count differs is left out of the verdict's improved/shared counts (named as left out) and yellow in `render_comparison`, since its score covers different cases, and tolerates schema-version mismatch rather than hard-blocking. `load_record` raises `RecordError` (one-line reason) for a missing/unreadable/non-JSON/too-deep/wrongly-shaped file — it shape-checks every field report, compare and history read (each case needs `match_score`, and a bool `match_result` when scored). `detailed_diff` (the `compare --detailed` mode) drills into per-test-case transitions — `case_diff` keys cases by `analysis.case_key` (id + repeat index; a row's `id` is the `case_label`) and classifies each case as regressed/improved/new_error/recovered/etc. (reusing the `match_score is None` = pipeline-error rule, never a real fail) and aggregates a global summary (change counts, worst-regressed cases across combos, per-tag net).
|
|
70
|
+
- **`starter.py`** — the commented starter benchmark `init` writes (`render(name, models, mode)`), plus `DEFAULT_MODEL`, `JUDGE_MODEL` and `PAID_MODEL`, the small paid model `init` suggests but never preselects (all three covered by the weekly live models check). `cases_csv(mode)` turns the inline starter cases into the CSV (one source for both the inline comment's CSV block and `init --csv`'s file). Text templates, not `yaml.safe_dump`, so the comments survive; `name`/`models` are dumped with `yaml.safe_dump` so any value round-trips.
|
|
71
|
+
- **`dataset.py`** — `expand(config, base_dir)` turns `test_cases: {file, evaluation?}` into the plain list (CSV/TSV via `csv`, JSONL via `json`; `FIELDS` keep their meaning, other columns become variables, `tags` split on `;`, a `JSON_EXPECTED` mode's (`weighted_match`, `json_match`, `json_schema`) `expected_output` is JSON in CSV, `scorer` is a field, missing ids become `line_<n>`). `main.load_config` calls it relative to the YAML's directory, before validation (and sets `config["_base_dir"]`, the YAML's absolute directory, for `python` scorers), so nothing downstream sees the file form; `DatasetError` messages name the file and line, and near-miss column names come back as warnings (printed to stderr).
|
|
72
|
+
- **`schemas.py`** — `TypedDict`s documenting the config and result dict shapes (typing only — the pipeline passes plain dicts straight from the YAML; runtime validation is `validator.py`'s job), plus the shared runtime constants `SCHEMA_VERSION` (2: adds per-case `latency_s` / `sample` and per-combo `score_ci`, latency percentiles, `repeats`, `flaky`; all additive), `ERROR_LABELS` (incl. `scorer_error`), `DEFAULT_TEMPERATURE`, `DEFAULT_MAX_TOKENS`, `DEFAULT_JUDGE_MAX_TOKENS` imported by runner, validator, reporter, evaluator and estimate.
|
|
73
|
+
|
|
74
|
+
`docs/assets/` holds the README's visuals: `banner.svg` plus `run-output.svg`, `dry-run.svg` and `compare.svg`, drawn by `make_visuals.py` (needs fonttools and the Geist fonts; text becomes outlines because an SVG in `<img>` can't load fonts). The README links them by absolute `raw.githubusercontent.com` URL so they also show on PyPI, with the same sample as text below each. When a sample's output changes, update the text and the script's figures together.
|
|
75
|
+
|
|
76
|
+
## Benchmark config schema (as actually consumed)
|
|
77
|
+
|
|
78
|
+
Configs live in `benchmarks/*.yaml`. The structure the code reads:
|
|
79
|
+
|
|
80
|
+
- **Templates use Jinja2** — `{{ variable }}`, NOT `{variable}`. Single braces render literally and silently produce wrong prompts (a real bug class). `evalblink validate` warns on this pattern. Variables come from the global `variables:` block merged with each `test_case.variables`.
|
|
81
|
+
- **`inference:`** `temperature`, `max_tokens` (a positive int; `100.0` is an error); optional `top_p` (0–1), `seed` (int), `response_format` (`json_object` / `text` / `{type: json_schema, json_schema: {name, schema}}`), `extra_body` (mapping; reserved keys rejected) — candidate calls only, in the cache key. Reasoning models (e.g. `nvidia/nemotron-3.5-lightning`) consume the budget on reasoning tokens and return null content if `max_tokens` is too low — give headroom.
|
|
82
|
+
- **`evaluation:` block is per-mode:**
|
|
83
|
+
- `contains` / `not_contains` / `regex` (like `exact_match`) need only `expected_output`: case-insensitive substring(s) — a string or a non-empty list, all must / none may appear — or a Python `re.search` pattern (case-sensitive; `(?i)`), which `validate` compiles. They match text, not meaning.
|
|
84
|
+
- `exact_match` cases need no `evaluation:` block at all. The scorer is a plain case-insensitive string comparison — prompt the model to return the label text only, no JSON.
|
|
85
|
+
- `llm_judge` requires `evaluation.judge_model` (+ optional `judge_threshold`, default 0.70, and `judge_max_tokens`, default 4096 — the judge's own output budget; verbose reasoning judges such as nemotron-3.5-lightning need 2k–6k). Missing `judge_model` raises `ValueError`. A judge API failure (`judge_api_error`) or an unusable reply (`judge_error`) keeps its reason in the case's `error` and shows it on the case's progress line (`⚠ judge API error: …` / `⚠ judge error: …`), naming `evaluation.judge_max_tokens` where relevant. Judge scores 1–5 are normalized to 0–1 via `(score - 1) / 4`.
|
|
86
|
+
- `weighted_match` requires `evaluation.quality_threshold` (0–1 per-case pass threshold) and `evaluation.variables` (list of `{name, weight, tolerance?}`). The scorer has a **fixed output schema**: expected/actual outputs must be JSON arrays of `{use_case, percent, order}` dicts. The three dimension names (`use_case`, `percent`, `order`) are hardcoded in `evaluator.weighted_match` — `evaluation.variables` defines their weights and tolerances, not arbitrary field names.
|
|
87
|
+
- **Three threshold levels** — keep these distinct: `quality_threshold` at the top level (0–100 %) is the CI/CD gate compared against the best combo's pass rate with unscored (pipeline-error) cases counted as failures. `evaluation.quality_threshold` (0–1) is the per-case threshold for `weighted_match`. `evaluation.judge_threshold` (0–1) is the per-case threshold for `llm_judge`. All three coexist in the same config.
|
|
88
|
+
- **`concurrency`** — optional top-level int, 1–100 (default 5); controls `ThreadPoolExecutor` worker count. A built-in local server also caps its own requests (`providers.<name>.concurrency`, default 1; a provider you add has no cap of its own unless it sets one); the run's `concurrency` bounds them all (`validate` warns on a higher provider value), and `_local_limits(config, run_limit)` shows only the lower caps on the `Running N cases` line.
|
|
89
|
+
- **Local models** — `models` / `judge_model` entries `ollama:<m>`, `lmstudio:<m>`, `llamacpp:<m>`, `vllm:<m>`, or `<name>:<m>` for a provider declared under `providers:` (`base_url` required for a new one; `api_key_env`, `api_key_header`, `api_key_prefix`, `headers`, `ca_bundle`, `check_models`, `concurrency`, `timeout` optional; `${VAR}` in `base_url` / `headers` / `ca_bundle` reads the environment). `validate` rejects a `base_url` ending in `/chat/completions` / `/completions` / `/models`, reserved or duplicate-key headers, non-text header values, a missing `ca_bundle` file; it warns on bare `$VAR`, key settings without `api_key_env`, plain http with credentials to a non-loopback host. `validate` rejects an unknown prefix with a suggestion. Cost $0 unless the server reports a numeric `usage.cost` ≥ 0 (used as is; anything else counts 0), and $0 in `--dry-run`; example `benchmarks/local_models.yaml`.
|
|
90
|
+
- **`repeats`** — optional top-level int, 1–100 (default 1); runs each case N times (own cache entries), score over all repeats, flaky cases reported, interval still over the number of test cases; `--dry-run` multiplies by N.
|
|
91
|
+
- **`max_cost_usd`** — optional top-level float; `--dry-run` exits 1 if estimated cost exceeds it.
|
|
92
|
+
- **`test_cases[].evaluation`** selects the scorer: `"exact_match"` | `"contains"` | `"not_contains"` | `"regex"` | `"json_match"` | `"json_schema"` | `"python"` | `"weighted_match"` | `"llm_judge"`. A single config may mix modes. Every mode but `llm_judge` and `python` needs `expected_output` (`json_match`: a non-empty mapping/list; `json_schema`: a valid schema; JSON text in a CSV cell); `llm_judge` needs `criteria`; `python` needs `scorer: "file.py:fn"` relative to the YAML (`validate` imports it); `tags` drive per-category breakdown.
|
|
93
|
+
- **Latency is tracked per candidate call** (successful attempt only, cached with the reply). It depends on the network, OpenRouter and `concurrency`; compare within a run or between runs made the same way.
|
|
94
|
+
|
|
95
|
+
When fixing a config, keep changes in the YAML and don't alter scoring semantics in `evaluator.py`/`runner.py` unless a run reveals a genuine code defect.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# The sdist carries what the test suite needs to run from it.
|
|
2
2
|
include tests/conftest.py
|
|
3
3
|
include PRD.md CLAUDE.md CHANGELOG.md CONTRIBUTING.md
|
|
4
|
-
recursive-include benchmarks *.yaml *.csv *.tsv *.jsonl
|
|
4
|
+
recursive-include benchmarks *.yaml *.csv *.tsv *.jsonl *.py
|
|
5
|
+
include docs/*.md
|