Skip to content

Commit aac07bc

Browse files
committed
add ut
1 parent ecf2c1d commit aac07bc

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/test_models.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import logging
23
from typing import Dict
34

45
import 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"]

0 commit comments

Comments
 (0)