使用Auto-GPT v0.1.1

学习使用Auto-GPT v0.1.1

环境要求

  • Python 3.8 or later
  • OpenAI GPT-3 API Key(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)

安装

下载Auto-GPT

1
2
git clone https://github.com/Torantulino/Auto-GPT.git
cd Auto-GPT

切换到标签v0.1.1

1
2
3
git fetch --all --tags
git tag
git checkout v0.1.1

安装依赖

1
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com

运行Redis容器

1
docker run -d --name redis-stack-server -p 6379:6379 redis/redis-stack-server:latest

配置

1
cp .env.example .env

修改.env文件中的配置

  • OPENAI_API_KEY: OpenAI GPT-3 API Key
  • MEMORY_BACKEND=redis
    • REDIS_HOST=localhost
    • REDIS_PORT=6379
    • REDIS_PASSWORD=

修改AI设置

1
cp ai_settings.yaml ai_settings.yaml.bak

添加待修改程序

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
touch auto_gpt_workspace/basic_math.py

import math


def calc_area(radius):
    return math.pi * radius**2


def calc_circumference(radius):
    radius = float(radius)


def main(radius):
    try:
        radius = float(radius)
    except ValueError:
        print("Please enter a valid number")
        return

    area = calc_area(radius)
    circumference = calc_circumference(radius)

    print("Area: ", area)
    print("Circumference: ", circumference)

修改ai_settings.yaml

1
2
3
4
5
6
7
8
ai_goals:
  - "Denonstrate your new programming abilities!"
  - "Improve basic_math.py"
  - "Build and run tests for it"
  - "When the file is error free, shut yourself down"
  - "Be sure to write your outputs to file."
ai_name: NBGPT
ai_role: "Read, evaluate, improve write tests for and execute the code contained in basic_math.py"

运行

1
python3 scripts/main.py --gpt3only --continuous
comments powered by Disqus