MultiPromptChain x RunnableBranch

In the course, we use the concept of router chain with the MultiPromptChain

image

But, I found the RunnableBranch option in the LangChain docs. Which seems to do the same thing (routing).

What is the difference between the two approaches and what is the best option when one wants to route to different agents based on the prompt?

It looks like the MultiPromptChain only picks the prompt dynamically based on the inputs (or maybe I’m off). On the flip side, the RunnableBranch object is more versatile. It lets you route to various chains, where each chain can have its own customized prompt. But that’s not all – you can also have a personalized retriever (in a RAG scenario) and different output parsers for each chain.

1 Like