# PR Description
This PR renames `ExpectedToolCall` to `NamedExpectedToolCall` and then
creates a new dataclass called `ExpectedToolCall`. `ExpectedToolCall`
can be passed to the `EvalSuite.add_case` and `EvalSuite.extend_case`
methods.
1. Enhance `EvalSuite.add_case` and `EvalSuite.extend_case` by accepting
a list of `ExpectedToolCall` as their `expected_tool_calls` input
parameter. This helps create a scaffolding for developers. Previously,
the expected type was `list[tuple[Callable, dict[str, Any]]]`, which is
still valid for backward compatibility.
```python
# Before (still valid for backward compatibility)
expected_tool_calls=[
(
adjust_playback_position,
{
"absolute_position_ms": 10000,
},
)
]
# After
expected_tool_calls=[
ExpectedToolCall(
func=adjust_playback_position,
args={"absolute_position_ms": 10000},
)
]
```
2. Removed any references to arcade.core in toolkits directory.
3. Some linting for import organization.
69 lines
1.6 KiB
Python
69 lines
1.6 KiB
Python
import arcade_math
|
|
from arcade_math.tools.arithmetic import add, sqrt
|
|
|
|
from arcade.sdk import ToolCatalog
|
|
from arcade.sdk.eval import (
|
|
BinaryCritic,
|
|
EvalRubric,
|
|
EvalSuite,
|
|
ExpectedToolCall,
|
|
tool_eval,
|
|
)
|
|
|
|
# Evaluation rubric
|
|
rubric = EvalRubric(
|
|
fail_threshold=0.85,
|
|
warn_threshold=0.95,
|
|
)
|
|
|
|
|
|
catalog = ToolCatalog()
|
|
catalog.add_module(arcade_math)
|
|
|
|
|
|
@tool_eval()
|
|
def math_eval_suite():
|
|
suite = EvalSuite(
|
|
name="Math Tools Evaluation",
|
|
system_message="You are an AI assistant with access to math tools. Use them to help the user with their math-related tasks.",
|
|
catalog=catalog,
|
|
rubric=rubric,
|
|
)
|
|
|
|
suite.add_case(
|
|
name="Add two large numbers",
|
|
user_message="Add 12345 and 987654321",
|
|
expected_tool_calls=[
|
|
ExpectedToolCall(
|
|
func=add,
|
|
args={
|
|
"a": 12345,
|
|
"b": 987654321,
|
|
},
|
|
)
|
|
],
|
|
rubric=rubric,
|
|
critics=[
|
|
BinaryCritic(critic_field="a", weight=0.5), # TODO: weight should be optional
|
|
BinaryCritic(critic_field="b", weight=0.5),
|
|
],
|
|
)
|
|
|
|
suite.add_case(
|
|
name="Take the square root of a large number",
|
|
user_message="What is the square root of 3224990521?",
|
|
expected_tool_calls=[
|
|
ExpectedToolCall(
|
|
func=sqrt,
|
|
args={
|
|
"a": 3224990521,
|
|
},
|
|
)
|
|
],
|
|
rubric=rubric,
|
|
critics=[
|
|
BinaryCritic(critic_field="a", weight=1.0),
|
|
],
|
|
)
|
|
|
|
return suite
|