GPT Engineer: A short prompt to build a complete APP

If you have a good idea and enter the prompt, you can get a complete APP.


GPT Engineer is a new player in the open source space, capable of creating a complete app from a short prompt. This article explains what GPT Engineer does and how to install it on your computer. Additionally, we will use GPT Engineer to create a working Plotly Dash application template. Let's see how it performs!


What is GPT Engineer?

It is an open-source project that demonstrates the capabilities of the GPT-4 and GPT-3 language models. Its focus is on creating complete applications from a single prompt. You simply specify what you want to build and AI will generate the application for you.


Before we start the installation, please review the technical requirements.

skills requirement

You need to meet the following prerequisites:

Python (≥ 3.10) and Git installed

installed conda and pip

Access to a bash terminal (macOS, Linux, or Windows)

A code editor of your choice (we use VSCode)

We tested on macOS Ventura 13.4.

default setting

Enter the following command in the terminal:

Create a conda environment (env): conda create -n gpt-engineer python=3.9.12 -> Select y in the question "Proceed ([y]/n)?".

Activate the conda environment: conda activate gpt-engineer

Install GPT Engineer

We will install GPT Engineer in three steps:

Step One - Clone the Repository

Visit the GPT Engineer repository on GitHub and click the green button "Code". Copy the link to the repository. Then open a terminal window on your computer and navigate to the directory where you want to save GPT Engineer. Then clone the repository with:

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

You will now see a folder named "gpt-engineer". This folder contains all the files in the GitHub repository. Next, we will install the required dependencies.

Step Two - Install all required dependencies

First, we go into the "gpt-engineer" folder. Do it with the following command:

$ 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. It will take some time! Now we are ready to setup GPT Engineer.

Step Three - Setup GPT Engineer

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

0b636080a82756a34e579aa1402d508b.jpeg

Click "Create new secret key" and give your API key a name. copy it. Be careful to save the API key as it will no longer be displayed. You will get free $5 API access credit.

To set up your API key, enter the following command in Terminal (remove the square brackets as well):

# macOS and linux

$ export OPENAI_API_KEY=[Insert your API Key here.]


Great, ready to install! Let's run the snake example to make sure everything is working. First, open the file projects/example/main_prompt. You should see the default content. In our tests, the default example didn't work very well. Therefore, we modified the prompt. We ask ChatGPT the question: "Explain the Snake game for developers." Then paste the sentence "Create a Snake application using the Python programming language." and the output of ChatGPT into the main_prompt file.

After completing these steps, run the following command in the "gpt-engineer" folder:

$ gpt-engineer projects/example

If you do not have access to GPT-4 through the API, the program will automatically use the gpt-3.5-turbo model. If you wish, you can sign up for the GPT-4 waitlist. In this paper, we use the gpt-3.5-turbo model.

GPT Engineer will ask you some questions for clarification. Please answer these questions. In our case, it raised the following questions:

ff53cf88a4cec78b21f6f305b09b75b9.jpeg

Then, GPT Engineer will generate related folders and files. When everything is done, you can run the resulting application. You saw the result at the beginning of this article. It's amazing what you can do with gpt-3.5-turbo. Now that we have an idea of ​​how powerful AI is, it has had a lot of influence in the world today.


Let's look at another example!

Generate a Plotly Dash application

In this part, we use GPT Engineer to generate a working Plotly Dash application. First, we copy 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 into 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

GPT Engineer asked for some clarification:

a9aedd99ef593adc7193272bde5278ca.jpeg


We answer these questions and press enter. Afterwards, GPT Engineer will generate all related folders and files. Then we start the application. Here is the result:

e95b696ac24ccfeb9d8884e538ae3f84.jpeg

GPT Engineer successfully generated all files and the application is hosted on 127.0.0.1:4242. This is exactly what we want. The message "Happy Day" appears in the text, and we instruct the tool to create a popup. However, tools had problems implementing this functionality.

Overall, we can quickly generate procedural template code, and it works. This saves a lot of time! But we also encountered some problems when using the tool. We'll discuss that in the next section.


Possible limitations and errors and solutions

We noticed the following:

· Example hints are not working properly for us. Maybe it works fine with GPT-4. In this tutorial, we only used GPT-3.

· It took us four attempts to get a working Snake game. Sometimes tools implement logic incorrectly, or miss some imports across multiple files. Also, tools often don't generate a requirements.txt file. You can generate it yourself based on the information in the all_output.txt file.

· We also noticed some API errors. If you receive the following message, please wait a while and try 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.


in conclusion

In this article, you learned how to set up GPT Engineer in 5 minutes. We then discuss two examples and see the power of the model. We also ran into some issues and showed you possible solutions. Overall, we can say that this tool is helpful for generating boilerplate code. But beware! You have to check all the functionality of your code because sometimes GPT Engineer implements logic errors.


Guess you like

Origin blog.csdn.net/specssss/article/details/131640584