CreateEvaluatorOptions: {
    kind?: EvaluationKind;
    name?: string;
    optimizationDirection?: OptimizationDirection;
    telemetry?: TelemetryConfig;
}

Options for creating a custom evaluator using createEvaluator.

Type declaration

  • Optionalkind?: EvaluationKind

    The kind of the evaluation.

    • "CODE": Code-based evaluator that runs custom logic
    • "LLM": LLM-based evaluator that uses a language model

    "CODE"

    const evaluator = createEvaluator(myFunction, { kind: "CODE" });
    
  • Optionalname?: string

    The name of the evaluator / metric that it measures.

    If not provided, the function will attempt to infer the name from the function's name property. If the function has no name, a unique name will be generated.

    const evaluator = createEvaluator(myFunction, { name: "custom-metric" });
    
  • OptionaloptimizationDirection?: OptimizationDirection

    The direction to optimize the numeric evaluation score.

    • "MAXIMIZE": Higher scores are better (e.g., accuracy, F1 score)
    • "MINIMIZE": Lower scores are better (e.g., error rate, latency)

    "MAXIMIZE"

    const evaluator = createEvaluator(myFunction, {
    optimizationDirection: "MAXIMIZE"
    });
  • Optionaltelemetry?: TelemetryConfig

    The telemetry configuration for the evaluator.

    When enabled, the evaluator will automatically create OpenTelemetry spans for tracing and observability. This allows you to track evaluator performance and debug issues in distributed systems.

    { isEnabled: true }

    const evaluator = createEvaluator(myFunction, {
    telemetry: { isEnabled: true, tracer: myTracer }
    });