Skip to content

Commit 884708d

Browse files
committed
Fix the validator
1 parent 8c85f5c commit 884708d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/judgeval/scorers/api_scorer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ def validate_threshold(cls, v):
3434
@field_validator('score_type')
3535
def convert_to_enum_value(cls, v):
3636
"""
37-
Validates that the `score_type` is a valid `JudgmentMetric` enum value.
38-
Converts string values to `JudgmentMetric` enum values.
37+
Validates that the `score_type` is a valid `APIScorer` enum value.
38+
Converts string values to `APIScorer` enum values.
3939
"""
4040
debug(f"Attempting to convert score_type value: {v}")
4141
if isinstance(v, APIScorer):
42-
info(f"Using existing JudgmentMetric: {v.value}")
43-
return v.value
42+
info(f"Using existing APIScorer: {v}")
43+
return v
4444
elif isinstance(v, str):
45-
debug(f"Converting string value to JudgmentMetric enum: {v}")
46-
return APIScorer[v.upper()].value
45+
debug(f"Converting string value to APIScorer enum: {v}")
46+
return APIScorer[v.upper()]
4747
error(f"Invalid score_type value: {v}")
4848
raise ValueError(f"Invalid value for score_type: {v}")
4949

@@ -58,7 +58,7 @@ def to_dict(self) -> dict:
5858
dict: A dictionary containing the scorer's configuration
5959
"""
6060
return {
61-
"score_type": self.score_type,
61+
"score_type": self.score_type.value, # Convert enum to string for serialization
6262
"threshold": self.threshold
6363
}
6464

0 commit comments

Comments
 (0)