The arguments for creating the sentiment evaluator.
Optionalchoices?: ClassificationChoicesMapOptionalinputMapping?: ObjectMapping<RecordType>The mapping of the input to evaluate to the shape that the evaluator expects
Optionalname?: stringOptionaloptimizationDirection?: OptimizationDirectionOptionalpromptTemplate?: PromptTemplateOptionaltelemetry?: TelemetryConfigAn evaluator function that takes a SentimentEvaluationRecord and returns a classification result indicating whether the latest user message expresses positive, neutral, or negative sentiment.
const evaluator = createSentimentEvaluator({ model: openai("gpt-4o-mini") });
const result = await evaluator.evaluate({
conversation: "User: My order still hasn't arrived.\nAssistant: Let me check.",
userMessage: "This is the third time I've had to ask.",
});
console.log(result.label); // "negative"
Creates a sentiment evaluator function.
This function returns an evaluator that labels the sentiment the user expresses in their latest message as positive, neutral, or negative. It judges the user's own expressed affect, not the assistant's tone and not whether the topic is inherently pleasant or unpleasant.