PythonGrader class

Runs custom Python code for evaluation.

The Python code should define a grade function that returns a score.

Example

final grader = EvalGrader.python(
  name: 'custom_check',
  source: '''
def grade(item, sample):
    return 1.0 if sample.output_text.startswith('Hello') else 0.0
''',
  passThreshold: 0.5,
);
Inheritance
Annotations
  • @immutable

Constructors

PythonGrader({required String name, required String source, double? passThreshold})
Creates a PythonGrader.
const
PythonGrader.fromJson(Map<String, dynamic> json)
Creates a PythonGrader from JSON.
factory

Properties

hashCode int
The hash code for this object.
no setteroverride
name String
The name of this grader.
final
passThreshold double?
The minimum score required to pass.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
source String
The Python source code containing the grade function.
final
type String
The type of grader.
no setteroverride

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Converts this to JSON.
override
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override