agents.common.models.grade.base

Base classes for grade models.

This module defines the fundamental abstractions for all grading models including the grade type enumeration and abstract base class.

Classes

Grade

Abstract base class for all grade models.

GradeType

Types of grade models available.

Module Contents

class agents.common.models.grade.base.Grade(/, **data)

Bases: pydantic.BaseModel, abc.ABC

Abstract base class for all grade models.

This class provides the common interface and functionality that all grade models must implement. It includes metadata, validation, and utility methods.

Parameters:

data (Any)

grade_type

The type of grade model

justification

Explanation for the grade assigned

confidence

Confidence level in the grade (0.0 to 1.0)

metadata

Additional metadata about the grading

grader_id

Identifier of the grader (agent, human, etc.)

timestamp

When the grade was assigned

Example

# This is an abstract class, use concrete implementations
grade = BinaryGrade(
value=True,
justification="Response meets all criteria",
confidence=0.95
)

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

compare_to(other)

Compare this grade to another grade.

Parameters:

other (Grade) – Another Grade instance to compare against

Returns:

Dictionary containing comparison information

Raises:

TypeError – If other is not a Grade instance

Return type:

dict[str, float | str]

get_grade_summary()

Get a summary of the grade information.

Returns:

Dictionary containing key grade information for display

Return type:

dict[str, Any]

abstractmethod get_normalized_score()

Get the grade as a normalized score between 0.0 and 1.0.

This method must be implemented by all concrete grade classes to provide a common way to compare grades across different types.

Returns:

A float between 0.0 and 1.0 representing the normalized grade

Return type:

float

abstractmethod is_passing(threshold=None)

Determine if the grade represents a passing score.

Parameters:

threshold (float | None) – Optional custom threshold for passing. If None, uses grade type default.

Returns:

True if the grade is considered passing, False otherwise

Return type:

bool

to_display_string()

Convert grade to a human-readable display string.

Returns:

Formatted string representation of the grade

Return type:

str

validate_grade_value(value)

Validate that a grade value is appropriate for this grade type.

This method should be overridden by concrete classes to provide type-specific validation.

Parameters:

value (Any) – The value to validate

Returns:

True if valid, False otherwise

Return type:

bool

classmethod validate_justification(v)

Validate that justification is meaningful.

Parameters:

v (str) – The justification string to validate

Returns:

The validated justification string

Raises:

ValueError – If justification is empty, too short, or meaningless

Return type:

str

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class agents.common.models.grade.base.GradeType

Bases: str, enum.Enum

Types of grade models available.

BINARY

Simple pass/fail or yes/no grading

NUMERIC

Numeric scoring with configurable ranges

PERCENTAGE

Percentage-based scoring (0-100%)

LETTER

Traditional letter-based grading (A-F)

RUBRIC

Multi-criteria rubric-based evaluation

QUALITATIVE

Text-based qualitative assessment

SCALE

Likert-scale or custom scale grading

COMPOSITE

Combination of multiple grade types

Initialize self. See help(type(self)) for accurate signature.