kind="code" flag on the scores.
Using create_evaluator
For convenience, a simple (sync or async) function can be converted into an Evaluator using the create_evaluator decorator. This function can either directly return a Score object or a value that can be converted into a score.
In the following examples, our decorated evaluation function and coroutine return a boolean, which when used as an Evaluator, is converted into a Score with a score value of 1 or 0 and a corresponding label of True or False.
- Python
- TypeScript
- Python
- TypeScript
Returning Score objects directly
- Python
- TypeScript
Other Score conversions
The create_evaluator / createEvaluator function will convert many different function outputs into scores automatically:
- Python
- TypeScript
- A Score object (no conversion needed)
- A number (converted to Score.score)
- A boolean (converted to integer Score.score and string Score.label)
- A short string (β€3 words, converted to Score.label)
- A long string (β₯4 words, converted to Score.explanation)
- A dictionary with keys βscoreβ, βlabelβ, or βexplanationβ
- A tuple of values (only bool, number, str types allowed)

