使用场景
比如在客服机器人的场景下,如果我们需要用不同的prompt来服务不同的用户提问时就需要用到MultiRouteChain。它会根据用户的输入选择一个合适的目标链,使用选中的目标链来回答用户的输入。
MultiRouteChain
class MultiRouteChain(Chain):
"""Use a single chain to route an input to one of multiple candidate chains."""
router_chain: RouterChain
"""Chain that routes inputs to destination chains."""
destination_chains: Mapping[str, Chain]
"""Chains that return final answer to inputs."""
default_chain: Chain
"""Default chain to use when none of the destination chains are suitable."""
它的主要属性有三个
- router_chain: 此链会根据用户输入选择目标链
- destination_chains: 它是一个Mapping, 用于存放可供选择的目标链
- default_chain: 当目标链中没有合适的链时,会默认使用这个链执行用户的输入
RouterChain
class RouterChain(Chain, ABC):
"""Chain that outputs the name of a destination chain and the inputs to it."""
Langchain提供了以下两种RouteChain子类
EmbeddingRouterChainLLMRouterChain
1.LLMRouterChain
它使用一个LL
本文讨论了在客服场景中使用MultiRouteChain进行用户输入路径路由的技术,包括LLMRouterChain和EmbeddingRouterChain的选择机制。通过实例展示了如何通过模型选择和向量匹配优化用户体验。
最低0.47元/天 解锁文章
671

被折叠的 条评论
为什么被折叠?



