The arguments for creating the tool selection 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 ToolSelectionEvaluationRecord and returns a classification result indicating whether the tool selection is correct or incorrect.
const evaluator = createToolSelectionEvaluator({ model: openai("gpt-4o-mini") });
const result = await evaluator.evaluate({
input: "User: What is the weather in San Francisco?",
availableTools: `WeatherTool: Get the current weather for a location.
NewsTool: Stay connected to global events with our up-to-date news around the world.
MusicTool: Create playlists, search for music, and check the latest music trends.`,
toolSelection: "WeatherTool"
});
console.log(result.label); // "correct" or "incorrect"
Creates a tool selection evaluator function.
This function returns an evaluator that determines whether the correct tool was selected for a given context. Unlike the tool invocation evaluator which checks if the tool was called correctly with proper arguments, this evaluator focuses on whether the right tool was chosen in the first place.
The evaluator checks for: