Record Class CritiqueResult

java.lang.Object
java.lang.Record
dev.agenor.core.reflection.CritiqueResult
Record Components:
feedback - human-readable critique that can be appended to the next prompt; never null, may be empty when shouldRevise is false
shouldRevise - true if the output should be regenerated using feedback
score - quality score in [0.0, 1.0]; higher is better

public record CritiqueResult(String feedback, boolean shouldRevise, double score) extends Record
Immutable result produced by a ReflectionStrategy after critiquing an output.

The score field is normalised to [0.0, 1.0], where 1.0 represents a perfect output. shouldRevise should be true when the score is below the configured threshold and further iteration may improve quality.

Example:


 CritiqueResult result = new CritiqueResult(
     "The answer lacks concrete examples.",
     true,
     0.6);

 if (result.shouldRevise()) {
     // re-run the generation with result.feedback() injected into the prompt
 }
 
Since:
0.12.0
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    CritiqueResult(String feedback, boolean shouldRevise, double score)
    Compact constructor — validates the score range.
  • Method Summary

    Modifier and Type
    Method
    Description
    accepted(double score)
    Convenience factory for an accepted result (no revision needed).
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the feedback record component.
    final int
    Returns a hash code value for this object.
    revise(String feedback, double score)
    Convenience factory for a result that requires revision.
    double
    Returns the value of the score record component.
    boolean
    Returns the value of the shouldRevise record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • CritiqueResult

      public CritiqueResult(String feedback, boolean shouldRevise, double score)
      Compact constructor — validates the score range.
  • Method Details

    • accepted

      public static CritiqueResult accepted(double score)
      Convenience factory for an accepted result (no revision needed).
      Parameters:
      score - quality score in [0.0, 1.0]
      Returns:
      a CritiqueResult with shouldRevise = false and empty feedback
    • revise

      public static CritiqueResult revise(String feedback, double score)
      Convenience factory for a result that requires revision.
      Parameters:
      feedback - critique to inject into the next prompt
      score - quality score in [0.0, 1.0]
      Returns:
      a CritiqueResult with shouldRevise = true
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • feedback

      public String feedback()
      Returns the value of the feedback record component.
      Returns:
      the value of the feedback record component
    • shouldRevise

      public boolean shouldRevise()
      Returns the value of the shouldRevise record component.
      Returns:
      the value of the shouldRevise record component
    • score

      public double score()
      Returns the value of the score record component.
      Returns:
      the value of the score record component