File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 11import json
2+ import logging
23from typing import Dict
34
45import pytest
@@ -660,3 +661,35 @@ def test_stable_hash_across_subprocess():
660661
661662 assert isinstance (child_hash , int )
662663 assert parent_hash == child_hash
664+
665+ def test_evaluation_row_extra_fields ():
666+ example = {
667+ "messages" : [
668+ {"role" : "user" , "content" : "What is the capital of France?" },
669+ {"role" : "assistant" , "content" : "The capital of France is Paris." },
670+ ],
671+ "ground_truth" : "Paris" ,
672+ "evaluation_result" : {"score" : 1.0 , "reason" : "Correct" },
673+ "input_metadata" : {"model" : "gpt-4" },
674+ "eval" : {"score" : 0.5 },
675+ "eval_details" : {
676+ "score" : 0.5 ,
677+ "reason" : "Correct" ,
678+ "is_score_valid" : True ,
679+ "metrics" : {
680+ "accuracy" : {
681+ "score" : 1.0 ,
682+ "reason" : "Correct" ,
683+ "is_score_valid" : True ,
684+ },
685+ },
686+ },
687+ "extra_fields" : {
688+ "test" : "test" ,
689+ },
690+ }
691+ row = EvaluationRow (** example )
692+ dictionary = json .loads (row .model_dump_json ())
693+ assert "eval" in dictionary
694+ assert "accuracy" in dictionary ["eval_details" ]["metrics" ]
695+ assert "test" in dictionary ["extra_fields" ]
You can’t perform that action at this time.
0 commit comments