Class DecisionModelQueryRouter.Builder
java.lang.Object
dev.langchain4j.rag.query.router.DecisionModelQueryRouter.Builder
- Enclosing class:
DecisionModelQueryRouter
- Since:
- 1.21.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()decisionModel(DecisionModel decisionModel) Sets the decision model that decides which retrievers to use.fallbackStrategy(DecisionModelQueryRouter.FallbackStrategy fallbackStrategy) Sets what happens when the decision model fails.maxMessages(Integer maxMessages) Sets how many of the last messages of the conversation are taken into account, including the query itself: the previous messages (user messages and text responses of the AI) are sent together with the query, so that follow-up questions are understood.minProbability(Double minProbability) Sets the minimum probability of "yes" for a retriever to be used.questionTemplate(PromptTemplate questionTemplate) Sets the template of the yes/no question asked for each retriever, which must contain the{{description}}variable (the description of the retriever).retrieverToDescription(Map<ContentRetriever, String> retrieverToDescription) Sets the retrievers to route to, each with a description of the content it can retrieve.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
decisionModel
Sets the decision model that decides which retrievers to use. Required. -
retrieverToDescription
public DecisionModelQueryRouter.Builder retrieverToDescription(Map<ContentRetriever, String> retrieverToDescription) Sets the retrievers to route to, each with a description of the content it can retrieve. Required. -
questionTemplate
Sets the template of the yes/no question asked for each retriever, which must contain the{{description}}variable (the description of the retriever). The query is the input.Default value is
DecisionModelQueryRouter.DEFAULT_QUESTION_TEMPLATE. -
minProbability
Sets the minimum probability of "yes" for a retriever to be used.Default value is 0.5.
-
fallbackStrategy
public DecisionModelQueryRouter.Builder fallbackStrategy(DecisionModelQueryRouter.FallbackStrategy fallbackStrategy) Sets what happens when the decision model fails.Default value is
DecisionModelQueryRouter.FallbackStrategy.DO_NOT_ROUTE. -
maxMessages
Sets how many of the last messages of the conversation are taken into account, including the query itself: the previous messages (user messages and text responses of the AI) are sent together with the query, so that follow-up questions are understood. System messages, tool calls and tool results are never sent, and do not count. Only applies when the query comes from a conversation with a chat memory.Default value is 3: the query and the 2 previous messages. More messages can make an older topic of the conversation outweigh the query. When the queries are already made self-contained, for example by a
CompressingQueryTransformer, set it to 1. -
build
-