GPT-ENGINEER: Build POWERFUL APPs with ONE PROMPT [Installation & Tutorial]

GPT Engineer is an open-source tool that builds apps from a single prompt. The demo shows installing it, setting up your OpenAI API key, and generating a joke website and Snake game. It falls back to GPT-3.5 Turbo if GPT-4 isn't available.
Chapters
If you are looking to build a product but do not know how to code, I have a great news for you. There is this project called GPT Engineer on GitHub which is currently trending which will let you build software products just using very simple prompts. This really works like a human engineer. So you will specify the requirements of your product, then the AI asks you some clarifying questions and after that it goes ahead and starts implementing those. In essence, it's very similar to R2GPT, but this is specifically geared towards software engineering and programming and actually it does a pretty good job. This project was brought to my attention by a community member in the Discord server. In this video I will show you how to install it on your local machine. Then we will look at how to properly set it up on different platforms and operating systems. And lastly we will ask it to build a very simple website for us. Now a few really great things about this project that you specify what you want to build. The AI asks for clarifications and then builds it for you. In terms of project philosophy, it's simple to get value and then incrementally build towards a user experience of high level prompting. So the user have to simply provide high level prompting and it lets you give features feedback to the AI that it will remember over time. By default this project uses GPT4 API. However, since I do not have access to the GPT4 API, I'm going to be showing you how to do the same thing using GPT 3.5 Turbo or chat GPT's API. One limitation that the authors have highlighted is chain of thought prompting is missing in this and they think that by adding chain of thought prompting it will be able to make it more reliable and probably will be able to follow prompt more closely. Now first let's see how you can install this locally. So for that you actually need to download the code base. Now there are two options. If you have Git installed on your local machine, you can simply copy the address to the repo and then do a git clone on it and clone the repo locally. If you do not have git install, you can simply download the whole repo as a zip file and then extract it and work with it. Now since I have git installed on my local machine, so I'm going to be using the first option. Next we need to clone the repo. So in order to do that we are going to be using Git clone and then in the path to the GitHub repo. So click enter and you see, it created a new directory or folder, and within this folder all the contents of the repo are present. Let me see where I am. So we need to actually move to this folder. So I'm going to type in CD and GPT dash Engineer and if I do LS now LS is basically list all the files, so it shows me all the contents of the repo. So let's clear this. I'm running this on Ubuntu using wsl, but you can do this on Windows or Mac as well. Now, in order to install all the required packages which are listed here in the requirements. TXT file, we're going to create a new virtual environment. So I'm going to use conda create end and then let's call it GPT Engineer. I have already a virtual environment by this name. So conda create n the name of the virtual environment and then the Python version that you want to use. So I'm going to be using 3.10.0. It's always a good practice to create separate virtual environments for all your projects, so you do not mess up your Python. Okay, so it's already telling me that this virtual environment exists, but in your case the output is going to be different if you do not have a virtual environment set up. So next we need to activate it. I'm going to say conda create conda activate and GPT Engineer and that will activate our virtual environment. And you can see it here. Now we will install the requirements. So to do that we're going to be using pip. So pip install R and then requirements txt when we run this, since I have already set up everything, so it tells me the requirements already satisfied. But in your case the output is going to look different. Now, before running the code, we need to set up our OpenAI API key. If you are on a Mac or a Linux machine, this is the command you're going to be using. Export OpenAI API key and then equal to your API key if you are on Windows. So you're going to be using the command set set and then the same format, right? So first we will need to go and grab our OpenAI API key. Here I am on my OpenAI's account, I created another API key called GPT Engineer. I just copied this. Now here's how you would set up your environment variable. So it's going to be export the environment variable name and then the property you want to set. As I said, this will work on Linux and Mac. If you were to do this on Windows machine, so you are going to be using sect and then OpenAI and everything that we have in here. Right? I will be removing this API key right after recording this video. Okay, so the installation is complete. Now let's see how we can run this. So before that we actually need to go to this main py. And here they have defined the model that they are using. So by default it's using GPT4 API. However, if you're like me and you do not have access to the GPT4 API yet, then we're going to be using ChatGPT, that is GPT 3.5 Turbo and I'm using the 16K version. So with this we are all set. Now, how do we create a new project and run our prompt? So they have provided this example folder. So you need to first create a folder. You can name it anything you want. And within that folder you need to put a file called main underscore prompt. Now this main underscore prompt file is going to contain your main prompt. So here in the example project, the prompt is we are writing Snake in Python MVC component split in separate files, keyboard control. Right? And you want to be as detailed as possible. Now you can run this example project, but I want to show you how to create your own. So first and foremost you actually need to create a folder. Let's call this a website. Then within this folder we need to actually create a similar file. So I'm going to just copy this and go back and paste it here. Okay, so now we will just replace this with our own prompt or requirements document. Now here is my example prompt. So write an HTML code for a website that has a single Button. Only use HTML. Do not include Java, JavaScript or CSS. When the button is pressed, it randomly shows one joke from a list of 10 joke. Show the joke as a text on the website. Do not use pop ups. Right? And then some other things that I want to include. Now the idea for the website is very simple. It's supposed to have a single button. When that button is pressed, it will show a random joke from a list of joke and also change the color of the background. Right? So now let's say you came up with the requirements. Then what you need to do is you need to go to the terminal, type python main py. This is the file we are going to be running. And then you need to provide the name of your project folder. So in this case it's website. So I'm going to say website and let's execute this. But let me take it Here so that we can see all the execution. So it says that GPT4 is not available. That's why it's actually reverting to 3.5. Then it's asking us to provide some clarification. So what should be the text content of the button? Should the jokes be displayed in a specific order or randomly, should the background color change to a specific set of colors or any color? And should the jokes be hard coded in HTML file or can be stored in a separate file? Right, so basically it's like you're working with a human engineer who is asking you for some clarification based on all the information that you have provided. Okay, so based on the questions, I came up with some answers. If you do not want to provide any answers. So you can simply type in Q and then it will move on. All right, so now for some reason, whenever I give it clarifying answers, so it displays this. No. And now let's say there is nothing else to add. So I'm going to type in Q and then click Enter. And after that you actually see that it started creating the code. But. Right, so it's showing us the code here. It's created an array which has all the jokes. Right. So I'm going to just wait for it to finish. Okay, so it seems like it finished writing the code. Now if we go back to our website folder, you see it created a couple of more folders. One is memory and then the second is workspace. Okay, so I simply open the folder. If you go to workspace, there's a text file which basically lists everything that was displayed. Right. So we can just close this and then there is this HTML file. It's actually created a HTML file. So it's not like a file format. So we need to actually give it a file format. So I'm going to just call it website HTML. I believe if you're using GPT4, it might be better at following the instructions. But let's see how the website looks like. Okay, so here is our simple website. It put a title, joke generator, and then there is a small button press me. So let's press this. Great. So it is showing a joke with each press and also changing the current. So it seems to have fulfilled all the requirements. This is awesome. Now this was a very simple example in which we asked it to create a single file, but it actually works, which is pretty awesome. Now you can build more complicated products with this. So as an example for more complicated project, let's look at the example Snake game. So what I'm going to do is I'm going to type in Python and then main PY and now we want to run the example project, right? So let's run this. And now it's asking me some clarifying questions. Can you provide more details on the specific hemisi component that need to be split into separate files? And are there any specific keyboard controls that need to be implemented? I asked ChatGPT to write a requirement document for the Snake game for an engineer to implement in Python. So I'm going to simply copy all this and take this to our GPT Engineer. So I'm simply pasting everything. And now it started coming up with the implementation. So the core classes are going to be model, view, controller, utility, then there are constants and it started implementing main PY function and then there is another model PY function and so on and so forth. So when I ran this example, it only created this all output.txt file which has all the code with corresponding file names. So what I did was I went ahead and created different files, for example controller PY and then simply copy the code from here and paste it in there. Then similarly for main PY I did the same thing. So there are a total of four files that I created. And now we actually move to that example workspace folder. Let's try to run the code and see if we can actually run our game. So I'm going to say Python main main py. Okay, and let's see. So in this case it's a text based game. It didn't create the graphical user interface. But let's say this is the Snake head. In order to move it, I'm going to use these. So let's say up and it it's moving up, up. Right, you can see it's actually moving. That's pretty nice. And now we need to turn it right. Yay, this works. Actually this is pretty good. Okay, so left and yeah, now you can also see that the length of the Snake is actually increasing. So this is pretty great. Probably in the requirements I should tell it to implement it using graphical user interface. There is a package called pygame which can be used to implement games in Python. But overall this is pretty neat. And the fact that I didn't really have to make many changes in order to make it work is pretty awesome in itself. Overall, GPT Engineer is a great project. You can implement some really complicated softwares with it. I have seen some people build some cool stuff, so it's help if you run into any issues. Check out our Discord server. There are some great people who are helping each other out, so come join us. I hope you found this video useful. Thanks for watching and see you in the next one. Thanks.










