Skip to content

Commit e080ea9

Browse files
Fixes ToolCallAccuracy raises ZeroDivisionError when called without any arguments. (#1685)
- Fixes: #1684 1. Check for both empty dictionaries: - If both refs and preds are empty, return 1.0 as you specified in your logic. 2. Check for empty refs: - If refs is empty but preds is not, return 0.0 since there's nothing to compare. Co-authored-by: ikka <[email protected]>
1 parent f14cd85 commit e080ea9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/ragas/metrics/_tool_call_accuracy.py

+5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ def init(self, run_config):
3535
async def _get_arg_score(
3636
self, preds: t.Dict[str, t.Any], refs: t.Dict[str, t.Any], callbacks: Callbacks
3737
) -> float:
38+
if not refs and not preds:
39+
return 1.0
40+
if not refs:
41+
return 0.0
42+
3843
score = 0.0
3944
for arg in refs.keys():
4045
if arg in preds:

0 commit comments

Comments
 (0)