flexeval.function_types#
Inspection utilities that use type hints to determine the appropriate object to pass to a function metric.
See eval_schema
.
Functions
|
|
|
|
|
Coerce input_object to a type accepted by metric_function at this metric_level. |
|
Given a callable, determine the valid metric_level values based on the type annotation of the first parameter. |
|
content is a list of dictionaries whose keys include 'content'. |
- flexeval.function_types.get_function_input(metric_function: Callable, metric_level: Literal['Message', 'Turn', 'Thread', 'ToolCall'], input_object: Turn | Message | Thread | ToolCall, context_only: bool) Turn | Message | Thread | ToolCall | str | dict | list [source]#
Coerce input_object to a type accepted by metric_function at this metric_level.
- Parameters:
metric_function (Callable) – Function to invoke with the returned input.
metric_level (eval_schema.MetricLevel) – The metric level at which metric_function is being invoked.
input_object (AnyFunctionObjectInput) – The input_object to be coerced, or passed as-is if accepted by metric_function.
context_only (bool) – Determines how strings and lists are converted. See schema documentation.
- Raises:
ValueError – If the function accepts at least one declared type, but
it's a type we don't support at all e.g. set or –
it's a type we don't support at this metric_level. –
- Returns:
The coerced input for metric_function.
- Return type:
- flexeval.function_types.get_valid_levels_for_callable(metric_function: Callable) set[str] [source]#
Given a callable, determine the valid metric_level values based on the type annotation of the first parameter.