1- """Community evaluator: response_quality
1+ """Example custom evaluator: checks that every invocation has a non-empty response
2+ and that responses don't just parrot back the user input.
23
3- Checks that every invocation has a non-empty response, meets a configurable
4- minimum length, and doesn't just parrot back the user input.
4+ Install the SDK standalone: pip install agentevals-evaluator-sdk
55
6- Config options:
7- min_response_length (int): Minimum character length for responses (default: 10)
6+ Usage in eval_config.yaml:
7+
8+ evaluators:
9+ - name: response_quality
10+ type: code
11+ path: ./examples/custom_evaluators/response_quality.py
12+ threshold: 0.7
13+ config:
14+ min_response_length: 20
815"""
916
10- from agentevals_grader_sdk import grader , EvalInput , EvalResult
17+ from agentevals_evaluator_sdk import EvalInput , EvalResult , evaluator
1118
1219
13- @grader
20+ @evaluator
1421def response_quality (input : EvalInput ) -> EvalResult :
1522 min_len = input .config .get ("min_response_length" , 10 )
1623 scores : list [float ] = []
@@ -37,7 +44,7 @@ def response_quality(input: EvalInput) -> EvalResult:
3744 and inv .final_response .strip ().lower () == inv .user_content .strip ().lower ()
3845 ):
3946 score -= 0.5
40- issues .append (f"{ inv .invocation_id } : response echoes user input" )
47+ issues .append (f"{ inv .invocation_id } : response is just the user input echoed back " )
4148
4249 scores .append (max (0.0 , score ))
4350
0 commit comments