Class JudgeCriterion

java.lang.Object
dev.langchain4j.test.judge.JudgeCriterion

@Experimental public final class JudgeCriterion extends Object
A criterion for a Judge, written in natural language, for example "mentions the refund amount". Optionally, it defines when it is satisfied and when it is not, which makes the verdicts more consistent and lets the team agree on what the criterion means:
JudgeCriterion.from("mentions the refund amount")
        .satisfiedWhen("the response states the amount of money that will be refunded")
        .notSatisfiedWhen("the response only says that a refund will be made, without the amount");
A criterion is immutable: satisfiedWhen(String) and notSatisfiedWhen(String) return a new criterion.
  • Method Details

    • from

      public static JudgeCriterion from(String text)
      Creates a criterion, for example JudgeCriterion.from("is polite").
    • satisfiedWhen

      public JudgeCriterion satisfiedWhen(String satisfiedWhen)
      Returns a copy of this criterion that defines when it is satisfied.
    • notSatisfiedWhen

      public JudgeCriterion notSatisfiedWhen(String notSatisfiedWhen)
      Returns a copy of this criterion that defines when it is not satisfied.
    • text

      public String text()
      The criterion, written in natural language, for example "is polite".
    • satisfiedWhen

      public String satisfiedWhen()
      When this criterion is satisfied, or null if not defined.
    • notSatisfiedWhen

      public String notSatisfiedWhen()
      When this criterion is not satisfied, or null if not defined.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object