AI-Agent 工作流-Routing Workflow
工作流-路由工作流
流程说明
用户输入userInput和可行的路由Map<String, Object> String是对这个路由的简介, Object就是实际的路由内容
这里以角色分配, 将不同的任务分配给不同的promt角色的使用方式举例
- 用户输入初始的userInput和Map<String, String>
- 根据userInput和Map的keySet让LLM决策当前任务使用的prompt角色, 给出原因和选择, 使用结构化的输出到RoutingResponse中
- 使用对应的prompt角色, 输出最后的结果

代码
- route方法
1 | public String route(String userInput, Map<String, Object> routes, String mode) { |
- determineRoute方法
1 | private String determineRoute(String input, Iterable<String> availableRoutes) { |
适用场景
适合处理存在不同的分类, 分别处理的复杂任务
原文:
When to use this workflow: Routing works well for complex tasks where there are distinct categories that are better handled separately, and where classification can be handled accurately, either by an LLM or a more traditional classification model/algorithm.
- 将简单/常见问题路由到较小的模型(如 Claude 3.5 Haiku),将困难/不寻常的问题路由到功能更强大的模型(如 Claude 3.5 Sonnet),以优化成本和速度。
- 将不同类型的客户服务查询(一般问题、退款请求、技术支持)引导到不同的下游流程、提示和工具中。
Comments
