@@ -26,7 +26,7 @@ def mock_model():
26
26
return model
27
27
28
28
# Simple implementation of PromptScorer for testing
29
- class TestScorer (PromptScorer ):
29
+ class SampleScorer (PromptScorer ):
30
30
def build_measure_prompt (self , example : Example ) -> List [dict ]:
31
31
return [
32
32
{"role" : "system" , "content" : "Test system prompt" },
@@ -45,18 +45,18 @@ def success_check(self, **kwargs) -> bool:
45
45
# Tests for PromptScorer
46
46
class TestPromptScorer :
47
47
def test_init (self ):
48
- scorer = TestScorer ("test_scorer" )
48
+ scorer = SampleScorer ("test_scorer" )
49
49
assert scorer .name == "test_scorer"
50
50
assert scorer .threshold == 0.5
51
51
assert scorer .include_reason is True
52
52
assert scorer .async_mode is True
53
53
54
54
def test_init_strict_mode (self ):
55
- scorer = TestScorer ("test_scorer" , strict_mode = True )
55
+ scorer = SampleScorer ("test_scorer" , strict_mode = True )
56
56
assert scorer .threshold == 1
57
57
58
58
def test_enforce_prompt_format (self ):
59
- scorer = TestScorer ("test_scorer" )
59
+ scorer = SampleScorer ("test_scorer" )
60
60
prompt = [{"role" : "system" , "content" : "Base prompt" }]
61
61
schema = {"score" : float , "reason" : str }
62
62
@@ -66,21 +66,21 @@ def test_enforce_prompt_format(self):
66
66
assert '"reason": <reason> (str)' in formatted [0 ]["content" ]
67
67
68
68
def test_enforce_prompt_format_invalid_input (self ):
69
- scorer = TestScorer ("test_scorer" )
69
+ scorer = SampleScorer ("test_scorer" )
70
70
with pytest .raises (TypeError ):
71
71
scorer .enforce_prompt_format ("invalid" , {})
72
72
73
73
@pytest .mark .asyncio
74
74
async def test_a_score_example (self , example , mock_model ):
75
- scorer = TestScorer ("test_scorer" )
75
+ scorer = SampleScorer ("test_scorer" )
76
76
scorer .model = mock_model
77
77
78
78
result = await scorer .a_score_example (example , _show_indicator = False )
79
79
assert result == 0.8
80
80
assert scorer .reason == "Test reason"
81
81
82
82
def test_score_example_sync (self , example , mock_model ):
83
- scorer = TestScorer ("test_scorer" , async_mode = False )
83
+ scorer = SampleScorer ("test_scorer" , async_mode = False )
84
84
scorer .model = mock_model
85
85
86
86
result = scorer .score_example (example , _show_indicator = False )
0 commit comments