相关文章推荐
睿智的伤疤  ·  光华讲坛——认知启发的视觉-语言技术-西南财 ...·  3 月前    · 
爱热闹的金针菇  ·  【无矶之谈】编码能力堪比Copilot、Cu ...·  1 月前    · 
逆袭的生菜  ·  AI 代码生成工具深度测评:GitHub ...·  1 月前    · 
开心的硬币  ·  中石化信息技术中心社会招聘公告-国务院国有资 ...·  1 月前    · 
痴情的高山  ·  MySql sql优化之order by ...·  2 年前    · 
刚毅的紫菜  ·  .net core web 项目 无法启动 ...·  2 年前    · 
温柔的啄木鸟  ·  用LightGBM回归进行网格搜索·  3 年前    · 
Code  ›  任务拆解,悠然自得,自动版本的ChatGPT,AutoGPT自动人工智能AI任务实践(Python3.10)开发者社区
openai next 人工智能
https://cloud.tencent.com/developer/article/2276154?areaSource=&traceId=
气宇轩昂的红薯
2 年前
作者头像
用户9127725
0 篇文章

任务拆解,悠然自得,自动版本的ChatGPT,AutoGPT自动人工智能AI任务实践(Python3.10)

前往专栏
腾讯云
开发者社区
文档 意见反馈 控制台
首页
学习
活动
专区
工具
TVP
文章/答案/技术大牛
发布
首页
学习
活动
专区
工具
TVP
返回腾讯云官网
社区首页 > 专栏 > 刘悦的技术博客 > 任务拆解,悠然自得,自动版本的ChatGPT,AutoGPT自动人工智能AI任务实践(Python3.10)

任务拆解,悠然自得,自动版本的ChatGPT,AutoGPT自动人工智能AI任务实践(Python3.10)

作者头像
用户9127725
发布 于 2023-04-28 17:05:06
242 0
发布 于 2023-04-28 17:05:06
举报
当我们使用ChatGPT完成某些工作的时候,往往需要多轮对话,比如让ChatGPT分析、翻译、总结一篇网上的文章或者文档,再将总结的结果以文本的形式存储在本地。过程中免不了要和ChatGPT“折冲樽俎”一番,事实上,这个“交涉”的过程也可以自动化,AutoGPT可以帮助我们自动拆解任务,没错,程序能做到的事情,人类绝不亲力亲为。

我们唯一需要做的,就是告诉AutoGPT一个任务目标,AutoGPT会自动根据任务目标将任务拆解成一个个的小任务,并且逐个完成,简单且高效。

配置AutoGPT

先确保本地环境 安装好了Python3.10.9 。

接着运行Git命令拉取项目:

git clone https://github.com/Significant-Gravitas/Auto-GPT.git

随后进入项目的目录:

cd Auto-GPT

安装相关的依赖库:

pip3 install -r requirements.txt

安装成功后,复制一下项目的配置文件:

cp .env.template .env

这里通过cp命令将配置文件模版.env.template复制成为一个新的配置文件.env。

随后将Openai的秘钥填入配置文件:

### OPENAI
# OPENAI_API_KEY - OpenAI API Key (Example: my-openai-api-key)
# TEMPERATURE - Sets temperature in OpenAI (Default: 0)
# USE_AZURE - Use Azure OpenAI or not (Default: False)
OPENAI_API_KEY=您的秘钥
TEMPERATURE=0
USE_AZURE=False

除了Openai官方的接口秘钥。

当然了,如果不想在本地装那么多依赖,也可以通过 Docker来构建 Auto-GPT的容器:

docker build -t autogpt .
docker run -it --env-file=./.env -v $PWD/auto_gpt_workspace:/app/auto_gpt_workspace autogpt

这里Docker会自动读取项目中的Dockerfile配置文件进行构建,相当方便。

至此,Auto-GPT就配置好了。

运行Auto-GPT

在项目根目录运行命令:

python3 -m autogpt --debug

即可启动AutoGPT:

➜  Auto-GPT git:(master) python -m autogpt --debug       
Warning: The file 'AutoGpt.json' does not exist. Local memory would not be saved to a file.
Debug Mode:  ENABLED
Welcome to Auto-GPT!  Enter the name of your AI and its role below. Entering nothing will load defaults.
Name your AI:  For example, 'Entrepreneur-GPT'
AI Name:

首先创建AutoGPT机器人的名字:

AI Name: v3u.cn
v3u.cn here!  I am at your service.
Describe your AI's role:  For example, 'an AI designed to autonomously develop and run businesses with the sole goal of increasing your net worth.'
v3u.cn is:

创建好名字以后,Auto-GPT就可以随时为您效劳了。

首先为AutoGPT设置目标:

v3u.cn is: Analyze the contents of this article,the url is https://v3u.cn/a_id_303,and write the result to goal.txt

这里我们要求AutoGPT分析并且总结 v3u.cn/a_id_303 这篇文章,并且将分析结果写入本地的goal.txt文件。

程序返回:

Enter up to 5 goals for your AI:  For example: Increase net worth, Grow Twitter Account, Develop and manage multiple businesses autonomously'
Enter nothing to load defaults, enter nothing when finished.
Goal 1: 
Using memory of type:  LocalCache

AutoGPT会告诉你可以最多拆解为五个任务,我们可以自己拆解,也可以让机器人帮助我们拆解,直接按回车,让AutoGPT自动拆解任务即可。

接着程序会自动爬取这篇文章的内容,然后使用gpt-3.5-turbo模型来进行分析:

Goal 1: 
Using memory of type:  LocalCache
Using Browser:  chrome
  Token limit: 4000
  Memory Stats: (0, (0, 1536))
  Token limit: 4000
  Send Token Count: 936
  Tokens remaining for response: 3064
  ------------ CONTEXT SENT TO AI ---------------
  System: The current time and date is Mon Apr 17 20:29:37 2023
  System: This reminds you of these events from your past:
  User: Determine which next command to use, and respond using the format specified above:
  ----------- END OF CONTEXT ----------------
Creating chat completion with model gpt-3.5-turbo, temperature 0.0, max_tokens 3064
The JSON object is valid.
 THOUGHTS:  Let's start by browsing the article at https://v3u.cn/a_id_303 to get a better understanding of its contents.
REASONING:  Browsing the article will allow us to analyze its contents and determine the appropriate next steps.
PLAN: 
-  Browse the article
-  Analyze its contents
-  Determine the appropriate next steps
CRITICISM:  None
NEXT ACTION:  COMMAND = browse_website ARGUMENTS = {'url': 'https://v3u.cn/a_id_303', 'question': 'analyze the contents of the article'}
Enter 'y' to authorise command, 'y -N' to run N continuous commands, 'n' to exit program, or enter feedback for ...
Input:y
-=-=-=-=-=-=-= COMMAND AUTHORISED BY USER -=-=-=-=-=-=-= 
[WDM] - Downloading: 100%|████████████████████████████████████████████| 8.04M/8.04M [00:03<00:00, 2.42MB/s]
Text length: 6977 characters
Adding chunk 1 / 1 to memory
Summarizing chunk 1 / 1
Creating chat completion with model gpt-3.5-turbo, temperature 0.0, max_tokens 300
SYSTEM:  Command browse_website returned: Error: This model's maximum context length is 4097 tokens. However, you requested 4339 tokens (4039 in the messages, 300 in the completion). Please reduce the length of the messages or completion.
  Token limit: 4000
  Memory Stats: (2, (2, 1536))
  Token limit: 4000
  Send Token Count: 1472
  Tokens remaining for response: 2528
  ------------ CONTEXT SENT TO AI ---------------
  System: The current time and date is Mon Apr 17 20:30:19 2023
  System: This reminds you of these events from your past:
['Assistant Reply: {\n    "thoughts": {\n        "text": "Let\'s start by browsing the article at https://v3u.cn/a_id_303 to get a better understanding of its contents.",\n        "reasoning": "Browsing the article will allow us to analyze its contents and determine the appropriate next steps.",\n        "plan": "- Browse the article\\n- Analyze its contents\\n- Determine the appropriate next steps",\n        "criticism": "None",\n        "speak": "I suggest we start by browsing the article at the given URL to analyze its contents and determine the appropriate next steps."\n    },\n    "command": {\n        "name": "browse_website",\n        "args": {\n            "url": "https://v3u.cn/a_id_303",\n            "question": "analyze the contents of the article"\n        }\n    }\n} \nResult: Command browse_website returned: Error: This model\'s maximum context length is 4097 tokens. However, you requested 4339 tokens (4039 in the messages, 300 in the completion). Please reduce the length of the messages or completion. \nHuman Feedback: GENERATE NEXT COMMAND JSON ']
  User: Determine which next command to use, and respond using the format specified above:
  Assistant: {
    "thoughts": {
        "text": "Let's start by browsing the article at https://v3u.cn/a_id_303 to get a better understanding of its contents.",
        "reasoning": "Browsing the article will allow us to analyze its contents and determine the appropriate next steps.",
        "plan": "- Browse the article\n- Analyze its contents\n- Determine the appropriate next steps",
        "criticism": "None",
        "speak": "I suggest we start by browsing the article at the given URL to analyze its contents and determine the appropriate next steps."
    "command": {
        "name": "browse_website",
        "args": {
            "url": "https://v3u.cn/a_id_303",
            "question": "analyze the contents of the article"
 
推荐文章
睿智的伤疤  ·  光华讲坛——认知启发的视觉-语言技术-西南财经大学计算机与人工智能学院
3 月前
爱热闹的金针菇  ·  【无矶之谈】编码能力堪比Copilot、Cursor、GPT-国内可用的智能AI编程_cursor和copilot
1 月前
逆袭的生菜  ·  AI 代码生成工具深度测评:GitHub Copilot、Cursor 对比_cursor和copilot
1 月前
开心的硬币  ·  中石化信息技术中心社会招聘公告-国务院国有资产监督管理委员会
1 月前
痴情的高山  ·  MySql sql优化之order by desc/asc limit M-阿里云开发者社区
2 年前
刚毅的紫菜  ·  .net core web 项目 无法启动 没有与此对象关联的进程_mengchentj的博客-CSDN博客
2 年前
温柔的啄木鸟  ·  用LightGBM回归进行网格搜索
3 年前
今天看啥   ·   Py中国   ·   codingpro   ·   小百科   ·   link之家   ·   卧龙AI搜索
删除内容请联系邮箱 2879853325@qq.com
Code - 代码工具平台
© 2024 ~ 沪ICP备11025650号