Files
agentUniverse/docs/guidebook/zh/实践应用/金融事件分析案例.md
2025-01-13 17:59:54 +08:00

68 lines
3.8 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.
# 金融事件分析案例
## 案例说明
本案例基于PeerAgentTemplate和PeerWorkPattern搭建了一个用于分析金融事件的多智能体协作案例并以“巴菲特2023年减持比亚迪”事件为例展示了如何在agentUniverse中使用PEER多智能体协作模式并详细展示了PEER中每种智能体的配置方式及输出样例。
该案例基于OPENAI的gpt-4o模型使用前需要您在环境变量中配置`OPENAI_API_KEY`
## Agents
### Planning Agent
原始代码文件可参考
- [配置文件](../../../../examples/sample_apps/peer_agent_app/intelligence/agentic/agent/agent_instance/peer_agent_case/demo_planning_agent.yaml)
- [提示词](../../../../examples/sample_apps/peer_agent_app/intelligence/agentic/prompt/planning_agent_cn.yaml)
Planning Agent负责将原始的金融问题拆分为多个可被单独解决的子问题提供给后续的Executing Agent执行。在这个案例中原始问题“分析下巴菲特减持比亚迪的原因”可以被拆解为下图中的数个子问题
![planning_result](../../_picture/6_4_1_planning_result.png)
### Executing Agent
原始代码文件可参考
- [配置文件](../../../../examples/sample_apps/peer_agent_app/intelligence/agentic/agent/agent_instance/peer_agent_case/demo_executing_agent.yaml)
- [提示词](../../../../examples/sample_apps/peer_agent_app/intelligence/agentic/prompt/executing_agent_cn.yaml)
在这个Agent中我们提供了一个用于在google上搜索信息的工具[google_search_tool](../../../../examples/sample_apps/peer_agent_app/intelligence/agentic/tool/google_search_tool.py),该工具的使用需要在环境信息中配置`SERPER_API_KEY`
Executing Agent负责解决Planning Agent拆分出的子问题。在本案例中Executing Agent对拆解问题的执行结果如下
![executing_result](../../_picture/6_4_1_executing_result.png)
结果较长,这里只展示了前两问的执行结果。
### Expressing Agent
原始代码文件可参考
- [配置文件](../../../../examples/sample_apps/peer_agent_app/intelligence/agentic/agent/agent_instance/peer_agent_case/demo_expressing_agent.yaml)
- [提示词](../../../../examples/sample_apps/peer_agent_app/intelligence/agentic/prompt/expressing_agent_cn.yaml)
Expressing Agent负责将Executing Agent输出的所有结果进行汇总并根据提示词中的要求总结表达为对原始问题的回答在该案例中Expressing Agent的输出结果如下
![expressing_result](../../_picture/6_4_1_expressing_result.png)
### Reviewing Agent
原始代码文件可参考
- [配置文件](../../../../examples/sample_apps/peer_agent_app/intelligence/agentic/agent/agent_instance/peer_agent_case/demo_reviewing_agent.yaml)
Reviewing Agent负责对Expressing Agent产出的结果进行评价看是否对于原问题是有效的回答在本案例中Reviewing Agent接受了Expressing Agent的答案
![reviewing_result](../../_picture/6_4_1_reviewing_result.png)
### PEER Agent
```yaml
info:
name: 'demo_peer_agent'
description: 'demo peer agent'
profile:
planning: 'demo_planning_agent'
executing: 'demo_executing_agent'
expressing: 'demo_expressing_agent'
reviewing: 'demo_reviewing_agent'
memory:
name: 'demo_memory'
metadata:
type: 'AGENT'
module: 'agentuniverse.agent.template.peer_agent_template'
class: 'PeerAgentTemplate'
```
用户可以通过配置文件的形式将上文中的四个Agent经由`PeerAgentTemplate`的协作模式组装为完整的PEER Agent。其中
- planning负责Plan部分的Agent名称
- executing负责Execute部分的Agent名称
- expressing负责Express部分的Agent名称
- reviewing负责Review部分的Agent名称
您可以在[示例文件](../../../../examples/sample_apps/peer_agent_app/intelligence/test/peer_agent.py)中完整运行本案例。