Evaluator that wraps a user-provided function for dynamic evaluation. This class allows users to create evaluators from any callable function, automatically handling parameter passing, validation, and result conversion to Score objects. Key Features:Documentation Index
Fetch the complete documentation index at: https://handbook.fiddler.ai/llms.txt
Use this file to discover all available pages before exploring further.
- 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
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
fn | Callable | ✗ | None | The callable function to wrap as an evaluator. |
score_name | `str | None` | ✗ | None |
Example
property name : 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
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
*args | Any | ✗ | None | Positional arguments to pass to the wrapped function. |
Returns
A Score object representing the function’s evaluation result. Return type: ScoreRaises
TypeError — If the provided arguments don’t match the function signature.The function result is converted to a Score as follows:
- bool: 1.0 for True, 0.0 for False
- int/float: Direct value conversion
- Score: Returns as-is