CategoricalResponse
Response for classification-style scorers.
Subclass this and define a categories class variable listing every
allowed category. The value is validated against this list.
class SentimentResponse(CategoricalResponse):
categories = [
Category(value="positive", description="Positive sentiment"),
Category(value="neutral", description="Neutral sentiment"),
Category(value="negative", description="Negative sentiment"),
]
class SentimentJudge(Judge[SentimentResponse]):
async def score(self, data: Example) -> SentimentResponse:
return SentimentResponse(
value="positive",
reason="The output has an enthusiastic tone.",
)
Attributes
PropType
value?str
The selected category label.
Type
strcategories?List[Category]
Class-level list of allowed Category objects.
Type
List[Category]reason?str
Type
strcitations?Optional[List[Citation]]
Type
Optional[List[Citation]]Default
Nonevalidate_value_in_categories()
def validate_value_in_categories():