AIDER: NEW GPT-Engineer | AI Coding Assistant | Installation & Tutorial

LARRUZ walks through installing and using Aider, an AI coding assistant that pairs with GPT-4 to write and edit code. He builds a Streamlit translation app from scratch, shows how Aider generates code and fixes bugs, and explains that GPT-4 access unlocks full features like repo mapping, while GPT-3.5 Turbo works with limitations.
Chapters
In this video, we're going to be looking at a new AI coding assistant called Heder. It's a new AI assistant that can create a complete code base for you. All you need to do is to tell it what you want to create in functionality. It's very similar to the GPT Engineer project. However, it does have some extra cool new features. You can use this with your existing code basis as well as it has the ability to automatically track any changes using Git. Now, under the hood, it's using OpenAI's models, so you can use both GPT4 as well as GPT 3.5 Turbo. Now, according to the authors, you will get the best performance if you use the GPT4 model. And the reason is the large Context window with GPT4. Now, if you have access to GPT4, the header package will use C tags. If you have access to GPT4 API, then EDIR will create a concise map of your whole repo, including all the declared variables and functions. And then it will use the CTAG library to provide these as a context to GPT4 API. Now, however, you need a much larger context window for this to work. This means that we can use the GPT 3.5 Turbo, but since the context window is smaller compared to GPT4, they have disabled the repository map feature using CTags. I do not have access to GPT4 API. So in this video we're going to be using GPT 3.5 Turbo. So for the rest of the video I will walk you through the installation process. Then I will show you how to set up new project in Edir. After that we will work on a streamlit app that uses OpenAI. At the end of the video, I will walk you through some tips and tricks. So let's get started. First, let me walk you through the installation process. So you have two options. First is using PIP and the second is you can clone the repo and do a local installation. We will be going with the first and simplest option. So here we are in our terminal. I like to create a new virtual environment for all my projects. So in order to create a new virtual environment, I'm going to be using conda. So simply type in conda create N and then the name of environment. So I'm going to call it adir. And then I'd like to provide the Python version that I want to use. I already have a virtual environment with the same name. It gives me this warning. CONDA environment already exists. Do you want to remove the existing environment? So I'm going to type in yes and hit enter. Okay, so conda is setting up a new virtual environment for us. I can type in Y and then it will start the installation process. In order to activate the virtual environment, I'm going to simply type in conda, activate adir, and you will see that the virtual environment has been changed here. Next, we need to install the aidir package. So I'm going to go back to the repo and I'm going to copy the first instruction. So we'll go back to the terminal and simply paste it. So pip, installed header, chat and hit enter. Okay, so the installation is complete and we are all set to start playing around with edir. Okay, so let me simply type in clear and you will see that I'm currently on my desktop. So first let me create different directory or folder. So let's call this ADIR and hit enter. Now we can simply move to this folder. So I'm going to type in adir and if you type in ls, it shows there's nothing in this folder. Now let's create a simple project, but before that, let's look at the documentation for proper usage. In order to use this package, you need to use the command header and then provide different files that you want to work on. Now, once you do that, these files will be added to the chat session so that the GPT can see their contents and edit them according to your instructions. Alternatively, you can simply use the command editor inside a GitHub repo and you don't have to provide any file names. In that case, it will look at all the files in the repo and start working on those. Now, for our simple app, I want to actually provide a file name. For my first application. I want to build an app that will translate text text from English to German. Okay, so it's actually telling me no OpenAI API key provided. So we actually first need to set an OpenAI API key. Okay, in order to set OpenAI API key, I'm using the export command followed by this environment variable. And next I will Simply paste my OpenAI API key. I'm working on a Mac machine. If you're working on a Windows machine, you need to use a set command. So this is going to become set OpenAI API key to your API key. All right, so I provided my API key. I will be removing this after recording this video. So now we need to run our command again. And now it tells us the API key doesn't support GPT4. So it's going to be using the GPT 3.5 Turbo instead. Now it simply displays some information so the model being used. Then it creates an empty file with the file name that we provided and it disabled the repo map. So just like using C tags because we don't have the GPT4 API, next we need to provide what we want it to create. I asked it create a streamlit app that takes an input from the user in English and shows the translation in German. And then I'm asking it to Specifically use the GPT 3.5 Turbo model for translation. Now it came up with the step by step process in order to create the app. So it says install the necessary dependencies, so we definitely need OpenAI and Streamlit packages. Then it says import the required modules, create a streamlit app. And for some reason it came up with this small piece of code. Then it showed that those instructions again and started adding more and more code. But finally it came up with this code just by looking at it. This should work. Okay, so it's asking me to actually replace your API key with the actual API key so I can do that in the code. But I'm going to ask it add my API key and then I'm going to just paste my API key and let's see if it's able to make the changes and update the code. So let's wait for it. Okay, it does seems to actually have updated the code with my new API key. This is simply awesome because you don't even have to make those changes yourself. Now one thing that I noticed in the code is that it's still using text DAVINCI003 as a model. Let's ask it to replace it with the GPT Turbo 3.5 Turbo. Okay, so I'm going to ask it. So I'm going to ask it replace the engine from text DAVINCI003 with GPT 3.5 Turbo 16K and let's see if it will be able to update the code for us. So let's see. And yes indeed, it actually updated that. Okay, this is great, but let's see if we'll be able to run the app or not. Okay, so it did create this translaterapp PY file for us. However, we need a requirements. Txt file in order to install all the required packages. So for that we will actually go back and I'm going to ask it to create requirements. TXT file with the dependencies and let's see what it does. Okay, and so it did create a requirements.txt file if you go to our folder. So it does shows requirements txt file. Now within that file we see that it's installing two different packages. One is the Streamlit and other one is OpenAim. However, the version that you see here, these are very old versions of these packages. And I think it has to do with the fact that the training cutoff date of ChatGPT or GPT4 was way back. I'm going to remove these package versions from here and save the text file. Okay, so I asked it how to actually use the requirements.txt file. So here are the instructions that you can use to install packages from the requirements file. And it actually even told me to make sure to have the correct version of Python installed. So either use pip or pip 3 depending on the version that you have installed. And it also gives me these the instructions to run the Streamlit app. This is extremely helpful. Okay, now we are all set. So I'm going to go and open an instance of Visual Code Studio and here we have the file structure that we saw. I like to create virtual environments for all my projects. I created my virtual environment and have simply activated it. Now we need to do the installation first. So we will say pip install dash r requirements. Txt and run this. It will download and install both packages. Okay, awesome. So we are done with the installation. Okay, so I had to ask it to make two changes. First was to replace the GPT 3.5 terminal model again with Textver G003. And the reason was that this specific API call is not compatible with that model. And the second was to actually include a prompt specifically asking to translate a given English text into German. This was missing in the initial implementation. Now let's clear this. And we were going to run the app using streamlit run and then the file name. So translate app hit enter. Okay, so it started a web server which is running at this address on the local host. And you can also access it over the network with this API address. So let's go to this web server. So here we have our app which is running. Okay, so here's the web server. It added a nice title to the web page, so let's use this sentence. So hi, how are you doing today? Oh wow, it worked. So we did get a response and seems to be in German, but let's confirm it now. Indeed it's in German. Since Google Translate detected this is German and the results are actually accurate. Now just to demonstrate that you can iterate all your code base, I asked it add the ability to translate text into French and add a radio button for the user to select a language. And then it went ahead and made all the required changes. So here instead of just a German language, now it gives you the option to add the select and German and French and it even updated the title of the page. So instead of English to German translation, now it says English translation. So here is how the final output looks like. So now we have two radio buttons, so let's use the same text. So first let's see if it can translate into genuine. Let's see French. And here we have a French translation. This is pretty neat. So this shows you that you can create code bases and then iterate on them using this wonderful and helpful aidr package. Now in the last section we're going to look at some tips which can help you get the most out of the adder package. Now first tip is that it's actually better to manually add files that you want to change in your project for it to help the most. Second, it's best to perform changes sequentially in smaller steps. You do not want it to create all the changes at once, but just think of it as a junior developer and you provide step by step instructions. You can use the run command to run tests, linters etc. And show the output to GPT so it can fix any issues. Now one feature which I personally like the most is the ability for it to learn from document snippets. So if it's making API calls in the wrong way or wrong arguments, simply provide some documents or examples and it might be able to fix the API calls or some other issues in the code. This is actually a great project and a stepping stone towards the AI's ability to create whole code bases. Just keep in mind that it's still an early prototype, so it will definitely make some mistakes along the way. But projects like AutoGPT, GPT Engineer and now ADIR simply shows us what is possible. I hope you found this video useful. Thanks for watching and see you in the next one.










