We’ve seen how ChatGPT can generate code for us. Then we’ve seen how Auto-GPT could make GPT-4 fully autonomous. And now we will construct entire apps with one prompt with GPT-Engineer.
How does it work? Easy, you simply must describe your project and GPT-Engineer will construct it for you.
No have to copy/paste code.
No have to create the files on your individual.
No need to establish the project environment yourself.
Here’s the best way to install and use GPT-Engineer. I’ll address all of the errors you may encounter in the course of the installation and, in case there are some changes within the GitHub repo, I’ll attempt to update this guide.
Step 1: Clone the Repo
First, we’ve to clone this GitHub repo. To achieve this, open up a terminal and run the code below.
git clone https://github.com/AntonOsika/gpt-engineer.git
Step 2: Arrange GPT-Engineer
A recent folder named gpt-engineer
will likely be created. Change directory using cd
.
cd gpt-engineer
make install
source venv/bin/activate
Note: When you get the error “No module named venv”, it’s good to arrange a virtual environment that runs Python 3 (with pip or conda), then activate it, and eventually repeat the steps above.
# pip
python3 -m venv name-of-env
source name-of-env/bin/activate
cd gpt-engineer
(same steps above)# conda
conda create --name name-of-env python=3.11.3
conda activate name-of-env
cd gpt-engineer
(same steps above)
Then we’ve to set our API key as shown below. To get your OpenAI API Key, click here.
# macOS/linux
export OPENAI_API_KEY=[your api key]# windows
set OPENAI_API_KEY=[your api key]
Step 3: Run GPT-Engineer
The way in which we interact with GPT-Engineer is thru the main_prompt
file, which is contained in the projects folder. By default, we’ve the “example” folder as shown below.
If you would like to start a recent project, just create a recent folder using the command below.
cp -r projects/example/ projects/my-new-project
Now it’s time to edit the main_prompt
file. When you open it up with a text editor, you’ll see the text below.
We’re writing snake in python. MVC components split in separate files. Keyboard control.
Those are the instructions to create a snake game in Python. You’ll be able to try it out as is, but for this demo, I’ll change the prompt to scrape my website.
Note: In case you permit the prompt as is, you must get this snake game after following the steps in the subsequent section.
Test #1: Web Scraping
Scrape the article titles from this website https://thepycoach.com/. The article titles are inside an h2 tag. Export the info right into a CSV file
Finally, to run gpt-engineer we’ve to make use of the command below.
gpt-engineer projects/my-new-project
Since my folder was named “web-scraping” the command will likely be gpt-engineer projects/web-scraping
for me.
Try the files generated!
All of the generated files will likely be in projects/my-new-project/workspace
.
Listed below are the files I got.
As you’ll be able to see I got the .py files that do the scraping part for me and in addition I got the info I wanted in a CSV file.
All the info was successfully scraped!
Do not forget that you may still encounter some errors while following every step on this guide. This GitHub project is nice but has some issues. Listed below are some I discovered.
Note 1: The necessities.txt file won’t be generated. If that’s the case, duplicate the all_output.txt
file (that ought to’ve been generated, and locate the necessities.txt section. Delete all the pieces however the libraries laid out in that section.
Note 2: When you get the error openai.error.ServiceUnavailableError: The server is overloaded or not ready yet
just try again later and it ought to be tremendous.
Test #2: Create a Web App
As we do with ChatGPT, while you edit the main_prompt
file you’ll be able to be very specific along with your prompt or not.
On this case, I’ll just type “Create an internet site about dogs” to see what it may possibly deliver without much prompting.
Listed below are all of the files I got.
Unfortunately, I’d still must do some tweaks to get the online app running, but GPT-Engineer still simplified the entire process.
That’s it! Now it’s your time to construct apps with GPT-Engineer. Let me know within the comment section whether GPT-Engineer got your request in a single shot or should you still needed to do some tweaks to get the code working.
For more information about GPT-Engineer, check the official repo.