Skip to content

Commit bb705a5

Browse files
committed
[issue-6025] [SDK] fix: mapping callables not reading task output
1 parent 3028b0d commit bb705a5

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

sdks/python/src/opik/evaluation/metrics/arguments_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def create_scoring_inputs(
5959
else:
6060
for key, value in scoring_key_mapping.items():
6161
if callable(value):
62-
mapped_inputs[key] = value(dataset_item)
62+
mapped_inputs[key] = value(mapped_inputs)
6363
else:
6464
if value not in mapped_inputs:
6565
LOGGER.debug(

sdks/python/tests/unit/evaluation/test_create_scoring_inputs.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,15 @@ def test_create_scoring_inputs_callable_mapping():
4242
"input": {"message": "hello"},
4343
"expected_output": {"message": "world"},
4444
}
45-
task_output = {"result": "hello world"}
45+
task_output = {
46+
"result": "hello world",
47+
"actual_output": {"message": "foo"},
48+
}
4649

47-
mapping = {"reference": lambda x: x["expected_output"]["message"]}
50+
mapping = {
51+
"reference": lambda x: x["expected_output"]["message"],
52+
"from_output": lambda x: x["actual_output"]["message"],
53+
}
4854

4955
result = create_scoring_inputs(
5056
dataset_item=dataset_item, task_output=task_output, scoring_key_mapping=mapping
@@ -54,7 +60,9 @@ def test_create_scoring_inputs_callable_mapping():
5460
"input": {"message": "hello"},
5561
"expected_output": {"message": "world"},
5662
"result": "hello world",
63+
"actual_output": {"message": "foo"},
5764
"reference": "world",
65+
"from_output": "foo",
5866
}
5967
assert_dicts_equal(result, expected)
6068

0 commit comments

Comments
 (0)