Class ChoiceQuestion

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

@Experimental public final class ChoiceQuestion extends Object implements Question
A question that selects exactly one option out of a named set, answered with the chosen option and the probability of each option (see ChoiceAnswer).

Each option has a name and, optionally, a description of when it applies. Options whose name says it all, such as sentiments, need no description (ChoiceQuestion.of("What is the sentiment?", List.of("positive", "negative", "neutral"))):

ChoiceQuestion team = ChoiceQuestion.builder()
        .text("Which team should handle this ticket?")
        .option("billing", "Payments, invoices, refunds")
        .option("support", "Problems using the product. Not for questions about invoices")
        .build();
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
    • options

      public Map<String,String> options()
      The descriptions of the options, keyed by option name, in the order they were added. The description is null for an option without a description.
    • of

      public static ChoiceQuestion of(String text, Map<String,String> options)
      Creates a choice question with the given text and the descriptions of the options, keyed by option name.
    • of

      public static ChoiceQuestion of(String text, List<String> options)
      Creates a choice question with the given text and options without descriptions, for options whose name says it all.
    • builder

      public static ChoiceQuestion.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