-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7eebb2c
commit 2661074
Showing
8 changed files
with
106 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from continuous_eval.eval.modules import Tool, AgentModule, Module, Metric, Test | ||
from continuous_eval.eval.pipeline import Pipeline, ModuleOutput | ||
from continuous_eval.eval.pipeline import Pipeline, ModuleOutput, CalledTools | ||
from continuous_eval.eval.dataset import Dataset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from typing import Any, Dict, TypedDict | ||
|
||
UUID = str | ||
|
||
|
||
class ToolCall(TypedDict): | ||
name: str | ||
kwargs: Dict[str, Any] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from typing import List | ||
|
||
from continuous_eval.eval.types import ToolCall | ||
from continuous_eval.metrics.base import Metric | ||
|
||
|
||
class ToolDeterministicMatch(Metric): | ||
def __init__(self, order_sensitive: bool = False) -> None: | ||
super().__init__() | ||
self._order_sensitive = order_sensitive | ||
|
||
def __call__(self, tools: List[ToolCall], ground_truths: List[ToolCall], **kwargs): | ||
if self._order_sensitive: | ||
# When order matters, compare tool executions directly in sequence. | ||
num_correct = sum( | ||
1 | ||
for i, tool in enumerate(tools) | ||
if i < len(ground_truths) | ||
and tool["name"] == ground_truths[i]["name"] | ||
and tool["kwargs"] == ground_truths[i]["kwargs"] | ||
) | ||
else: | ||
# Convert ground_truth to a format that's easy to check for "contains" | ||
ground_truth_set = { | ||
frozenset(tool.items()) for tool in [{"name": tool["name"], **tool["kwargs"]} for tool in ground_truths] | ||
} | ||
# Score | ||
num_correct, matched_executions = 0, set() | ||
for tool in tools: | ||
tool_set = frozenset({"name": tool["name"], **tool["kwargs"]}.items()) | ||
if tool_set in ground_truth_set and tool_set not in matched_executions: | ||
num_correct += 1 | ||
matched_executions.add(tool_set) | ||
|
||
return {"num_correct": num_correct, "score": num_correct / len(ground_truths)} |