Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath"
version = "2.9.3"
version = "2.9.4"
description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools."
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
Expand Down
11 changes: 7 additions & 4 deletions src/uipath/eval/evaluators/exact_match_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ async def evaluate(
"""
actual_output = str(self._get_actual_output(agent_execution))
expected_output = str(self._get_expected_output(evaluation_criteria))
if not self.evaluator_config.case_sensitive:
actual_output = actual_output.lower()
expected_output = expected_output.lower()

is_exact_match = actual_output == expected_output
try:
is_exact_match = float(actual_output) == float(expected_output)
except ValueError:
if not self.evaluator_config.case_sensitive:
actual_output = actual_output.lower()
expected_output = expected_output.lower()
is_exact_match = actual_output == expected_output
if self.evaluator_config.negated:
is_exact_match = not is_exact_match

Expand Down
61 changes: 61 additions & 0 deletions tests/evaluators/test_evaluator_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,67 @@ async def test_exact_match_negated(
assert isinstance(result, NumericEvaluationResult)
assert result.score == 0.0

@pytest.mark.asyncio
@pytest.mark.parametrize(
"actual, expected",
[
("1.0", "1"),
("1", "1.0"),
("1e0", "1"),
("1.00", "1.0"),
("0.5", "0.50"),
("-3.0", "-3"),
],
)
async def test_exact_match_numeric_leniency(
self, actual: str, expected: str
) -> None:
"""Test that numerically equal values match regardless of string representation."""
execution = AgentExecution(
agent_input={"input": "Test"},
agent_output={"result": actual},
agent_trace=[],
)
config = {
"name": "ExactMatchNumericTest",
"case_sensitive": True,
"target_output_key": "result",
}
evaluator = ExactMatchEvaluator.model_validate(
{"evaluatorConfig": config, "id": str(uuid.uuid4())}
)
criteria = OutputEvaluationCriteria(expected_output={"result": expected}) # pyright: ignore[reportCallIssue]

result = await evaluator.evaluate(execution, criteria)

assert isinstance(result, NumericEvaluationResult)
assert result.score == 1.0, (
f"Expected '{actual}' and '{expected}' to be considered equal as numbers"
)

@pytest.mark.asyncio
async def test_exact_match_numeric_non_equal(self) -> None:
"""Test that numerically different values do not match."""
execution = AgentExecution(
agent_input={"input": "Test"},
agent_output={"result": "1.5"},
agent_trace=[],
)
config = {
"name": "ExactMatchNumericTest",
"case_sensitive": True,
"target_output_key": "result",
}
evaluator = ExactMatchEvaluator.model_validate(
{"evaluatorConfig": config, "id": str(uuid.uuid4())}
)
criteria = OutputEvaluationCriteria(expected_output={"result": "1"}) # pyright: ignore[reportCallIssue]

result = await evaluator.evaluate(execution, criteria)

assert isinstance(result, NumericEvaluationResult)
assert result.score == 0.0

@pytest.mark.asyncio
async def test_exact_match_validate_and_evaluate_criteria(
self, sample_agent_execution: AgentExecution
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading