ChatGPT in RStudio with gptstudio - Better than GitHub Copilot?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video I'll show you how to become a more efficient and more capable R programmer by using large language models inside of our studio you can use openai's gbt4 your favorite hugging face model anthropics Claude or even Google's Palm models right inside of your favorite IDE a how [Music] here we are in a fresh posit Cloud project if you want to follow at a follow along at home exactly with me you can create a free account on posit.cloud and the first thing that we're going to do here is install a number of packages so we're going to use the pack package manager go ahead and start the installation there you'll notice it's fairly quick and we also are going to use uh the use this package while that installs if pack is new to you I want to encourage you to go give it a try it as the developers describe as fast convenient and safe for package management and a new flavor on how to do package management overall you'll notice that if you were to repeat the same thing with install.packages use this it might take a substantially longer amount of time as well so this use this package it provides uh what's called syntactic sugar uh basically some some wrappers and and friendlier defaults that let you do the right thing the first time that you want to do something in R it's it's maintained by many of the many employees at posit who are living and breathing the r development life cycle okay now what we're going to do is install the uh actual package that you probably clicked on this video to to see which is GPT Studio I'm going to install the development version and that's just because the release on crayon is so new that it actually hasn't been updated in the package managers that posit Cloud uses by default so if you're following along at home you can you only need to include GPT studio in the installation here I'll go ahead and click enter while that's that's going we can jump over to the open AI playground uh you'll need to go here to generate an API key to do that go to create an account if you don't have one already you will need to add payment instructions uh you will have a free credit that you can use at the beginning here and that likely will take you a good ways once you have all of that set up click on API Keys again we're in the settings here collect create new secret key give it a name and create the key you'll copy that to your clipboard I've already copied mine and we'll jump over to back to posit Cloud hopefully the in the package installation is almost done it looks like it is and what we'll do now is we need to set this API key as an environmental variable we'll use the use this package to do so so edit our Environ we can specify the scope if we want to but the default is setting it at the user level that's good enough for us so we're going to set the variable open AI API key and oh looks like I didn't actually have my API key copied over so I'll just create this again you can see it live so it's a fairly quick process jump over to I don't apparently I unintentionally triggered one of my add-ins there okay so we'll save this and by the way don't bother freezing the video and copying my API key I intend on deleting this shortly after finishing the recording okay so we have the necessary packages installed we've set our environmental variable we can confirm that with sys.get in open AI API key there there we go uh and this serves as the authentication mechanism to query the openai API basically this is how about the app works underneath the hood we can try to launch the uh chat gbt app what I did there was hit command shift p or I believe it's Ctrl shift p on Windows uh it's prompting us to install a new package I think we're about to get an error Yep this I think is a bug within posit cloud or at least is beyond my technical capabilities all you have to do if this happens to you as well is to just leave this session click on it again and then this should work just fine you also in addition to using the command shift p to show the command palette you can go to add-ins chat GPT and this should work just fine for you as well and we can see the app here I've made this a little bit uh the the font size and the resolution a bit larger here so that uh it's hopefully easier to read but it's making a little bit more compact than what I'm typically using this chat agent here we can start off with a simple question so let's say what is ggplot2 we should see our answer streaming in right below giving us a explanation of all of this uh and there's a lot of additional customization and functionality that you can add to this overall capability so let me open up uh the settings here so you can get a sense of what these look like I'm going to make this a little wider so we can see all the settings together um you may want to go and specify instead of gbt 3.5 maybe you want to do gpt4 you can balance the quality of the model or the cost on your own there a lot of different customization options including the task so if you're using more General a question question and answering much like you would chat GPT that could be a good option for you we have an advanced developer mode this is something like if you're developing our packages this might be useful for you but if you don't like what we have over here you can actually select custom and then edit the custom prompt below I'll do something like respond in Spanish as the instructions here I'll go ahead and save this and and I'll say who in who developed it [Music] foreign and you see that it is now responding to us in Spanish the settings that we set there that would if we restart the session that's what I'll actually do uh right now just go to session restart r or command shift o if you're on a Mac for this we'll do a command shift p and then select chat gbt to reopen this and I'll say who developed ggplot2 my expectation is that this should respond to us in English this time yep if you want to change that to make these settings persist you can come in here let's select Advanced developer uh we'll say no preference on our programming style ask it to use the open AI API that's the only one we've set up so far and we'll go down and pick gpt4 so we'll save this as a default just for Simplicity of the programming um from on my side or on our side as the development team here all of these options appear but they might not all be applicable for the particular configuration that you are using so if you have any confusion please create an issue on our GitHub we'd be more than happy to help you out so what I'd like to do now is so we've saved this as default we can ask this a question of something like show me a an example and we should have some code output for us here that'd be yep so it's first telling us to install some of these packages giving us an example for how you could actually use these uh we can just just to make sure that the code is in fact functioning for us come over here oops I didn't actually copy it so uh the I do notice that while it's still running it's difficult it doesn't let you copy code so that maybe that could be a future Improvement lots of explanation that we have there we'll go ahead and copy this over hopefully it will be somewhat quick on installing all of the necessary packages that we have and once this is done I do expect a plot to show up for us here yep there we go so that one is a little boring so let's ask it make the example more exciting you'll see that we get a response from this as well foreign [Music] actually has commented out uh the code that it assumes we've already run so we'll have to wait till it's done to copy this code over but it is convenient that it breaks up these code blocks for you so you can just copy them directly that's what we'll do here copy it in [Music] and I'll say no uh looks like I hadn't actually copied so it that was my fault there or maybe I copied the wrong walk of code you're probably yelling at your screen at home realizing that I had done that okay there we go it's a little bit more of exciting of a plot not using the default theme so there's a lot of customization that you can do use the the intent here was to give you enough flexibility to have this interaction with the integrated large language models inside of our studio to be customized for your own experience so please play around with these settings maybe uh tweak the the custom prompt if that's of interest to you you there's many other API Services anthropic Azure open AI hugging face and palm these are all are a little bit different in the model X execution for example Claude from anthropic has a massive token window the new Claude 2 has a hundred thousand token window Which is far larger than most code repository so I'm excited about trying to load in my entire code repository Force maybe some challenging questions that I have to see if it can use the entire context of my project to make some recommendations for me thanks for watching this demo of GPT Studio I hope you see how you could become a better art programmer by trying this package out I would love to hear from you about your what you like what you don't like please create issues on our GitHub repo with feature requests bug reports or just a general discussion we've had a lot of fun developing this package it's a group of volunteer developers but we are eager and excited to to continue to create useful tools for working inside of our favorite IDE R studio so thanks for watching I hope to make more content to come so please like share and subscribe that could really help me grow this admittedly tiny audience that I have today so thanks for for being with us today and I hope to see you again soon thank you
Info
Channel: James Wade
Views: 1,093
Rating: undefined out of 5
Keywords:
Id: rZB0_53Cm1w
Channel Id: undefined
Length: 11min 33sec (693 seconds)
Published: Wed Jul 12 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.