Class DecisionEngine
DecisionModel — the counterpart of
VoiceEngine for decisions rather than audio.
What a decision model is, and why it is not a chat call
Classifying, routing or gating used to mean a full chat completion with structured output: slow,
chatty, and it hands you a word ("urgent") when what you needed was a
number you can threshold. A decision model answers a fixed set of questions in one small
call and returns probabilities. That changes the engineering: you keep the decision in Java,
at a threshold you wrote down, with the measurement in your audit log.
It also costs a fraction of a chat turn, and several questions ride in one call — which is why the API lets you ask them together instead of once per question.
Providers
Only "openai" is built in. A decision model is a dedicated endpoint, not a chat
completion: OpenAI serves it at POST {baseUrl}/decisions. OpenAI-compatible chat
providers such as Groq or DeepSeek do not implement it and answer 404. See DecisionConfig
for what to configure when your chat provider is not OpenAI. LangChain4j also ships Ollama (its
local, key-free System One API) and TypeSafe in their own modules; they plug in here and nowhere
else.
Analogy: a breathalyser rather than a conversation about whether someone seems drunk. It returns a reading; the legal limit is set elsewhere, by someone accountable for it.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic Decisionsdecide(String input, Map<String, dev.langchain4j.model.decision.request.Question> questions, DecisionConfig config) Ask one or more questions about the same input, in a single call.static dev.langchain4j.model.decision.DecisionModelmodel(DecisionConfig config) Build the LangChain4J decision model described byconfig.
-
Method Details
-
decide
public static Decisions decide(String input, Map<String, dev.langchain4j.model.decision.request.Question> questions, DecisionConfig config) Ask one or more questions about the same input, in a single call.- Parameters:
input- the text being judged (a ticket, an email, a transcript, a diff)questions- the questions, keyed by the name you will read the answers back byconfig- which decision model to call and how to reach it- Returns:
- the answers, wrapped so that absent probabilities cannot surprise you
- Throws:
IllegalArgumentException- ifinputis blank orquestionsis emptyIllegalStateException- if no API key is configured
-
model
Build the LangChain4J decision model described byconfig.Exposed as the escape hatch to the raw LangChain4J model, so choosing EasyAI never means losing access to the layer underneath.
- Parameters:
config- the decision settings- Returns:
- a ready
DecisionModel
-