Files
agentUniverse/docs/guidebook/zh/开始使用/4.构建典型的多智能体应用.md
2025-01-07 23:11:50 +08:00

60 lines
3.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 文档说明
在《快速构建单体智能体》中我们我们已经快速构建并运行了单体智能体,在本章节我们将进一步将其拆分成多个智能体协作的方式。
# 从单智能体到多智能体
样板工程地址:[demo_startup_app_with_multi_agents](../../../../examples/startup_app/demo_startup_app_with_multi_agents)
对于比较复杂的场景,单智能可能不足以完成任务,需要多个智能体协作。
以样板工程的保险问答为例由于用户的问题可能比较发散单智能体的回答有时候会产生偏离。在部分专家经验的驱动下对于这种场景我们将其拆分为策划、执行与表达3个智能体并使用保险智能顾问智能体将其串联。
## 子智能体
使用单体智能体构建章节中所获得的经验我们分别建立策划、执行与表达3个智能体
策划智能体(拆解问题):
[question_rewrite_agent.yaml](../../../../examples/startup_app/demo_startup_app_with_multi_agents/intelligence/agentic/agent/agent_instance/insurance_planning_agent.yaml)
执行智能体:
[question_planning_agent.yaml](../../../../examples/startup_app/demo_startup_app_with_multi_agents/intelligence/agentic/agent/agent_instance/insurance_executing_agent.yaml)
表达智能体:
[insurance_expressing_agent.yaml](../../../../examples/startup_app/demo_startup_app_with_multi_agents/intelligence/agentic/agent/agent_instance/insurance_expressing_agent.yaml)
## 主智能体
[insurance_consult_agent.yaml](../../../../examples/startup_app/demo_startup_app_with_multi_agents/intelligence/agentic/agent/agent_instance/insurance_consult_agent.yaml)
主智能体将几个智能体和工具按照一定的逻辑串接起来这里要注意的是参数的传递agent_input作为线程上下文可以存储中间产物给后面的智能体使用每个智能体的出入参字段是可以按照需求自定义建议不要重复。
## 运行测试
运行 [insurance_consult_pro_agent_test.py](../../../../examples/startup_app/demo_startup_app_with_multi_agents/intelligence/test/insurance_multi_agent_test.py)
**原问题改写后的问题是:**
```text
如何将保险产品A的基础版升级到升级版或尊享版升级的具体流程和条件是什么
```
**智能体 question_planning_agent 执行结果为:**
```json
{
"sub_query_list": [
"如何从保险产品A的基础版升级到更高版本",
"保险产品A升级版和尊享版的升级流程是什么",
"保险产品A升级时是否有额外的费用或条件需要满足"
]
}
```
**insurance_consult_agent 最终执行结果:**
```text
保险产品A在保障期间内不支持直接升级。如果您想要从当前的基础版升级到升级版或尊享版需要在当前保险期结束后重新选择更高版本的保险产品进行投保。
请注意,升级时可能会有不同的保费标准,具体费用需依据您投保时的年龄和所选版本确定。
```