The value to convert to an EvaluationResult. Can be:
score, label, and/or explanation propertiesAn EvaluationResult object with extracted properties
Convert a number to an EvaluationResult:
const result = toEvaluationResult(0.95);
// Returns: { score: 0.95 }
Convert a string to an EvaluationResult:
const result = toEvaluationResult("correct");
// Returns: { label: "correct" }
Convert an object with all properties:
const result = toEvaluationResult({
score: 0.9,
label: "high",
explanation: "High quality output"
});
// Returns: { score: 0.9, label: "high", explanation: "High quality output" }
Converts an unknown value to an EvaluationResult.
This function provides a flexible way to normalize various return types from evaluator functions into a standardized
EvaluationResultformat. It handles multiple input types:{ score: number }{ label: string }score,label, andexplanationproperties if presentEvaluationResultobjectThis is particularly useful when creating evaluators from functions that may return different types, ensuring consistent evaluation result formatting.