[Requirement](../../core/requirement#class-requirement) factories for tool-use validation.
Provides uses_tool, a [Requirement](../../core/requirement#class-requirement) factory that validates whether a model
response includes a call to a specified tool — useful when you need to enforce tool
invocation via rejection sampling rather than relying solely on the model’s
tool_choice setting. Also provides tool_arg_validator, which validates the
value of a specific argument to a named tool. Both accept either the tool’s string
name or its callable.
Functions
FUNC uses_tool
tool_name: The tool that must be called; this can be either the name of the tool or the Callable for the tool.check_only: Propagates to the Requirement.
tool_choice if the OpenAI tool_choice model option is supported by your model and inference engine.
Returns:
- A
[Requirement](../../core/requirement#class-requirement)that validates whether the specified tool was called.
FUNC tool_arg_validator
validation_fn returns a True value for the value of the arg_name argument to tool_name.
If tool_name is not specified, then this requirement is enforced for every tool that
Args:
description: The Requirement description.tool_name: The (optional) tool name for .arg_name: The argument to check.validation_fn: A validation function for validating the value of thearg_nameargument.check_only: propagates thecheck_onlyflag to the requirement.
- A
[Requirement](../../core/requirement#class-requirement)that validates the specified tool argument.