1、metagpt准备工作(安装部署)

本次的主要错因,1、在hpc上没有进入正确的路径去修改config。2、用pip安装时貌似缺少库,可能也和错误路径有关。
创建虚拟环境、激活、获取
git获取

conda create -n metagpt_env python=3.10
conda activate metagpt_env
git clone https://github.com/geekan/MetaGPT.git --depth 1 -b main #进入一个有权限的路径克隆,否则就失败
cd MetaGPT
git clone https://github.com/geekan/MetaGPT.git 
cd /your/path/to/MetaGPT
pip install -e .

直接当做库安装,但是有可能失败,先移除再安装

conda remove -n metagpt_env
conda create -n metagpt_env python=3.10
conda activate metagpt_env
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple metagpt==0.6.6 #失败
metagpt --init-config #如果失败下面手动创建

我的路径在如下,而不是进入metagpt
(metagpt_env) gbian883@2cbdf0ded76a:/opt/miniconda3/envs/metagpt_env/lib/python3.10/site-packages$
优先级如下:

 home_yaml_file = Path.home() / ".metagpt/config.yaml"
 key_yaml_file = METAGPT_ROOT / "config/key.yaml"
 default_yaml_file = METAGPT_ROOT / "config/config.yaml"

安装好后开始配置api_key

cd config
cp config2.yaml key.yaml
vim key.yaml```
或者手动创建
```bash

touch /opt/miniconda3/envs/metagpt_env/lib/python3.9/site-packages/metagpt/config2.yaml

# touch .metagpt/config2.yaml 报错
vim ~/config2.yaml #打开后按a进入编辑 esc退出编辑 :wq退出并保存 :q!不保存直接退出 记得得在英文输入法下按:

配置,智谱接口详情智谱

llm:
  api_type: "zhipuai"  # or azure / ollama / groq etc. Check LLMType for more options
  model: "glm-4"  # or gpt-3.5-turbo
  base_url: "https://open.bigmodel.cn/api/paas/v4/chat/completions"  # or forward url / other llm url
  api_key: "YOUR_API_KEY"

报错总结:
报错:TypeError: dataclass() got an unexpected keyword argument ‘slots’
python=3.10 一开始装的10,尝试建一个3.9的库
报错:
ImportError: cannot import name ‘etree’ from ‘lxml’ (/opt/miniconda3/envs/metagpt_env/lib/python3.9/site-packages/lxml/init.py)
貌似还是不兼容?
报错:mportError: cannot import name ‘BaseModel’ from ‘pydantic’
尝试安装最新版本的metagpt
报错:error: RPC failed; curl 56 GnuTLS recv error (-9): Error decoding the received TLS packet.
尝试手动下载安装 unzip +文件名解压,成功
安装包

metagpt "Create a 2048 game" #尝试一下

或者,在startup.py中运行以下代码

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))

结果

/opt/miniconda3/envs/metagpt_env/bin/python /hpc2hdd/home/gbian883/MetaGPT/MetaGPT-main/metagpt/startup.py 
2024-05-26 19:30:50.509 | INFO     | metagpt.const:get_metagpt_package_root:29 - Package root set to /hpc2hdd/home/gbian883/MetaGPT/MetaGPT-main
2024-05-26 19:30:53.955 | INFO     | metagpt.roles.role:_act:402 - Alex(Democratic candidate): to do Action(AlexSay)
Certainly! Let's engage in this live broadcast debate on the topic of climate change.

---

Anchor: Welcome to our live broadcast, tonight we have Alex and Bob, candidates for the upcoming election. Our first topic is climate change. Alex, as a Democratic candidate, what is your stance on climate change and what actions would you take to address it?

**Alex (Me):** Thank you for having us here tonight. Climate change is not just an environmental issue, it's an existential threat to our future and the future of generations to come. We are already seeing the devastating impacts of inaction: extreme weather events, rising sea levels, and the loss of biodiversity. As a leader, I would prioritize bold and immediate action.

Firstly, I would support a rapid transition to renewable energy sources, setting a goal for the United States to achieve 100% clean energy by 2030. We need to invest heavily in solar, wind, and other sustainable technologies, creating millions of new jobs in the process.

Secondly, I believe in rejoining the Paris Agreement and leading the global effort to limit global warming to 1.5 degrees Celsius. We must work collaboratively with other nations to tackle this global issue.

Lastly, I would implement a carbon pricing mechanism, ensuring that polluters pay for their emissions, and use those funds to invest in green infrastructure and to support vulnerable communities that are most affected by climate change.

Anchor: Bob, your response?

**Bob:** [Bob's response]

Anchor: Alex, a quick rebuttal?

**Alex (Me):** I appreciate Bob's concerns, but we cannot afford to wait any longer. The science is clear, and the cost of inaction far outweighs the cost of taking action now. We need decisive leadership to secure a sustainable future for all Americans. This is not just an environmental issue; it's a moral imperative. We have a responsibility to our children and grandchildren to leave them a habitable planet.
2024-05-26 19:31:06.910 | INFO     | metagpt.utils.cost_manager:update_cost:57 - Total running cost: $0.007 | Max budget: $10.000 | Current cost: $0.007, prompt_tokens: 79, completion_tokens: 398
2024-05-26 19:31:06.912 | INFO     | metagpt.roles.role:_act:402 - Bob(Republican candidate): to do Action(BobSay)
**Bob:** Thank you, and I too recognize the importance of environmental stewardship. However, I believe that we must balance our approach to climate change with economic realities. As a Republican, I understand the need for a thriving economy to support our families and businesses. We can address climate change without sacrificing jobs or economic growth.

My approach would focus on innovation and technology. I support investing in next-generation nuclear energy, which is clean and reliable, and encouraging private sector innovation through tax incentives for research and development in green technologies. This will drive down the costs of clean energy and make our energy sector more competitive globally.

Regarding the Paris Agreement, I have concerns about its potential economic impact on American industries and workers. Instead of rushing into international commitments that could harm our economy, I would advocate for agreements that are fair and equitable, ensuring that all countries are held to the same standards.

As for carbon pricing, I'm hesitant to support a policy that could increase costs for American families. Instead, I would promote policies that reward companies for reducing emissions, not punish them for producing the energy we all rely on.

**Alex (Me):** Bob's vision seems to be rooted in the past, not the future. While economic stability is crucial, we cannot ignore the impending crisis of climate change. The innovation and technology Bob speaks of will not materialize without a clear and urgent push from the government. We need to lead the world in this transition, not lag behind.

Rewarding companies for reducing emissions is a step in the right direction, but without a comprehensive plan, we're just treading water. We need a bold commitment, and that means facing the reality that some industries will have to evolve. It's about creating new jobs in green industries, not protecting jobs that are holding us back from progress.

The Paris Agreement isn't just about environmentalism; it's about global leadership. By stepping back from the international stage, we lose our seat at the table and our ability to influence the world towards a more sustainable path. We cannot afford to miss this opportunity to shape our future and secure our planet for generations to come.
2024-05-26 19:31:23.958 | INFO     | metagpt.utils.cost_manager:update_cost:57 - Total running cost: $0.019 | Max budget: $10.000 | Current cost: $0.013, prompt_tokens: 467, completion_tokens: 427
2024-05-26 19:31:23.960 | INFO     | metagpt.roles.role:_act:402 - Alex(Democratic candidate): to do Action(AlexSay)
**Alex (Me):** Climate change demands urgency. We're talking about the health of our planet, the air our kids breathe. I stand for immediate, bold action. Renewable energy isn't just an option, it's our future. The Paris Agreement isn't just a pledge, it's our global responsibility. Let's lead, not lag behind, in safeguarding our home.
2024-05-26 19:31:27.846 | INFO     | metagpt.utils.cost_manager:update_cost:57 - Total running cost: $0.033 | Max budget: $10.000 | Current cost: $0.014, prompt_tokens: 915, completion_tokens: 79
2024-05-26 19:31:27.848 | INFO     | metagpt.roles.role:_act:402 - Bob(Republican candidate): to do Action(BobSay)
**Bob:** I understand the sense of urgency, and I too want to leave a habitable planet for future generations. But we must be pragmatic. My approach is about balance—between our environment and our economy. We can't ignore the immediate needs of American workers and families. We're talking about real lives, real jobs, real communities that rely on industries that have been the backbone of our economy.

We need a just transition to a greener economy, one that doesn't leave workers in the dust. That's why I propose a Worker Transition Program, providing retraining and new opportunities for those in fossil fuel industries. Let's empower people to adapt and thrive in this new green economy, not leave them behind.

And on the Paris Agreement, I'm all for American leadership, but it must be leadership that's in our nation's best interest. We can lead by example, by investing in our own clean energy revolution, and by exporting our technology to the world, creating jobs here at home and influencing global change through innovation and market leadership.

We don't need to choose between the environment and the economy—it's a false dichotomy. We can protect our planet and grow our economy simultaneously. But it requires a thoughtful, strategic approach, not just a rush to meet deadlines that could have unintended consequences for the very people we're trying to protect.
2024-05-26 19:31:38.156 | INFO     | metagpt.utils.cost_manager:update_cost:57 - Total running cost: $0.051 | Max budget: $10.000 | Current cost: $0.018, prompt_tokens: 984, completion_tokens: 273
2024-05-26 19:31:38.158 | INFO     | metagpt.roles.role:_act:402 - Alex(Democratic candidate): to do Action(AlexSay)
**Alex (Me):** Climate change is a crisis we can't afford to ignore. My plan? Swiftly shift to clean energy, lead on the global stage by rejoining the Paris Agreement, and hold polluters accountable. It's not just about our planet—it's about our duty to future generations. We must act now, with urgency and resolve.
2024-05-26 19:31:42.597 | INFO     | metagpt.utils.cost_manager:update_cost:57 - Total running cost: $0.070 | Max budget: $10.000 | Current cost: $0.019, prompt_tokens: 1278, completion_tokens: 74

Process finished with exit code 0
  • 8
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值