Evaluation configuration contracts
Configure target inputs, evaluator bindings, exact-match scoring and dataset segments.
Start with the complete two-case workflow. Public SDK configuration types are generated from the same schemas used by API validation and dashboard builders. Unknown evaluator options are rejected.
The SDK exports EvaluationEvaluatorVersion, EvaluationTargetConfig,
EvaluationColumnCreate, EvaluationInputBinding and EvaluationSegmentCriteria.
Evaluator versions discriminate their config by type; IntelliSense shows the
required text-normalization flags and named judge/model options. Input bindings
use source to distinguish dataset, target, literal and reference values.
Custom expressions use a typed declarative tree (EvaluationExpression). EvaluationEvaluatorConfig<T> selects the config for a specific evaluator type. A schema update is required to add a supported config option; arbitrary JSON remains only where the domain needs it, such as JSON Schema and literal values.
Target inputs
Create targets through evaluations.columns.create with category: "target" and the discriminated target object:
target.type | Required configuration |
|---|---|
model | name, modelId, providerId, inputMapping |
route | name, routeId, inputMapping; optional environmentId |
prompt, executionType: "model" | name, promptId, string promptVersionId, modelId, inputMapping |
prompt, executionType: "route" | name, promptId, string promptVersionId, routeId, inputMapping |
endpoint | Present in types; runtime execution is disabled. Do not use for runnable evaluations. |
Mappings use destination keys on the left and dataset source strings on the right. For model/route chat, { user_message: "dataset.question" } produces one user message. Alternatively map messages from a messages dataset column. For prompt targets, use actual template variable names, such as { customerName: "dataset.customer_name" }. Dataset sources refer to declared column keys; dataset. does not refer to case metadata/tags. Start with a declared column key. JSON/messages columns support safe dotted child keys and numeric array indices, such as dataset.input.messages; actual child values and types are checked during execution.
An empty target mapping forwards all case data and uses fallback input selection; explicit mappings avoid accidentally sending expected answers or metadata to the model.
Exact-match evaluator
Evaluator creation requires a version with type, category, inputSchema, config and outputType. Supply canonical keys actual and expected, both required with type any. All three booleans are required by management validation: caseSensitive, trimWhitespace, normalizeWhitespace. The runtime's fallback defaults do not remove these creation requirements.
import type { Requests } from "@nirmos/sdk";
const input: Requests["createEvaluationevaluators"] = {
name: "Exact answer",
version: {
type: "exact_match", category: "deterministic", scope: "output",
inputSchema: [
{ key: "actual", type: "any", required: true },
{ key: "expected", type: "any", required: true },
],
config: { caseSensitive: true, trimWhitespace: true, normalizeWhitespace: false },
outputType: "boolean", scoreDirection: "none",
},
};
const created = await nirmos.evaluations.evaluators.create(input);
console.log(created.evaluator.id, created.version?.id);Strings are trimmed when requested, optionally collapse whitespace, then optionally ignore case. Arrays compare in order; objects compare keys and values structurally. This evaluator needs no provider call. passed: false is a completed comparison, not an evaluator error. Template summaries are available through evaluations.selectors(); inspect a configured evaluator with evaluations.evaluators.get(id) to read its version schema/config rather than assuming any generic JSON is valid.
Evaluator column bindings
Creating an evaluator version does not attach it to a suite or bind its inputs. Create an enabled category: "evaluator" column with evaluatorVersionId and config.inputMapping. Mapping keys must match the evaluator's inputSchema keys; required inputs must all be mapped.
import type { EvaluationInputBinding } from "@nirmos/sdk";
const inputMapping: Record<string, EvaluationInputBinding> = {
actual: { source: "target", path: "output" },
expected: { source: "dataset", key: "expected" },
};
await nirmos.evaluations.columns.create({
suiteId: "suite-id", key: "exact_answer", name: "Exact answer",
category: "evaluator", enabled: true, evaluatorVersionId: "evaluator-version-id",
config: { inputMapping },
});| Binding | Value read |
|---|---|
{ source: "target", path: "output" } | Current target's entire output |
{ source: "target", path: "output.answer" } | answer in an object output; no automatic JSON parsing of text |
{ source: "dataset", key: "expected" } | Declared field in case data; safe dotted children/array indices allowed |
{ source: "literal", value: "Paris" } | Fixed JSON value |
{ source: "reference", reference: "target:baseline.output" } | Output of configured target column with key baseline |
{ source: "reference", reference: "transform.normalized" } | Result of configured transform column normalized |
Dataset bindings are checked against the pinned dataset's declared fields and input types. Paths reject prototype traversal; unresolved required paths become mapping errors. Cross-target/transform references require those columns to exist and execute; the SDK does not orchestrate external targets or transforms for you. Prefer canonical object bindings. Legacy strings "target.output" and "dataset.expected" normalize to the corresponding objects; target inputMapping is a different, string-only contract.
Other evaluators have distinct requirements: contains/not_contains use string actual/expected plus the same three booleans; regex needs string actual and a valid safe pattern (optional flags); json_schema needs JSON actual and config.schema; numeric needs number actual/expected and a supported operator (eq, neq, gt, gte, lt, lte). Cosine similarity requires a physical embedding model; embedding routes are rejected because Gateway embeddings cannot execute routes. Chat judges require a model or route and can incur provider calls. Human review creates pending assignments, not automatic scores. Inspect the chosen template/version before wiring those evaluators.
Segments use dataset columns
Segment fields are bare declared dataset column keys, such as topic, not dataset.topic, data.topic or metadata.topic. Keys start with a lowercase letter and contain lowercase letters, digits and underscores. A dataset column with role metadata still lives in case data; case-level metadata is separate and cannot be addressed through the current segment API.
type Value = string | number | boolean | null | Value[] | { [key: string]: Value };
type Rule = { field: string; operator: "equals" | "not_equals" | "contains" | "in" | "exists"; value?: Value };
type Criteria = Rule | { operator: "AND" | "OR"; rules: Rule[] };
const criteria: Criteria = {
operator: "AND",
rules: [{ field: "topic", operator: "equals", value: "cities" }],
};
const segment = await nirmos.evaluations.segments.create({
suiteId: "suite-id", name: "Cities", critical: false, criteria,
});
console.log(segment.id);Create the topic column and populate data.topic before creating this segment. Groups contain 1-20 simple rules; nested groups are not supported by management validation. equals/not_equals compare JSON values; contains checks a string substring or array member; in expects an array of alternatives; exists checks non-null presence (value: false reverses it).
Case tags are not automatically dataset fields. Although execution code has tag/metadata matching branches, the public create/update schemas and field validation prevent using them as a general supported contract. A field named tags must be a declared dataset column; its value takes precedence over case tags. Prefer an ordinary field such as topic to make intent obvious. General case-tag/metadata filtering is not exposed by the current management contract.
Invalid bindings and errors
{ source: "dataset", path: "expected" } is invalid: dataset references require key. { source: "target", key: "output" } requires path instead. source: "response" is unsupported. The SDK rejects these object literals at compile time; API validation includes a path such as config.inputMapping.actual. Unknown evaluator input names are rejected when attaching a column, and missing dataset columns identify the input and field. Required data that disappears at runtime produces a failed evaluator score with INPUT_PATH_NOT_FOUND; its message identifies the input and its dataset, target or reference source.
Target output paths use safe dotted names and numeric array positions; prototype keys are forbidden. A path such as output.answer cannot be checked against an unstructured model response until execution. Strings are not automatically parsed as JSON. Legacy string bindings remain accepted, including literal strings; use structured literal when a string resembles a reference. Target input maps remain string-only because they build target variables before inference; evaluator bindings resolve dataset values, generated outputs, literals and prior results after inference.
Identifiers and updates
Logical dataset/evaluator/target IDs identify resources for reads, archive and metadata updates. Dataset-version, evaluator-version and target-version IDs pin executable configurations. Runs require a frozen dataset version. evaluators.update() changes name/description/status only; create a new immutable config version with evaluators.versions.create(evaluatorId, version), then attach its returned version ID to suite columns. experiments.prepare() returns an experiment ID used by runs.create(); despite their names, run targetIds and evaluatorIds select version IDs. A score belongs to a trial and pinned evaluator version. All twelve evaluator configs include runnable creation examples and defaults.
Updating column metadata
evaluations.columns.update(columnId, { name: "Renamed" }) preserves omitted
configuration, input mappings, description and enabled state. Supplied config
replaces that configuration object and is validated against the effective column;
config: {} cannot clear required evaluator bindings. These PATCH fields do not
accept null. Use description: "" to clear a description, or enabled: false
to disable a column. Updating evaluator configuration itself requires a new
immutable evaluator version. Column keys and categories are immutable; create a
new column to change category. A category change cannot bypass mapping validation.
Evaluator get/list responses contain discriminated version configs. Narrow
version.type === "exact_match" before reading version.config.caseSensitive as
boolean. Generic historical-version/selector projections remain broader; do not
assume their JSON fields have the same shape without validation.