Nirmos
SDK reference

Evaluator configuration reference

All twelve built-in evaluators: typed configs, required inputs, defaults, results and validation.

Use EvaluationEvaluatorVersion for a complete version, or EvaluationEvaluatorConfig<"exact_match"> for one config. Configs reject unknown options. Creating an evaluator or version does not execute it: attach its version ID to an evaluator column, configure config.inputMapping, then prepare and execute a run. Input schemas below use the registry's canonical names; required inputs must be bound. Optional inputs can be omitted. See binding guide.

Version-wide fields: required type, category, inputSchema, outputType, config; optional scope defaults to output, scoreDirection defaults to none. inputSchema entries require key and type; required defaults true. Types are any, string, number, boolean, json, object, array, messages. any/json accept JSON values including null; dataset columns still enforce their own declared types. Category is deterministic, semantic, llm or human. Scope labels do not add span/session execution to the output-based runner.

Every config allows optional description (up to 2,000 characters). Named model/route options need a nonempty identifier. Judges select either a model or a route; setting both is rejected by TypeScript and API validation. Defaults below distinguish omitted runtime options from dashboard/template presets. Existing versions retain their stored settings; no hidden defaults change text comparison semantics.

Type / purposeRequired configOptional config and defaultsCanonical inputsResult / common errors
exact_match: structural equalitycaseSensitive, trimWhitespace, normalizeWhitespace: explicit booleansCompatibility aliases trim, case_sensitive; optional fixed expected. Template preset: false, true, false.actual:any, expected:anyBoolean value/pass; arrays ordered, objects compare keys recursively. Wrong flag type rejected.
contains: substring presentSame explicit text flagsSame aliases and fixed expected; same template presetactual:string, expected:stringBoolean; nonstring inputs fail with INPUT_TYPE_MISMATCH.
not_contains: substring absentSame explicit text flagsSame aliases and fixed expected; same template presetactual:string, expected:stringInverts successful contains comparison, preserves evaluator errors.
regex: safe RE2 regular expressionpattern (1-1,000 characters)flags, default emptyactual:stringBoolean; invalid flags, lookaround and backreferences rejected; large inputs fail with REGEX_INPUT_TOO_LARGE.
json_schema: validate JSONschema: JSON Schema objectNone beyond descriptionactual:jsonBoolean; strings are JSON-parsed, invalid JSON produces false/invalid_json. Invalid schema rejected; schema/input limits apply.
numeric: finite scalar comparisonFor operator: "between", both min and maxoperator defaults eq; other operators neq, gt, gte, lt, lte, ==, =, !=, >, >=, <, <=. Scalar config expected, value, threshold optional. Template preset uses gte.actual:number, expected:numberValue is actual number; pass compares against expected. between is inclusive and requires min ≤ max. Nonfinite values rejected.
custom_expression: bounded declarative comparisonexpression: EvaluationExpressionNone beyond descriptionactual:any, expected:any; custom declared inputs allowedBoolean. Operators eq, neq, gt, gte, lt, lte, contains, starts_with, ends_with, exists, and, or, not. Max depth 8, nodes 100; unknown inputs/operators rejected. No JS execution.
cosine_similarity: compare embedded textsembeddingModel or compatibility alias modelthreshold defaults 0.8, range −1…1actual:string, reference:stringNumeric cosine, pass ≥ threshold. Physical embedding model only; routes rejected. Provider/dimension failures produce failed scores. Incurs embedding calls.
llm_judge: rubric-based judgingNonempty rubric; one of judgeModel, model, judgeRoute, routescoreMin:1, scoreMax:5, passThreshold:4, temperature:0, reasoningRequired:false; storeExplanation retained as display preferenceactual:any; optional input, context, referenceNumeric or boolean score/pass with reasoning. Threshold must lie inside increasing scale. Invalid judge JSON fails score. Incurs chat call.
reference_judge: judge against referenceSame judge configSame judge defaultsactual:any, reference:any; optional input, contextSame judge score/error behavior; reference required.
pairwise_judge: compare same-case targetsJudge rubric/model selection; tieBehavior: "allow" or "force_choice"; outputLabels: exactly three strings for A/B/tieJudge temperature/reasoning options; template tie preset allow, labels ["A","B","tie"]candidateA:any, candidateB:any; optional input, reference, contextWinner label/pass; fixed A/B randomization avoids position bias. Force-choice forbids tie. Baseline/candidate columns must exist.
human_review: assigned reviewNonempty question, responseType: "pass_fail", "rating", "choice" or "text"; choice requires ≥2 choicesinstructions, assignedReviewerIds, requireComment:false, requireCommentOnFailure:false; rating defaults ratingMin:1, ratingMax:5; optional passThreshold, ratingLabelsactual:any; optional reference, input, contextPending score/assignment until authorized review. Completed generation does not mean review completed. Template preset requires comment on failure.

Numeric config comparison values are fallbacks, in order: bound expected/reference/value, config expected, then numeric value/threshold. If using a fixed threshold or range instead of a row value, declare expected optional in inputSchema and omit its binding. Number inputs accept only finite numbers at the binding layer; do not rely on numeric-string coercion from direct evaluator internals.

Human review choices can be strings or { value?, label?, passed? } objects. ratingLabels accepts an array or number-keyed string map. Supported stored aliases min/max, scaleLabels, labels, rubric remain representable; canonical question and responseType are still required on public writes. assignedReviewerIds are user/member identifiers and do not grant permissions. Runtime checks assignments separately.

Minimal SDK creation examples for every type

This function creates one version of each supported evaluator. It makes no inference calls. Supply configured Gateway model names/routes for the semantic/judge configs. For an executable suite, bind the canonical input keys from the table. Default input type any is used only where multiple JSON shapes are supported; text/number bindings remain strict.

import { Nirmos, type EvaluationEvaluatorVersion } from '@nirmos/sdk';

export async function createEvaluatorExamples(client: Nirmos, models: { embedding: string; judge: string }) {
  const text = { caseSensitive: false, trimWhitespace: true, normalizeWhitespace: false };
  const pair = [{ key: 'actual', type: 'any' as const }, { key: 'expected', type: 'any' as const }];
  const strings = pair.map(input => ({ ...input, type: 'string' as const }));
  const versions: EvaluationEvaluatorVersion[] = [
    { type: 'exact_match', category: 'deterministic', outputType: 'boolean', inputSchema: pair, config: text },
    { type: 'contains', category: 'deterministic', outputType: 'boolean', inputSchema: strings, config: text },
    { type: 'not_contains', category: 'deterministic', outputType: 'boolean', inputSchema: strings, config: text },
    { type: 'regex', category: 'deterministic', outputType: 'boolean', inputSchema: [{ key: 'actual', type: 'string' }], config: { pattern: '^Paris$', flags: 'i' } },
    { type: 'json_schema', category: 'deterministic', outputType: 'boolean', inputSchema: [{ key: 'actual', type: 'json' }], config: { schema: { type: 'object', required: ['answer'], properties: { answer: { type: 'string' } } } } },
    { type: 'numeric', category: 'deterministic', outputType: 'number', inputSchema: [{ key: 'actual', type: 'number' }, { key: 'expected', type: 'number' }], config: { operator: 'gte' } },
    { type: 'custom_expression', category: 'deterministic', outputType: 'boolean', inputSchema: pair, config: { expression: { operator: 'eq', left: { input: 'actual' }, right: { input: 'expected' } } } },
    { type: 'cosine_similarity', category: 'semantic', outputType: 'number', inputSchema: [{ key: 'actual', type: 'string' }, { key: 'reference', type: 'string' }], config: { embeddingModel: models.embedding } },
    { type: 'llm_judge', category: 'llm', outputType: 'number', inputSchema: [{ key: 'actual', type: 'any' }], config: { rubric: 'Rate factual accuracy from 1 to 5.', judgeModel: models.judge } },
    { type: 'reference_judge', category: 'llm', outputType: 'number', inputSchema: [{ key: 'actual', type: 'any' }, { key: 'reference', type: 'any' }], config: { rubric: 'Rate agreement with reference from 1 to 5.', judgeModel: models.judge } },
    { type: 'pairwise_judge', category: 'llm', outputType: 'category', inputSchema: [{ key: 'candidateA', type: 'any' }, { key: 'candidateB', type: 'any' }], config: { rubric: 'Choose more accurate answer.', judgeModel: models.judge, tieBehavior: 'allow', outputLabels: ['A', 'B', 'tie'] } },
    { type: 'human_review', category: 'human', outputType: 'boolean', inputSchema: [{ key: 'actual', type: 'any' }], config: { question: 'Is this answer correct?', responseType: 'pass_fail' } },
  ];
  const created = [];
  for (const version of versions) {
    created.push(await client.evaluations.evaluators.create({ name: `SDK ${version.type}`, version }));
  }
  return created;
}

Judge/semantic model presence is checked on save; executable catalog access, credentials, quota and provider capabilities are checked during execution. Incomplete evaluators created from templates remain readable/editable, but cannot become executable versions without model selection. Reads preserve display output labels numeric, categorical and human_review; write outputType uses number, category and normal scalar labels. The SDK response types reflect this existing projection.

evaluators.update() edits resource metadata. To change scoring, call evaluators.versions.create(evaluatorId, version) and rebind the suite column. Archive examples with evaluators.archive(created.evaluator.id); archive preserves history. Do not archive resources while a run still uses them.

On this page