Router Chain

Learn about the router chain and how we can use it to implement a chatbot in LangChain.

A router chain handles a complex system of chains that involves forwarding based on decision-making by the model. We have multiple subchains that will be prompted based on the type of input from the user or the previous chain until the required result is reached.

Structure of the router chain

The router chain consists of three key components:

  • Router chain: This chain decides the next chain to be called.

  • Destination chain: These chains represent the options available for the router chain to redirect the input to.

  • Default chain: When the router chain can’t decide which chain to use, it redirects to the default chain that provides a default output.

Get hands-on with 1200+ tech skills courses.