Class JudgeRequest

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

@Experimental public final class JudgeRequest extends Object
What a Judge evaluates: a text, the criteria to check it against and, optionally, the context the text responds to (a user message or a conversation) and the sources it should be based on.
JudgeRequest request = JudgeRequest.builder()
        .text(answer)
        .context(JudgeContext.from(question))
        .sources(retrievedTexts)
        .criteria(
                JudgeCriterion.from("says that the return period is 14 days"),
                JudgeCriterion.from("contains only claims that are stated in the sources"))
        .build();
List<JudgeVerdict> verdicts = judge.evaluate(request).verdicts();
  • Method Details

    • builder

      public static JudgeRequest.Builder builder()
      Creates a builder of a request: the text to judge and the criteria are required.
    • text

      public String text()
      The text to judge, for example the response of an AI Service.
    • context

      public JudgeContext context()
      What the text responds to (a UserMessageContext or a ConversationContext), or null if not given.
    • sources

      public List<String> sources()
      The sources the text should be based on, for example retrieved documents, or null if not given. An empty list means the text had no sources to be based on.
    • criteria

      public List<JudgeCriterion> criteria()
      The criteria to check the text against, never empty.
    • 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