Skip to content

Commit

Permalink
Fixes ToolCallAccuracy raises ZeroDivisionError when called without a…
Browse files Browse the repository at this point in the history
…ny 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 <shahules786@gmail.com>
  • Loading branch information
sahusiddharth and shahules786 authored Nov 19, 2024
1 parent f14cd85 commit e080ea9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ragas/metrics/_tool_call_accuracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ def init(self, run_config):
async def _get_arg_score(
self, preds: t.Dict[str, t.Any], refs: t.Dict[str, t.Any], callbacks: Callbacks
) -> float:
if not refs and not preds:
return 1.0
if not refs:
return 0.0

score = 0.0
for arg in refs.keys():
if arg in preds:
Expand Down

0 comments on commit e080ea9

Please sign in to comment.