Skip to main content
This page summarizes the main public APIs exported from @m4trix/evals.

Dataset

Use Dataset.define(...) to select discovered test cases.
Fields:
  • name: stable id; letters, digits, _, and -.
  • displayName: optional human-facing label.
  • includedTags: string/RegExp matchers, or TagOrFilter / TagAndFilter expressions.
  • excludedTags: string/RegExp matchers.
  • includedPaths: string glob or RegExp matchers.
  • excludedPaths: string glob or RegExp matchers.

TestCase

Use TestCase.describe(...) for each case.
input and output can be values or functions returning values.

Evaluator

Use Evaluator.use(...) to provide middleware context, then call .define(...) and .evaluate(...).
Evaluator callback arguments:
  • input: resolved test-case input.
  • output: optional resolved expected output.
  • ctx: merged middleware context.
  • meta: run, dataset, test-case, repetition, experiment, and tag metadata.
  • log(...): attach a log entry to the artifact.
  • logDiff(...): attach an expected-vs-actual diff.
  • createError(...): create a structured evaluator error.

RunConfig

Use RunConfig.define(...) to create named runnable suites.
Each run row must set either:
  • evaluators: concrete evaluator exports from discovered modules.
  • evaluatorPattern: wildcard or regex-style evaluator name pattern resolved by the runner.
Optional row fields:
  • repetitions: positive integer, defaults to 1.
  • sampling: set exactly one of count or percent; optional seed.

Scores

Built-in scores:
  • percentScore: { value, stdDev?, count? }
  • deltaScore: { value, delta }
  • binaryScore: { passed, passedCount?, totalCount? }
Example:
Create custom scores with Score.of(...):

Metrics

Built-in metrics:
  • tokenCountMetric: { input?, output?, inputCached?, outputCached? }
  • latencyMetric: { ms }
Create custom metrics with Metric.of(...).

Runner API

Use createRunner(...) when you want to discover and run evals programmatically.
The runner can also expand a discovered RunConfig and execute all jobs with shared concurrency.