Class YesNoQuestion

java.lang.Object
dev.langchain4j.model.decision.request.YesNoQuestion
All Implemented Interfaces:
Question

@Experimental public final class YesNoQuestion extends Object implements Question
A yes/no question, answered with the probability that the answer is "yes" (see YesNoAnswer).

Optionally, yesWhen() and noWhen() describe when the answer should be "yes" and when it should be "no":

YesNoQuestion refundRequested = YesNoQuestion.builder()
        .text("Does the customer ask for a refund?")
        .yesWhen("The customer explicitly asks for their money back")
        .noWhen("The customer only asks about a charge")
        .build();
They describe what "yes" and "no" mean for this question when the question alone is ambiguous. When only one of them is set, how it combines with the question is up to the model: some models read a lone yesWhen as the only reason to answer "yes". To split the cases clearly, set both.
Since:
1.21.0
  • Method Details

    • text

      public String text()
      Description copied from interface: Question
      What the model should evaluate, for example "Which team should handle this ticket?".
      Specified by:
      text in interface Question
    • yesWhen

      public String yesWhen()
      When the answer should be "yes", or null if not set.
    • noWhen

      public String noWhen()
      When the answer should be "no", or null if not set.
    • from

      public static YesNoQuestion from(String text)
      Creates a yes/no question with the given text.
      Since:
      1.23.0
    • of

      @Deprecated(since="1.23.0", forRemoval=true) public static YesNoQuestion of(String text)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use from(String) instead
      Creates a yes/no question with the given text.
    • builder

      public static YesNoQuestion.Builder builder()
    • 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