- Dynamic Function Wrapping: Converts any callable into an evaluator
- Argument Validation: Validates that provided arguments match function signature
- Smart Result Conversion: Automatically converts various return types to Score
- Error Handling: Gracefully handles function execution and argument errors
- Parameter Flexibility: Supports functions with any parameter signature
Parameters
Callable
required
The callable function to wrap as an evaluator.
str | None
default:"None"
Optional custom name for the score. If not provided,
uses the function name.
Example
property name
Type:str
score()
Execute the wrapped function and convert result to Score. Calls the wrapped function with the provided arguments and converts the result to a Score object. Validates that the provided arguments match the function’s signature.Parameters
Any
Positional arguments to pass to the wrapped function.
Any
Keyword arguments to pass to the wrapped function. They
must match its parameters: an unknown keyword raises
ScoreFunctionInvalidArgs unless the function accepts
**kwargs.Returns
A
Score object representing the function’s evaluation result, or the list of Score objects the wrapped function returned.Raises
ScoreFunctionInvalidArgs – If the provided arguments don’t match the wrapped function’s signature.The wrapped function’s return value is converted to a Score as follows:
bool: value 1.0 for True, 0.0 for False, withlabelset to the string form (“True” / “False”)int/float: value set to the numberScore: returned as-islist[Score]: returned as-isNone: a SKIPPED score- anything else:
labelset to the string form of the value
SkipEval produces a SKIPPED score, and any other exception
produces a FAILED score carrying the error reason and message.