File tree Expand file tree Collapse file tree
src/opik/evaluation/metrics Expand file tree Collapse file tree Original file line number Diff line number Diff 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 (
Original file line number Diff line number Diff line change @@ -37,14 +37,20 @@ def test_create_scoring_inputs_string_mapping():
3737
3838
3939def test_create_scoring_inputs_callable_mapping ():
40- """Test when scoring_key_mapping contains callable mappings for nested dictionaries"""
40+ """Test when scoring_key_mapping contains callable mappings for nested dictionaries in dataset """
4141 dataset_item = {
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
@@ -55,6 +61,7 @@ def test_create_scoring_inputs_callable_mapping():
5561 "expected_output" : {"message" : "world" },
5662 "result" : "hello world" ,
5763 "reference" : "world" ,
64+ "from_output" : "foo" ,
5865 }
5966 assert_dicts_equal (result , expected )
6067
You can’t perform that action at this time.
0 commit comments