How To Use ChatGPT To Write Code In VSCode (Can Chat GPT Write Python Code In Visual Studio Code?)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I was just doing research on how to use chat GPT to write code and decided to make this tutorial to share with you guys in this tutorial I will be using visual studio code you know vs code in my opinion it's the best editor for writing code but it's the only coding Editor to my knowledge that has built-in GPT support well not really built in I'm just saying you can use vs code's GPT extensions in order to add chat GPT to your coding workflow so let's go ahead and get started first I'm going to open an existing JavaScript project on my C drive go to file open folder and navigate to your project folder I'll browse down to my C drive then I'll go to my projects folder where all of my coding files are this is where I have my JavaScript folder inside I have another project called YouTube don't enter the folder just click on it once and click open folder button okay now that the project is open in vs code let's add chat GPT extension for writing code go to extensions button on the navigation bar in the input Box start typing chatgpt right locate the chat GPT for writing code extension looks like there are two of them with the same name I'll pick the one that has more installations this one looks like it has 114 000 installs Okay click on install button and go back to your project just close all of these tabs that's annoying okay now that you are looking at your project here I have an empty function actually to use chat GPT for coding select the code you want to do something with right click and scroll down to where your sub menu has all of these new chat GPT options these options were added by the chat GPT for writing code extension that we added in previous step nothing will happen but don't panic this is only because we haven't added our openai API key yet go back to extensions Tab and select the installed GPT for writing code extension again here click on the settings cogwheel then select extension settings here on this page is where you add your openai key but first we need to generate it click on this open AI link to open your openai dashboard if you don't have an account yet you have to register one I highly recommend it if you want to use chat GPT for coding an openai account is essential click on create new secret key button you can use any name you want but for this tutorial I'll just name it how to use chatgpt to write code in vs code click on the green create secret key button openai will only show you this key once right now this is why it's important to save it somewhere in a safe place that's right you will not be able to copy this code again even from your dashboard this is the one-time opportunity to copy it to your settings of course you can always create another key but I'm just saying okay with the key copied let's go back to vs code paste the key into this input box just so you know every time you use GPT to write or optimize code you will be using your paid openai GPT tokens keep that in mind it shouldn't be much anyway but you can set your extension token limit here which by default is set to 1024. now select GPT model I'll leave it at DaVinci I mean chat GPT model is nice but DaVinci 003 may be more suitable for tasks that require concise responses and That's essential for writing code okay I think we're done here let's go back to our code base select the function and right click here I'm going to choose code GPT explain selection and chat GPT will explain what this code does of course this is just an empty function but this is a great way to learn how to code just be creative and ask anything you want to ask GPT any coding question right click the selected code scroll down to ask code GPT option okay I think I found it thing is I have so many GPT coding extensions installed and they all get in the way okay so how do we actually write code with chat GPT I'm going to ask codegpt to write a function that adds two numbers it's pretty simple one thing I learned with this particular extension is that if you click on the function it gets copied over to your source code I'm sure it would be a hassle otherwise imagine clicking selecting and clicking copy and paste all the time okay now I'm going to ask codegpt to write a function that draws a labyrinth I'll also ask it to use a known Labyrinth generation algorithms I don't know what to expect I'm using this for the first time myself okay on the left hand side chatgpt gave me the Labyrinth generation function the only problem for some reason it decided to write it in Python and that's okay oh and another thing the body of the function seems to be missing the actual Labyrinth generation code it did put emphasis on me saying make it random though so I have to be more careful about what I tell it to do it simply filled the Labyrinth with random blocks there is no actual Labyrinth path this doesn't mean it doesn't work I just need to get better at writing more detailed coding prompts but for now what I can do is I can ask code GPT to rewrite this function in JavaScript so this is how you write code using GPT this is the workflow asking questions copying code and asking GPT to rewrite the code again with each step save the valuable code generated by GPT and ask it to change or improve it it's a process but basically this is how using chat GPT for writing code works I will be doing more coding and AI tutorials in the future it's up to you if you want to subscribe or even like this video I'm just trying to do my best to help others learn
Info
Channel: Ghost Together
Views: 3,579
Rating: undefined out of 5
Keywords:
Id: 8F6XJ8PsMMA
Channel Id: undefined
Length: 5min 27sec (327 seconds)
Published: Mon Jul 24 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.