# 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.
54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
from arcade_spotify.tools.models import SearchType
|
|
from arcade_spotify.tools.search import search
|
|
|
|
from arcade.sdk import ToolCatalog
|
|
from arcade.sdk.eval import (
|
|
BinaryCritic,
|
|
EvalRubric,
|
|
EvalSuite,
|
|
ExpectedToolCall,
|
|
SimilarityCritic,
|
|
tool_eval,
|
|
)
|
|
|
|
# Evaluation rubric
|
|
rubric = EvalRubric(
|
|
fail_threshold=0.9,
|
|
warn_threshold=0.95,
|
|
)
|
|
|
|
catalog = ToolCatalog()
|
|
catalog.add_tool(search, "Spotify")
|
|
|
|
|
|
@tool_eval()
|
|
def spotify_search_eval_suite() -> EvalSuite:
|
|
"""Create an evaluation suite for Spotify "player" tools."""
|
|
suite = EvalSuite(
|
|
name="Spotify Tools Evaluation",
|
|
system_message="You are an AI assistant that can manage Spotify using the provided tools.",
|
|
catalog=catalog,
|
|
rubric=rubric,
|
|
)
|
|
|
|
suite.add_case(
|
|
name="Search Spotify catalog",
|
|
user_message="search for 3 songs in the the album 'American IV: The Man Comes Around' by Johnny Cash",
|
|
expected_tool_calls=[
|
|
ExpectedToolCall(
|
|
func=search,
|
|
args={
|
|
"q": "album:American IV: The Man Comes Around artist:Johnny Cash",
|
|
"types": [SearchType.TRACK],
|
|
"limit": 3,
|
|
},
|
|
)
|
|
],
|
|
critics=[
|
|
SimilarityCritic(critic_field="q", weight=0.5),
|
|
BinaryCritic(critic_field="limit", weight=0.25),
|
|
BinaryCritic(critic_field="types", weight=0.25),
|
|
],
|
|
)
|
|
|
|
return suite
|