Skip to content
Open
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
10 changes: 9 additions & 1 deletion py/autoevals/test_values.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pytest import approx
from pytest import approx, mark

from autoevals.list import ListContains
from autoevals.number import NumericDiff
Expand Down Expand Up @@ -105,3 +105,11 @@ def test_exact_match():
expected,
expected_score,
)


@mark.parametrize("reference", [{"amount": 100}, [100]])
@mark.parametrize("non_json", [None, True, 100, 1.5])
def test_exact_match_json_and_non_json_values(reference, non_json):
evaluator = ExactMatch()
assert evaluator(output=non_json, expected=reference).score == 0
assert evaluator(output=reference, expected=non_json).score == 0
2 changes: 1 addition & 1 deletion py/autoevals/value.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def normalize_value(value: Any, maybe_object: bool) -> str:
try:
if maybe_object:
return json.dumps(json.loads(value))
except json.JSONDecodeError:
except (json.JSONDecodeError, TypeError):
pass

return str(value)