# 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.
158 lines
5.1 KiB
Python
158 lines
5.1 KiB
Python
import arcade_github
|
|
from arcade_github.tools.models import SortDirection
|
|
from arcade_github.tools.repositories import (
|
|
count_stargazers,
|
|
get_repository,
|
|
list_org_repositories,
|
|
list_repository_activities,
|
|
list_review_comments_in_a_repository,
|
|
)
|
|
|
|
from arcade.sdk import ToolCatalog
|
|
from arcade.sdk.eval import (
|
|
BinaryCritic,
|
|
EvalRubric,
|
|
EvalSuite,
|
|
ExpectedToolCall,
|
|
tool_eval,
|
|
)
|
|
|
|
# Evaluation rubric
|
|
rubric = EvalRubric(
|
|
fail_threshold=0.9,
|
|
warn_threshold=0.95,
|
|
)
|
|
|
|
catalog = ToolCatalog()
|
|
# Register the GitHub tools
|
|
catalog.add_module(arcade_github)
|
|
|
|
|
|
@tool_eval()
|
|
def github_repositories_eval_suite() -> EvalSuite:
|
|
"""Evaluation suite for GitHub Repositories tools."""
|
|
suite = EvalSuite(
|
|
name="GitHub Repositories Tools Evaluation Suite",
|
|
system_message="You are an AI assistant that helps users interact with GitHub repositories using the provided tools.",
|
|
catalog=catalog,
|
|
rubric=rubric,
|
|
)
|
|
|
|
# Count Stargazers
|
|
suite.add_case(
|
|
name="Count stargazers of a repository",
|
|
user_message="How many stargazers does the ArcadeAI/test repo have?",
|
|
expected_tool_calls=[
|
|
ExpectedToolCall(
|
|
func=count_stargazers,
|
|
args={
|
|
"owner": "ArcadeAI",
|
|
"name": "test",
|
|
},
|
|
)
|
|
],
|
|
critics=[
|
|
BinaryCritic(critic_field="owner", weight=0.5),
|
|
BinaryCritic(critic_field="name", weight=0.5),
|
|
],
|
|
)
|
|
|
|
# List an Organization's Repositories
|
|
suite.add_case(
|
|
name="List repositories in an organization",
|
|
user_message="List all repos in the ArcadeAI org, sorted by creation date in descending order.",
|
|
expected_tool_calls=[
|
|
ExpectedToolCall(
|
|
func=list_org_repositories,
|
|
args={
|
|
"org": "ArcadeAI",
|
|
"repo_type": "all",
|
|
"sort": "created",
|
|
"sort_direction": SortDirection.DESC,
|
|
},
|
|
)
|
|
],
|
|
critics=[
|
|
BinaryCritic(critic_field="org", weight=0.1),
|
|
BinaryCritic(critic_field="repo_type", weight=0.1),
|
|
BinaryCritic(critic_field="sort", weight=0.1),
|
|
BinaryCritic(critic_field="sort_direction", weight=0.1),
|
|
],
|
|
)
|
|
|
|
# Get Repository
|
|
suite.add_case(
|
|
name="Get details of a repository",
|
|
user_message="Tell me about the test repo owned by ArcadeAI.",
|
|
expected_tool_calls=[
|
|
ExpectedToolCall(
|
|
func=get_repository,
|
|
args={
|
|
"owner": "ArcadeAI",
|
|
"repo": "test",
|
|
"include_extra_data": False,
|
|
},
|
|
)
|
|
],
|
|
critics=[
|
|
BinaryCritic(critic_field="owner", weight=0.3),
|
|
BinaryCritic(critic_field="repo", weight=0.3),
|
|
],
|
|
)
|
|
|
|
# List Repository Activities
|
|
suite.add_case(
|
|
name="List activities in a repository",
|
|
user_message="List all PR merges in the 'ArcadeAI/test' repository that were performed by TestUser in the last month",
|
|
expected_tool_calls=[
|
|
ExpectedToolCall(
|
|
func=list_repository_activities,
|
|
args={
|
|
"owner": "ArcadeAI",
|
|
"repo": "test",
|
|
"direction": SortDirection.DESC,
|
|
"per_page": 30,
|
|
"actor": "TestUser",
|
|
"time_period": "month",
|
|
"activity_type": "pr_merge",
|
|
"include_extra_data": False,
|
|
},
|
|
)
|
|
],
|
|
critics=[
|
|
BinaryCritic(critic_field="owner", weight=0.1),
|
|
BinaryCritic(critic_field="repo", weight=0.1),
|
|
BinaryCritic(critic_field="direction", weight=0.1),
|
|
BinaryCritic(critic_field="actor", weight=0.1),
|
|
BinaryCritic(critic_field="time_period", weight=0.1),
|
|
BinaryCritic(critic_field="activity_type", weight=0.1),
|
|
],
|
|
)
|
|
|
|
# List Review Comments in a Repository
|
|
suite.add_case(
|
|
name="List review comments in a repository",
|
|
user_message="List all review comments in the 'ArcadeAI/test' repository, sorted by creation date in descending order.",
|
|
expected_tool_calls=[
|
|
ExpectedToolCall(
|
|
func=list_review_comments_in_a_repository,
|
|
args={
|
|
"owner": "ArcadeAI",
|
|
"repo": "test",
|
|
"sort": "created",
|
|
"direction": SortDirection.DESC,
|
|
"per_page": 30,
|
|
"page": 1,
|
|
"include_extra_data": False,
|
|
},
|
|
)
|
|
],
|
|
critics=[
|
|
BinaryCritic(critic_field="owner", weight=0.2),
|
|
BinaryCritic(critic_field="repo", weight=0.2),
|
|
BinaryCritic(critic_field="sort", weight=0.1),
|
|
BinaryCritic(critic_field="direction", weight=0.1),
|
|
],
|
|
)
|
|
|
|
return suite
|