Class RoutingChatModelConfiguration
java.lang.Object
io.micronaut.langchain4j.router.RoutingChatModelConfiguration
@EachProperty("langchain4j.routing-chat-models")
public final class RoutingChatModelConfiguration
extends Object
Configures a
RoutingChatModel: a ChatModel bean that sends each
request to one of several chat models, chosen by a ChatModelRouter.
langchain4j.routing-chat-models.assistant.routes.fast=small langchain4j.routing-chat-models.assistant.routes.expert=large langchain4j.routing-chat-models.assistant.descriptions.fast=Greetings and simple questions langchain4j.routing-chat-models.assistant.descriptions.expert=Reasoning, maths and code langchain4j.routing-chat-models.assistant.default-route=fast
- Since:
- 2.4.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@Nullable String@Nullable String@Nullable dev.langchain4j.model.chat.router.DecisionModelChatModelRouter.FallbackStrategy@Nullable DoublegetName()@Nullable String@Nullable StringvoidsetDecisionModel(@Nullable String decisionModel) The name of theDecisionModelbean of the default router, otherwise the defaultDecisionModel.voidsetDefaultRoute(@Nullable String defaultRoute) The route used when the router does not choose one.voidsetDescriptions(Map<String, String> descriptions) The descriptions of the requests that each route handles, which the router compares the requests with.voidsetFallbackStrategy(@Nullable dev.langchain4j.model.chat.router.DecisionModelChatModelRouter.FallbackStrategy fallbackStrategy) What the default router does when no route is likely enough.voidsetMinProbability(@Nullable Double minProbability) The minimum probability of the route chosen by the default router, below which the fallback strategy applies.voidsetQuestion(@Nullable String question) The question the default router asks the decision model.voidThe name of theChatModelRouterbean that chooses the route.voidThe names of theChatModelbeans, by route.
-
Field Details
-
PREFIX
-
-
Constructor Details
-
RoutingChatModelConfiguration
- Parameters:
name- The name of the routing chat model bean
-
-
Method Details
-
getName
- Returns:
- The name of the routing chat model bean
-
getRoutes
-
setRoutes
-
getDescriptions
-
setDescriptions
-
getDefaultRoute
- Returns:
- The route used when the router does not choose one
-
setDefaultRoute
The route used when the router does not choose one.- Parameters:
defaultRoute- The default route
-
getRouter
- Returns:
- The name of the
ChatModelRouterbean
-
setRouter
The name of theChatModelRouterbean that chooses the route. By default, a router asks theDecisionModel(seesetDecisionModel(String)) which route matches the request.- Parameters:
router- The name of the router bean
-
getDecisionModel
- Returns:
- The name of the
DecisionModelbean of the default router
-
setDecisionModel
The name of theDecisionModelbean of the default router, otherwise the defaultDecisionModel.- Parameters:
decisionModel- The name of the decision model bean
-
getQuestion
- Returns:
- The question the default router asks the decision model
-
setQuestion
The question the default router asks the decision model.- Parameters:
question- The question
-
getMinProbability
- Returns:
- The minimum probability of the route chosen by the default router
-
setMinProbability
The minimum probability of the route chosen by the default router, below which the fallback strategy applies.- Parameters:
minProbability- The minimum probability
-
getFallbackStrategy
public @Nullable dev.langchain4j.model.chat.router.DecisionModelChatModelRouter.FallbackStrategy getFallbackStrategy()- Returns:
- What the default router does when no route is likely enough
-
setFallbackStrategy
public void setFallbackStrategy(@Nullable dev.langchain4j.model.chat.router.DecisionModelChatModelRouter.FallbackStrategy fallbackStrategy) What the default router does when no route is likely enough.- Parameters:
fallbackStrategy- The fallback strategy
-