-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathevaluation_schema_builder.py
More file actions
53 lines (47 loc) · 1.92 KB
/
Copy pathevaluation_schema_builder.py
File metadata and controls
53 lines (47 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""Internal class for building evaluation response schemas."""
from typing import Any, Dict
class EvaluationSchemaBuilder:
"""
Internal class for building evaluation response schemas.
Not exported - only used internally by Judge.
Schema is a fixed shape: one "evaluation" object with score and reasoning.
The judge config's evaluation_metric_key is only used when keying the result,
not in the schema.
"""
@staticmethod
def build() -> Dict[str, Any]:
"""
Build the evaluation response schema. No parameters; the schema is
always the same. The judge keys the parsed result by its config's
evaluation_metric_key.
In practice the model returns JSON like:
{"evaluation": {"score": 0.85, "reasoning": "The response is accurate."}}
:return: Schema dictionary for structured output
"""
return {
'title': 'EvaluationResponse',
'description': 'Response containing an evaluation (score and reasoning).',
'type': 'object',
'properties': {
'evaluation': {
'type': 'object',
'description': 'The evaluation result.',
'properties': {
'score': {
'type': 'number',
'minimum': 0,
'maximum': 1,
'description': 'Score between 0.0 and 1.0.',
},
'reasoning': {
'type': 'string',
'description': 'Reasoning behind the score.',
},
},
'required': ['score', 'reasoning'],
'additionalProperties': False,
},
},
'required': ['evaluation'],
'additionalProperties': False,
}