Skip to main content

Use createEvaluator when your evaluation logic is plain TypeScript and you want a reusable evaluator object with consistent metadata and telemetry.

Example#

What You Get#

  • an evaluator name
  • evaluator kind such as CODE or LLM
  • optimization direction metadata
  • optional OpenTelemetry spans around execution

When To Use Code Evaluators#

Code evaluators are the right fit when the scoring logic should stay deterministic, cheap, and fully under your control:

  • regex or exact-match checks
  • JSON structure validation
  • latency and cost thresholds
  • post-processing checks on existing model output
  • asEvaluatorFn
  • toEvaluationResult