Class DecisionModelChatModelRouter.Builder
java.lang.Object
dev.langchain4j.model.chat.router.DecisionModelChatModelRouter.Builder
- Enclosing class:
DecisionModelChatModelRouter
- Since:
- 1.21.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()decisionModel(DecisionModel decisionModel) Sets the decision model that selects the route.fallbackStrategy(DecisionModelChatModelRouter.FallbackStrategy fallbackStrategy) Sets what happens when the decision model fails.maxMessages(Integer maxMessages) Sets the maximum number of messages of the conversation (user messages and text responses of the AI, up to and including the last user message) that the decision model receives.minProbability(Double minProbability) Sets the minimum probability of the chosen route.Sets the question asked to choose between the routes, whose descriptions are the options.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
decisionModel
Sets the decision model that selects the route. Required. -
question
Sets the question asked to choose between the routes, whose descriptions are the options.It is a plain question rather than a template: all routes are the options of a single choice question, so there is nothing to insert into the question.
Default value is "Which model should handle this request?".
-
minProbability
Sets the minimum probability of the chosen route. Below it, the router does not select a route, so the default route of the routing chat model is used, for example a larger model when the decision model is not sure. Requires a decision model that reports probabilities. Optional: by default, the chosen route is always used. -
fallbackStrategy
public DecisionModelChatModelRouter.Builder fallbackStrategy(DecisionModelChatModelRouter.FallbackStrategy fallbackStrategy) Sets what happens when the decision model fails.Default value is
DecisionModelChatModelRouter.FallbackStrategy.DEFAULT_ROUTE. -
maxMessages
Sets the maximum number of messages of the conversation (user messages and text responses of the AI, up to and including the last user message) that the decision model receives. System messages, tool calls and tool results are never sent, and do not count. Previous messages help with follow-ups whose meaning depends on them; too many can make an older topic outweigh the last message.Default value is 3. With 1, only the text of the last user message is sent.
-
build
-