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 Details

  • Constructor Details

    • RoutingChatModelConfiguration

      public RoutingChatModelConfiguration(@Parameter String name)
      Parameters:
      name - The name of the routing chat model bean
  • Method Details

    • getName

      public String getName()
      Returns:
      The name of the routing chat model bean
    • getRoutes

      public Map<String,String> getRoutes()
      Returns:
      The names of the ChatModel beans, by route
    • setRoutes

      public void setRoutes(Map<String,String> routes)
      The names of the ChatModel beans, by route.
      Parameters:
      routes - The routes
    • getDescriptions

      public Map<String,String> getDescriptions()
      Returns:
      The descriptions of the requests that each route handles
    • setDescriptions

      public void setDescriptions(Map<String,String> descriptions)
      The descriptions of the requests that each route handles, which the router compares the requests with.
      Parameters:
      descriptions - The descriptions, by route
    • getDefaultRoute

      public @Nullable String getDefaultRoute()
      Returns:
      The route used when the router does not choose one
    • setDefaultRoute

      public void setDefaultRoute(@Nullable String defaultRoute)
      The route used when the router does not choose one.
      Parameters:
      defaultRoute - The default route
    • getRouter

      public @Nullable String getRouter()
      Returns:
      The name of the ChatModelRouter bean
    • setRouter

      public void setRouter(@Nullable String router)
      The name of the ChatModelRouter bean that chooses the route. By default, a router asks the DecisionModel (see setDecisionModel(String)) which route matches the request.
      Parameters:
      router - The name of the router bean
    • getDecisionModel

      public @Nullable String getDecisionModel()
      Returns:
      The name of the DecisionModel bean of the default router
    • setDecisionModel

      public void setDecisionModel(@Nullable String decisionModel)
      The name of the DecisionModel bean of the default router, otherwise the default DecisionModel.
      Parameters:
      decisionModel - The name of the decision model bean
    • getQuestion

      public @Nullable String getQuestion()
      Returns:
      The question the default router asks the decision model
    • setQuestion

      public void setQuestion(@Nullable String question)
      The question the default router asks the decision model.
      Parameters:
      question - The question
    • getMinProbability

      public @Nullable Double getMinProbability()
      Returns:
      The minimum probability of the route chosen by the default router
    • setMinProbability

      public void setMinProbability(@Nullable Double minProbability)
      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