Evaluate state against an ordered rubric.
Use Score when the answer lies on a spectrum whose levels can be described,
such as severity, urgency, or customer frustration. criteria lists two or
more levels, numbered from zero in their supplied order. The returned score
is an expected value and may fall between integer levels; the full
probability distribution remains available for custom decision logic.
Score: z.infer<typeof scoreSchema>const response = await model.invoke({
state: "This has failed three times. Fix it now.",
questions: {
frustration: {
type: "score",
instructions: "How frustrated does the customer appear?",
criteria: [
"Calm and neutral.",
"Concerned but civil.",
"Very angry or using strong language.",
],
},
},
});
const frustration = response.scores.frustration;
frustration.score; // May be fractional, for example 1.35.
frustration.legend; // The original zero-based rubric.
frustration.probabilities; // Probability for each rubric level.