Skip to content

Commit 33229d1

Browse files
salma-elshafeySalma Elshafey
andauthored
Fix if condition if query value is None for tool-based evals (#4601)
* Ensure query param is not None for tool-related evaluators * Remove trailing whitespace, bump versions. * Fix condition * fix condition --------- Co-authored-by: Salma Elshafey <[email protected]>
1 parent bc1206d commit 33229d1

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

assets/evaluators/builtin/tool_call_accuracy/evaluator/_tool_call_accuracy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ async def _do_eval(self, eval_input: Dict) -> Dict[str, Union[float, str]]: # t
253253
:return: The evaluation result.
254254
:rtype: Dict
255255
"""
256-
if "query" not in eval_input:
256+
if eval_input.get("query") is None:
257257
raise EvaluationException(
258258
message=(
259259
"Query is a required input to the Tool Call Accuracy evaluator."

assets/evaluators/builtin/tool_input_accuracy/evaluator/_tool_input_accuracy.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ async def _do_eval(self, eval_input: Dict) -> Dict[str, Union[float, str]]:
485485
:return: A dictionary containing the result of the evaluation.
486486
:rtype: Dict[str, Union[str, float]]
487487
"""
488-
if "query" not in eval_input:
488+
if eval_input.get("query") is None:
489489
raise EvaluationException(
490490
message=(
491491
"Query is a required input to "
@@ -501,8 +501,7 @@ async def _do_eval(self, eval_input: Dict) -> Dict[str, Union[float, str]]:
501501
)
502502

503503
# Format conversation history for cleaner evaluation
504-
else:
505-
eval_input["query"] = reformat_conversation_history(
504+
eval_input["query"] = reformat_conversation_history(
506505
eval_input["query"], logger, include_system_messages=True, include_tool_calls=True
507506
)
508507

assets/evaluators/builtin/tool_selection/evaluator/_tool_selection.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,22 +488,21 @@ async def _do_eval(self, eval_input: Dict) -> Dict[str, Union[float, str]]:
488488
:return: A dictionary containing the result of the evaluation.
489489
:rtype: Dict[str, Union[str, float]]
490490
"""
491-
if "query" not in eval_input:
491+
if eval_input.get("query") is None:
492492
raise EvaluationException(
493493
message=(
494494
"Query is a required input to the Tool Selection evaluator."
495495
),
496496
internal_message=(
497-
"Query is a required inputto the Tool Selection evaluator."
497+
"Query is a required input to the Tool Selection evaluator."
498498
),
499499
blame=ErrorBlame.USER_ERROR,
500500
category=ErrorCategory.INVALID_VALUE,
501501
target=ErrorTarget.TOOL_SELECTION_EVALUATOR,
502502
)
503503

504504
# Format conversation history for cleaner evaluation
505-
else:
506-
eval_input["query"] = reformat_conversation_history(
505+
eval_input["query"] = reformat_conversation_history(
507506
eval_input["query"], logger, include_system_messages=True, include_tool_calls=True
508507
)
509508

0 commit comments

Comments
 (0)