Auto-GPT的安裝與使用
Auto-GPT(https://github.com/Significant-Gravitas/Auto-GPT)讓使用者建立目標後,會不斷思考如何完成任務,經過不斷跟自己對話改進結果,使用Google搜尋與ChatGPT完成目標,中間不需要人為插手。
安裝環境Windows11+ Anaconda(https://www.anaconda.com/download)+Python3.10
需要OpenAI API key(https://platform.openai.com/account/api-keys)
安裝Auto-GPT
Step1)筆者安裝anaconda,使用conda建立虛擬環境,目前Python要求3.10以上。
#conda create -n gpt python=3.10
Step2)使用git(https://desktop.github.com/)下載Auto-GPT的原始碼,並安裝所需python模組
#git clone https://github.com/Significant-Gravitas/Auto-GPT.git
#cd Auto-GPT
#pip install -r requirements.txt
Step3)拷貝.env.template到.env
#copy .env.template .env
編輯.env,修改以下,加入OpenAI API key
OPENAI_API_KEY=sk-YourAPIkey
Step4)執行Auto-GPT
#python -m autogpt
執行過程
Step4a)需要輸入AI NAME、機器人的用途、建立最多五個目標。
Warning: The file 'AutoGpt.json' does not exist. Local memory would not be saved to a file.
NEWS: Welcome to Auto-GPT! We'll keep you informed of the latest news and features by printing messages here. If you don't wish to see this message, you can run Auto-GPT with the --skip-news flag
Welcome to Auto-GPT! run with '--help' for more information.
Create an AI-Assistant: Enter the name of your AI and its role below. Entering nothing will load defaults.
Name your AI: For example, 'Entrepreneur-GPT'
AI Name: Bot
Bot 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.'
Bot is: 蒐集程式範例的機器人
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: 蒐集10個C++條件判斷範例程式
Goal 2: 蒐集10個C++迴圈範例程式
Goal 3: 蒐集10個C++陣列範例程式
Goal 4:
Using memory of type: LocalCache
Using Browser: chrome
Step4b)過程中會不斷出現THOUGHTS->REASONING->PLAN->CRITICISM,使用者可以決定要同意幾個的這個過程,例如5次輸入「y -5」,接下來5次都會自動執行,不會再詢問,這過程中會使用API key的token產生費用。
THOUGHTS: I think I should start by collecting C++ conditional statements examples.
REASONING: I should focus on one task at a time, and since I need to collect 10 examples of each type of program, I should start with one category at a time.
PLAN:
- Use 'google' command to look up examples of C++ conditional statements.
- Store each example in a file called 'conditional_statement_example_{number}.cpp' where 'number' is an integer.
- Repeat this process until I have collected 10 examples.
CRITICISM: I need to make sure I save the files to the correct location so that I can easily retrieve them later.
NEXT ACTION: COMMAND = google ARGUMENTS = {'input': 'C++ conditional statement examples'}
Enter 'y' to authorise command, 'y -N' to run N continuous commands, 'n' to exit program, or enter feedback for ...
Input:y -5
Step4c)五次結束後在,在Auto-GPT\auto_gpt_workspace\conditional_statement_example_1.cpp的檔案為Auto-GPT所蒐集到的條件判斷程式,如下。
Step4d)過程中所有紀錄在Auto-GPT\log\activity.txt