Class DecisionResponse
java.lang.Object
dev.langchain4j.model.decision.response.DecisionResponse
The response of a
DecisionModel: one DecisionAnswer per question
of the request, keyed by question name, together with the DecisionResponseMetadata (model name, token
usage).
DecisionResponse response = decisionModel.decide(request);
ChoiceAnswer team = response.choice("team");
YesNoAnswer urgent = response.yesNo("urgent");
if (urgent.probability() > 0.8) {
escalate(team.value());
}
- Since:
- 1.21.0
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescription<A extends DecisionAnswer>
AReturns the answer with the given name, as the given answer type.answers()The answers, keyed by the names of the questions they answer.static DecisionResponse.Builderbuilder()Returns the answer to theChoiceQuestionwith the given name.booleaninthashCode()metadata()The name of the model that produced the answers, ornullif the model did not report it.Returns the answer to theScaleQuestionwith the given name.The token usage of the call, ornullif the model did not report it.toString()Returns the answer to theYesNoQuestionwith the given name.
-
Method Details
-
answers
The answers, keyed by the names of the questions they answer. -
yesNo
Returns the answer to theYesNoQuestionwith the given name.- Throws:
IllegalArgumentException- if there is no answer with this name, or it is not aYesNoAnswer.
-
choice
Returns the answer to theChoiceQuestionwith the given name.- Throws:
IllegalArgumentException- if there is no answer with this name, or it is not aChoiceAnswer.
-
scale
Returns the answer to theScaleQuestionwith the given name.- Throws:
IllegalArgumentException- if there is no answer with this name, or it is not aScaleAnswer.
-
answer
Returns the answer with the given name, as the given answer type. Useful for answer types defined by integrations.- Throws:
IllegalArgumentException- if there is no answer with this name, or it is not of the given type.
-
metadata
-
modelName
The name of the model that produced the answers, ornullif the model did not report it. -
tokenUsage
The token usage of the call, ornullif the model did not report it. -
builder
-
equals
-
hashCode
-
toString
-