【AI Agent系列】【MetaGPT多智能体学习】0. 环境准备 - 升级MetaGPT 0.7.2版本及遇到的坑

本文介绍了在跟随《MetaGPT多智能体课程》进行环境搭建时遇到的问题,包括升级环境、配置APIkey、模块缺失等,并提供了Windows环境下解决问题的方法。作者分享了单智能体课程系列笔记链接作为参考。
摘要由CSDN通过智能技术生成

之前跟着《MetaGPT智能体开发入门课程》学了一些MetaGPT的知识和实践,主要关注在MetaGPT入门和单智能体部分(系列文章附在文末,感兴趣的可以看下)。现在新的教程来了,新教程主要关注多智能体部分。

本系列文章跟随《MetaGPT多智能体课程》(https://github.com/datawhalechina/hugging-multi-agent),深入理解并实践多智能体系统的开发。

本文为该课程的前期准备 - 环境搭建。

0. 环境准备中遇到的坑

0.1 环境升级

距离上次单智能体的入门课程已经过了一个多月了,这一个月间,MetaGPT也在快速迭代,0.5版本到0.6版本再到0.7版本。要用就用最新的… 所以我升级了0.7版本。并且从源码安装:

git clone https://github.com/geekan/MetaGPT.git
cd /your/path/to/MetaGPT
pip install -e .

更具体和更多的安装方式可参考官方教程

升级的过程很顺利,然后运行示例程序检验环境是否能用。先不要管这个程序是干嘛的,直接拷贝到一个python文件中,点运行。

import asyncio

from metagpt.actions import Action
from metagpt.environment import Environment
from metagpt.roles import Role
from metagpt.team import Team

action1 = Action(name="AlexSay", instruction="Express your opinion with emotion and don't repeat it")
action2 = Action(name="BobSay", instruction="Express your opinion with emotion and don't repeat it")
alex = Role(name="Alex", profile="Democratic candidate", goal="Win the election", actions=[action1], watch=[action2])
bob = Role(name="Bob", profile="Republican candidate", goal="Win the election", actions=[action2], watch=[action1])
env = Environment(desc="US election live broadcast")
team = Team(investment=10.0, env=env, roles=[alex, bob])

asyncio.run(team.run(idea="Topic: climate change. Under 80 words per message.", send_to="Alex", n_round=5))

0.2 坑一:1 validation error for Config

在这里插入图片描述
这是因为没有设置API key导致的。找到 MetaGPT/config/config2.yaml文件,修改里面的参数,把你的key,model等填进去:

在这里插入图片描述

0.3 坑二:No module named ‘pwd’

在这里插入图片描述
这是因为Windows环境下没有pwd命令。因为这是封装在langchain内部的,我们不太好改源码。可以用以下两种解决方法:

(1)换 WSL 环境来运行程序

(2)还是Windows环境,将 langchain 的版本换一下:

pip install langchain==0.1.6
pip install langchain-community==0.0.19

所以如果你是Windows环境,那么大概也只能使用 WSL 来运行程序了。

0.4 运行成功

运行后的输出应该类似下图这样:

在这里插入图片描述
至此,环境准备好了。

附:之前MetaGPT单智能体课程的系列笔记

  • 24
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

同学小张

如果觉得有帮助,欢迎给我鼓励!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值