Class ChoiceQuestion
java.lang.Object
dev.langchain4j.model.decision.request.ChoiceQuestion
- All Implemented Interfaces:
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 a description of when it applies. For options whose name says it all, such as
sentiments, the name is used as the description
(ChoiceQuestion.from("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
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic ChoiceQuestion.Builderbuilder()booleanstatic ChoiceQuestionCreates a choice question with the given text and options whose names say it all: each name is also used as the description.static ChoiceQuestionCreates a choice question with the given text and the descriptions of the options, keyed by option name.inthashCode()static ChoiceQuestionDeprecated, for removal: This API element is subject to removal in a future version.static ChoiceQuestionDeprecated, for removal: This API element is subject to removal in a future version.usefrom(String, Map)insteadoptions()The descriptions of the options, keyed by option name, in the order they were added.text()What the model should evaluate, for example "Which team should handle this ticket?".toString()
-
Method Details
-
text
-
options
-
from
Creates a choice question with the given text and the descriptions of the options, keyed by option name.- Since:
- 1.23.0
-
from
Creates a choice question with the given text and options whose names say it all: each name is also used as the description.- Since:
- 1.23.0
-
of
@Deprecated(since="1.23.0", forRemoval=true) public static ChoiceQuestion of(String text, Map<String, String> options) Deprecated, for removal: This API element is subject to removal in a future version.usefrom(String, Map)insteadCreates a choice question with the given text and the descriptions of the options, keyed by option name. -
of
@Deprecated(since="1.23.0", forRemoval=true) public static ChoiceQuestion of(String text, List<String> options) Deprecated, for removal: This API element is subject to removal in a future version.usefrom(String, List)insteadCreates a choice question with the given text and options whose names say it all: each name is also used as the description. -
builder
-
equals
-
hashCode
-
toString
-
from(String, List)instead