Class LanguageModelQueryRouter

java.lang.Object
dev.langchain4j.rag.query.router.LanguageModelQueryRouter
All Implemented Interfaces:
QueryRouter

public class LanguageModelQueryRouter extends Object implements QueryRouter
A QueryRouter that utilizes a ChatLanguageModel to make a routing decision.
Each ContentRetriever provided in the constructor should be accompanied by a description which should help the LLM to decide where to route a Query.
Refer to DEFAULT_PROMPT_TEMPLATE and implementation for more details.

Configurable parameters (optional):
- promptTemplate: The prompt template used to ask the LLM for routing decisions.
- fallbackStrategy: The strategy applied if the call to the LLM fails of if LLM does not return a valid response. Please check LanguageModelQueryRouter.FallbackStrategy for more details. Default value: LanguageModelQueryRouter.FallbackStrategy.DO_NOT_ROUTE
See Also: