avatarTinz Twins

Summary

GPT Engineer is an open-source project that generates complete applications using a single prompt, showcasing the capabilities of GPT-4 and GPT-3 language models.

Abstract

GPT Engineer is an open-source project that demonstrates the potential of GPT-4 and GPT-3 language models by creating complete applications with a single prompt. The article discusses the functionality of GPT Engineer, its installation process, and provides examples of its usage, including generating a snake game and a Plotly Dash app. The article also highlights some limitations and errors encountered while using the tool, emphasizing the need for users to check the generated code for logic errors.

Opinions

  • GPT Engineer has the potential to save time by generating template code quickly.
  • The tool can sometimes implement logic errors or forget necessary imports.
  • The tool may not always generate a requirements.txt file, requiring users to create it manually.
  • Users may encounter API errors, which can be resolved by retrying the request or contacting OpenAI's help center.
  • GPT Engineer's performance may vary depending on the model used (GPT-4 or GPT-3.5-turbo).
  • The tool can be helpful for generating template code, but users should thoroughly check the functionalities of the code.
  • The tool's performance may improve with GPT-4 access, as the example prompt did not work with GPT-3.5-turbo.

GPT POWERED APP BUILDING

GPT Engineer: Build an Entire App with a Single Prompt

Have an idea. Enter a prompt. Get an app.

Photo by Mohamed Nohassi on Unsplash

A lot has happened in the AI field in the last six months. ChatGPT can write code and support developers in programming. PrivateGPT can analyse your documents locally, and AutoGPT can perform tasks autonomously. Now a new player from the open-source sector enters the market: GPT Engineer. This tool can create complete applications with a single prompt. Find out how well it works in this article!

This article describes the functionality of GPT Engineer and how you install it on your computer. In addition, we will create a working Plotly Dash app template using GPT Engineer. Be curious! You don’t have to do much. Follow the step-by-step instructions in this article, and GPT Engineer is running in 5 minutes. Let’s start!

🤔 What is GPT Engineer?

It’s an open-source project for showcasing the capabilities of GPT-4 and GPT-3 language models. The focus is on creating complete apps with only one prompt. You specify what you want to build, and the AI generates the app for you. When you follow the example from the GitHub repo, you get a snake app. We had some trouble with the default prompt, so we wrote our own prompt. Here’s the result:

AI-generated snake game (GIF by authors)

Wow, we create this with a single prompt!

Before we start with the installation, check out the technical requirements.

✅ Technical requirements

Prerequisites

You will need the following prerequisites:

  • Installed Python (≥ 3.0) and Git
  • Installed conda and pip
  • Access to a bash (macOS, Linux or Windows)
  • Code editor of your choice (We use VSCode.)

We tested it on macOS Ventura 13.4.

Initial Setup

Enter the following in your terminal:

  • Create a conda environment (env): conda create -n gpt-engineer python=3.9.12 -> Answer the question Proceed ([y]/n)? with y.
  • Activate the conda env: conda activate gpt-engineer

🖥️ Installation of GPT Engineer

We install GPT Engineer in three steps:

Step 1 — Clone the repo

Go to the GPT Engineer repo on GitHub and click on the green button “Code”. Copy the link to the repo. Then open a terminal window on your computer and navigate to the directory where you want to save GPT Engineer. Then we can clone the repo with the following command:

$ git clone https://github.com/AntonOsika/gpt-engineer.git

Now, you see a folder “gpt-engineer”. This folder contains all the files from the GitHub repo. Next, we install the required dependencies.

Step 2 — Install all required dependencies

First, we navigate to the folder “gpt-engineer”. Use the following command for this:

$ cd gpt-engineer

Then we install the required dependencies. You can use the following command:

$ pip install -e .

It installs some dependencies on your computer. This takes a moment! Now we are ready to set up GPT Engineer.

Step 3 — Set up GPT Engineer

The GPT Engineer communicates with the OpenAI API, so you need to set your API key. You can generate the API key in your OpenAI account. Log in to your OpenAI account and create your API key.

Create new OpenAI API keys (Screenshot by authors)

Click on “Create new secret key” and give your API key a name. Copy it. Be careful to save the API key because it will no longer display. You get a free $5 credit for API access.

To set your API key, enter the following command in the terminal (Delete the square brackets as well.):

# macOS and linux
$ export OPENAI_API_KEY=[Insert your API Key here.]

Great, the installation is ready! Let’s run the snake example so we know that everything is working correctly. First, open the file projects/example/main_prompt. You should see the default content. In our tests, the default example doesn’t work fine. So we modify the prompt. We ask ChatGPT the following “Explain the snake game for a developer.”. Then we paste the sentence “Create a snake app in the programming language python.” and the output of ChatGPT in the file main_prompt.

After that we run the following command in the “gpt-engineer” folder:

$ gpt-engineer projects/example

If you don’t have GPT-4 access via the API, the program uses the model gpt-3.5-turbo automatically. You can register for the GPT-4 waitlist if you want. In this article, we use the model gpt-3.5-turbo.

The GPT Engineer asks you some question for clarification. Answer the questions. In our case it asks the following:

Clarification GPT Engineer (Screenshot by authors)

Then the GPT Engineer generates the relevant folders and files. When all things are done, you can run the generated application. You saw the result at the beginning of this article. It’s amazing what you can do with gpt-3.5-turbo. Now we have an idea of how powerful AI already is today.

Let’s look to another example!

😎 Generate a Plotly Dash App

In this section, we generate a working Plotly Dash App with GPT Engineer. First, we duplicate the folder “example” and rename it. You can use the following command:

$ cp -r projects/example/ projects/my-plotly-dash-app

Next, we paste the following prompt in the file projects/my-plotly-dash-app/main_prompt:

Create a Plotly Dash app for the web browser in Python. 
The app has one button with the label "Show message". 
Clicking on the button displays the message "Happy Day".

Then we run the new project:

$ gpt-engineer projects/my-plotly-dash-app

The GPT Engineer asks for some clarification:

We answer the questions and click enter. After that, the GPT Engineer generates all relevant folders and files. Then we start the app. Here’s the result:

The GPT Engineer generates all files well and the app is hosted on 127.0.0.1:4242. That is exactly what we wanted. The message “Happy Day” appears as text, and we instruct the tool to make a pop-up window. The tool implemented this functionality not correctly.

In general, we can generate programme template code very fast, and it is working. This can save a lot of time! But we had also some trouble with the tools. We will discuss it in the next section.

💡 Limitations and Errors

We noticed the following things:

  • The example prompt didn’t work for us. Maybe it works with GPT-4 access. We used only GPT-3 in this tutorial.
  • We needed four attempts to get a working snake game. Sometimes the tool implements the logic wrong or forget some imports in several files. In addition, the tool often doesn’t generate the requirements.txt. You can generate it by yourself using the informations of the file all_output.txt.
  • We also noticed some API errors. If you get the following message, wait some time and try it again:
openai.error.APIError: That model is currently overloaded with other 
requests. You can retry your request, or contact us through our help 
center at help.openai.com if the error persists.

🎬 Conclusion

In this article, you learned how to set up GPT Engineer in 5 minutes. Then we discussed two examples and see how powerful the models already are. We also had some issues and showed you possible solutions. In general, we can say that the tool can be helpful for generating template code. But pay attention! You have to check all functionalities of the code because sometimes the GPT Engineer implements logic errors.

👉🏽 Join our free weekly Magic AI newsletter for the latest AI updates!

👉🏽 You can find all our Freebies on our digital products page!

Subscribe for free to get notified when we publish a new story:

Learn more about us on our About page. Don’t forget to follow us on X. Thanks so much for reading. If you liked this article, feel free to share it. Have a great day!

Sign up for a Medium membership using our link to read unlimited Medium stories.

Level Up Coding

Thanks for being a part of our community! Before you go:

🚀👉 Join the Level Up talent collective and find an amazing job

Gpt
Gpt Engineer
Large Language Models
Python
Artificial Intelligence
Recommended from ReadMedium