haive.agents.common.models.grade.qualitativeΒΆ

Qualitative grading model for text-based evaluations.

This module implements a qualitative grading system that provides text-based assessments with sentiment analysis and quality indicators.

ClassesΒΆ

QualitativeGrade

Qualitative grading model for text-based evaluations.

QualityLevel

Quality levels for qualitative assessment.

SentimentType

Sentiment types for qualitative feedback.

Module ContentsΒΆ

class haive.agents.common.models.grade.qualitative.QualitativeGrade(/, **data)ΒΆ

Bases: haive.agents.common.models.grade.base.Grade

Qualitative grading model for text-based evaluations.

This grade model provides detailed text-based assessments with quality levels, sentiment analysis, and structured feedback including strengths, weaknesses, and recommendations.

Parameters:

data (Any)

quality_levelΒΆ

Overall quality assessment

sentimentΒΆ

Sentiment of the feedback

strengthsΒΆ

List of identified strengths

weaknessesΒΆ

List of identified weaknesses

recommendationsΒΆ

List of improvement recommendations

detailed_feedbackΒΆ

Extended qualitative feedback

Example

grade = QualitativeGrade(
quality_level=QualityLevel.GOOD,
sentiment=SentimentType.POSITIVE,
strengths=[
"Clear logical structure",
"Strong supporting evidence",
"Engaging writing style"
],
weaknesses=[
"Minor grammatical errors",
"Could use more varied sentence structure"
],
recommendations=[
"Proofread for grammatical accuracy",
"Vary sentence length and structure for better flow"
],
justification="Well-written piece with strong content but needs polish",
detailed_feedback="This work demonstrates a solid understanding..."
)

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.

classmethod create_constructive_feedback(justification, strengths, weaknesses, recommendations, quality_level=QualityLevel.FAIR, **kwargs)ΒΆ

Create balanced constructive feedback.

Parameters:
  • justification (str) – Main justification

  • strengths (list[str]) – List of strengths

  • weaknesses (list[str]) – List of weaknesses

  • recommendations (list[str]) – List of improvement recommendations

  • quality_level (QualityLevel) – Quality level (default FAIR)

  • **kwargs – Additional parameters

Returns:

QualitativeGrade with balanced feedback

Return type:

QualitativeGrade

classmethod create_positive_feedback(justification, strengths, minor_improvements=None, quality_level=QualityLevel.GOOD, **kwargs)ΒΆ

Create predominantly positive qualitative feedback.

Parameters:
  • justification (str) – Main justification

  • strengths (list[str]) – List of strengths to highlight

  • minor_improvements (list[str] | None) – Optional minor areas for improvement

  • quality_level (QualityLevel) – Quality level (default GOOD)

  • **kwargs – Additional parameters

Returns:

QualitativeGrade with positive sentiment

Return type:

QualitativeGrade

generate_narrative_summary()ΒΆ

Generate a narrative summary of the qualitative assessment.

Returns:

Human-readable narrative summary

Return type:

str

get_feedback_summary()ΒΆ

Get a structured summary of all feedback.

Returns:

Dictionary containing organized feedback information

Return type:

dict[str, Any]

get_improvement_priority()ΒΆ

Get prioritized improvement recommendations.

Returns top weaknesses with corresponding recommendations.

Returns:

List of prioritized improvement items

Return type:

list[str]

get_normalized_score()ΒΆ

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

Based on quality level mapping to numeric equivalents.

Returns:

Normalized score based on quality level

Return type:

float

is_passing(threshold=None)ΒΆ

Determine if the grade represents a passing score.

Parameters:

threshold (float | None) – Custom threshold for passing (0.0 to 1.0). If None, uses 0.6 (equivalent to β€œfair” quality)

Returns:

True if the quality level meets or exceeds the threshold

Return type:

bool

to_display_string()ΒΆ

Convert grade to a human-readable display string.

Returns:

Formatted string representation of the qualitative grade

Return type:

str

validate_feedback_consistency()ΒΆ

Validate that feedback is consistent with quality level.

Returns:

Self if validation passes

Raises:

ValueError – If feedback is inconsistent with quality level

Return type:

QualitativeGrade

classmethod validate_feedback_items(v)ΒΆ

Validate that feedback items are meaningful.

Parameters:

v (list[str]) – List of feedback items to validate

Returns:

Validated list of feedback items

Raises:

ValueError – If items are empty or too vague

Return type:

list[str]

validate_grade_value(value)ΒΆ

Validate that a value can be converted to a quality level.

Parameters:

value (Any) – The value to validate

Returns:

True if the value can be converted to QualityLevel, False otherwise

Return type:

bool

class haive.agents.common.models.grade.qualitative.QualityLevelΒΆ

Bases: str, enum.Enum

Quality levels for qualitative assessment.

EXCEPTIONALΒΆ

Outstanding quality, exceeds expectations

EXCELLENTΒΆ

High quality, meets all expectations

GOODΒΆ

Satisfactory quality, meets most expectations

FAIRΒΆ

Adequate quality, meets basic expectations

POORΒΆ

Below expectations, significant issues

UNACCEPTABLEΒΆ

Does not meet minimum standards

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

class haive.agents.common.models.grade.qualitative.SentimentTypeΒΆ

Bases: str, enum.Enum

Sentiment types for qualitative feedback.

VERY_POSITIVEΒΆ

Highly positive feedback

POSITIVEΒΆ

Generally positive feedback

NEUTRALΒΆ

Balanced or neutral feedback

NEGATIVEΒΆ

Generally negative feedback

VERY_NEGATIVEΒΆ

Highly negative feedback

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