Package dev.agenor.core.reflection
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; nevernull, may be empty whenshouldReviseisfalseshouldRevise-trueif the output should be regenerated usingfeedbackscore- quality score in[0.0, 1.0]; higher is better
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
ConstructorsConstructorDescriptionCritiqueResult(String feedback, boolean shouldRevise, double score) Compact constructor — validates the score range. -
Method Summary
Modifier and TypeMethodDescriptionstatic CritiqueResultaccepted(double score) Convenience factory for an accepted result (no revision needed).final booleanIndicates whether some other object is "equal to" this one.feedback()Returns the value of thefeedbackrecord component.final inthashCode()Returns a hash code value for this object.static CritiqueResultConvenience factory for a result that requires revision.doublescore()Returns the value of thescorerecord component.booleanReturns the value of theshouldReviserecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
CritiqueResult
Compact constructor — validates the score range.
-
-
Method Details
-
accepted
Convenience factory for an accepted result (no revision needed).- Parameters:
score- quality score in[0.0, 1.0]- Returns:
- a
CritiqueResultwithshouldRevise = falseand empty feedback
-
revise
Convenience factory for a result that requires revision.- Parameters:
feedback- critique to inject into the next promptscore- quality score in[0.0, 1.0]- Returns:
- a
CritiqueResultwithshouldRevise = true
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
feedback
Returns the value of thefeedbackrecord component.- Returns:
- the value of the
feedbackrecord component
-
shouldRevise
public boolean shouldRevise()Returns the value of theshouldReviserecord component.- Returns:
- the value of the
shouldReviserecord component
-
score
public double score()Returns the value of thescorerecord component.- Returns:
- the value of the
scorerecord component
-