Class ChatModelRoutingResult

java.lang.Object
dev.langchain4j.model.chat.router.ChatModelRoutingResult

@Experimental public final class ChatModelRoutingResult extends Object
The result of a ChatModelRouter: the route that handles the request, or the default route of the routing chat model.
ChatModelRouter router = request -> request.chatRequest().messages().size() > 20
        ? ChatModelRoutingResult.route("complex")
        : ChatModelRoutingResult.defaultRoute();
Since:
1.21.0
  • Method Details

    • route

      public static ChatModelRoutingResult route(String routeName)
      Routes the request to the route with the given name.
    • defaultRoute

      public static ChatModelRoutingResult defaultRoute()
      Routes the request to the default route of the routing chat model, for example when a router that calls a model is unsure.
    • routeName

      public String routeName()
      The name of the selected route, or null if the default route is used.
    • isDefaultRoute

      public boolean isDefaultRoute()
      Whether the default route of the routing chat model is selected, in which case routeName() is null.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object