Mastering OpenAI Python & JavaScript APIs - ChatGPT, Dall-E, Whisper & Prompt Engineering

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] perfect [Music] [Applause] [Music] [Applause] [Music] he [Music] [Applause] [Music] [Applause] [Music] again suin and W to YouTube channel so in this video we are going to be using the open AI model models but what I want you to keep in mind is that you don't have to pay for anything if you want to pay for a models you totally can but throughout the course we're going to be using all of the models totally for free and by the way I'm going to also tell you like how you're going to be using a shair GPT 4 and also if you want to use the dolly 3 so you can totally do that but now let's talk about what you will learn in this course so in this course we're going to be first of all starting from the chair GPT model and we're going to be using that for the chair completion then we are going to be jumping into the Del and it's going to allows us to make a realistic images after that we're going to be jumping into the whisper model it's going to allows us to make text to speech and also speech to text and finally we're going to be using all of that models in JavaScript as well so if you guys don't know what a JavaScript is you don't have to worry about that and finally we have a big section on Prom engineering and trust me there are a lot of thing that we are going to be covering throughout the course but now let's talk about what you have to know before jumping into this course so you just have to know the Python programming language and if you guys don't know what a python is so here you can see I have a complete course on there and this course is also going to be coming on this channel as well so here you can see I have a lot of courses right here and if you guys don't know what a JavaScript is so here is the JavaScript course so yeah that's that and finally the final thing which I want to mention is that I don't have any Instagram account please don't follow me on Instagram because I don't have any Instagram account yeah let's get into the course now let's talk about the open AI models so open a is a research company focus on artificial intelligence they are particularly well known for their development of a large language model so what do I mean by a large language model or llms LM is a fancy way of saying a computer program that is really good with a language just like we learn a language by reading and listening a lot these programs are also trained with a massive amount of textual data to understand and even create a language okay so this is what llm is but there is also a huge misconception between the generative Ai and the llm so what do I mean by a generative AI generative AI is a broad term for any AI that can create a new things for example like art music text and even a code something which we are going to be discussing throughout the course but you don't have to worry about that for now so I want you to keep this sentence in mind so it's like a big tool boox with many different creative AI tools okay so this is just a basic of a generative AI but now let's talk about the llm so these are a specific type of generative AI that focus on creating and understanding a human language they're like a really powerful Tools in a generative AI toolbox specialized for only working with the words okay so yeah that was a lot of theory but now let me just get into the actual content so the first thing which I want you to is that I want you to come to this platform. open.com and this is the openai developer platform and throughout the course we're going to be covering all of these topics like text generation and we are going to be learning a lot about from engineering and we're not going to be covering embeddings in this course because this is a huge topic which we're going to be learning in my Lang chain course but you don't have to worry about that for now we're going to be covering topics like text to speech image generation we are not going to be covering a fine tuning we are going to be also covering like text to speech as well so if you guys want me to cover a vision I'll make a separate video on that but throughout the course we're not going to be also covering this uh topic as well okay so what I want you to do is that I want you to just click on this login button right here and here you can create your own account if you don't have already but if you have like a Google account or maybe a Microsoft account or maybe an Apple account so you can just click on that and you can specify that and the rest is a history once you specify your credential and you successfully logged in it's going to bring you to this kind of layout right here okay so here you can see we have all of that stuff right here but now in this case we have like this document mentation and throughout the course we're going to be covering almost all of these documentation and I'm not going to be showing you this documentation because I like to code instead of showing you this documentation so if you want to come to this documentation so yeah here it is and you can also click on this API reference and here you can learn more about that like you have to install the open Ai and this is how you're going to be installing there for the nodejs and so on and so forth but you don't have to worry about that for now okay so what I want you to do is that I want you to just click on this playground right here you can can select your model which you're going to be using and by the way we are going to be using a gbt 3.5 turbo and you can choose whichever model that you like the reason I'm using a chair GPT 3.5 turbo is that this is totally free and it's going to give you a lot of credits and also a great results as well you can also specify the temperature if you wanted to p and these are all the perimeters which we are going to be covering throughout the course but you don't have to worry about that for now then we have assistant we can also compare uh two models like we have a GPT 3.5 turbo and we can also choose like I don't know maybe uh I'm going to just choose like I'm going to give it the prompt of like I don't know maybe hello Word program and also Define there so now let me just click on this run button so yeah this is how you're going to be comparing two models if you wanted to now let me just click on this completion and here you can also provide your own prompts and you can test all of them out by yourself okay so yeah there are a lot of things to cover but we not going to be covering these topics so now let's discuss the main topic of this section which is called the API keys so now let me just click on the API keys right here and here you can see I don't have any API key right now at this point but if I want to generate API key I'm going to just click on this create a new secret and here you can see it's going to ask me to provide some sort of a name for there so I'll just provide like demo you can give it any name that you like now let me just click on create a secret key so now let me just click on there and here you can see API key is now generated successfully but but what I want you to do is that I want you to just click on this copy right here don't forget to copy your API key let me just say that once again do not forget to copy your API key and also don't share this API key with other and also let me just say there once again you will never share this API key with anyone and that also means like whenever you are pushing your code to your GitHub repository you will have to secure your API key so that no nobody else can use that okay so I want you to keep that in mind and now let me just click on there I'm going to just create a new file right here and now inside this file I'm going to be storing my API key right here so now a lot of people will ask me hose you already show us your API key I can totally steal there and I can take all of your credits and you are telling us not to share this API key with anyone so what's the point of telling me all of that okay so now I'm going to just click on this done right here and here you can see this API key is now successfully generated right here by the time you are watching this video this API key will be totally deleted which means like any website or any application is using this key will no longer have access to this API key so now let me just create a new one because I cannot delete that right here because I only have one API key so I'm going to have to generate another one to delete this existing one so I'm going to just click on there and now let me just give it the name of like demo 2 or something like that create a secret key and here you can see it's going to take a bit of time now let me just copy there and once I copy there now let me just click on this done button right here I can now totally delete this API key so I'm going to just click on this uh basket icon right here and now let me just revoke the key okay and once I do here you can see that API key is now successfully gone and now I'm going to just replace that with this new key right here so say bye-bye to this older one and now let me just replace that right here with this new one so this how we are going to be generating our API key but now let's talk about the usage so now let me just click on there and here you can see I use this API for a lot of things so when I was making this course I use this API for a lot of things like for the image generation and also I provided a lot of prompts and for the voices and whatnot so I only use $0.21 and whenever you create your open AI account it's going to give you $5 totally for free okay so it's going to give you $5 totally for free and now let me just show you the pricing and and trust me it's going to surprise you okay so now let me just go to this price in right here I'm showing you this but by the time you are watching this video this information will be totally changed okay so I cannot guarantee like by the time you're watching this video uh the pricing will be totally the same so I want you to keep that in mind okay so in this course we're not going to be even bothering getting a CH gbt 4 because I want to make this course accessible for everyone so we are going to be using the free one here you can see if you're using a CH gbt 4 Turbo for 1 million tokens and by the way you don't have to worry about the tokens for for now because we're going to be discussing tokens in a really great detail but later in this course but not right now okay so for 1 million token input we only have to pay $10 and for 1 million tokens output we are going to be only paying $30 if you're just using a CH gbt 4 not a turbo so these are the pricing for this so I'm not going to read through all of them but throughout this sces we're going to be using CH gbt 3.5 turbo for 1 million tokens we only have to pay $0.50 okay and for 1 million tokens uh for the output we are going to have to only pay $150 and throughout the course you don't have to pay for anything why is that because whenever you create the open a account it will give you $5 totally for free so yeah what I want you to keep in mind is that you don't have to pay for anything to watch this course and yeah and if you're using the assistant API so these are the pricing for that if you're doing a fine tuning yeah these are a lot of prices right here if you are using a embedding model something which we going to be discussing in my upcoming courses but not right now so these are the pricing for there and finally we have a base models like D2 and we also have a page right here so these are the pricing for that so yeah that was the basic introduction of all of that theory and what I want you to do is that I want you to create your own API key because we're going to be getting into the coding right right now in the beginning of this video I mentioned that for the first portion of this course we going to be using a Python programming language so that also means that you're going to have to install that in your machine if you did not install a python in your machine so the first thing which I want you to do is that I want you to go to this python.org and then H your mouse over to this downloads and click on this python 3. whatever version it is okay so I want you to download and install there and once you do now the next thing which you have to do is that you will also need some sort of a place where you're going to be writing your code so I will highly recommend to install a vs code in your machine if you want to use other products like jet br's ID or there are a lot of them out there so if you want to use that you are more than welcome to use that but I will highly recommend you to use a vs code so once you come to this link which is a code. vs code.com so here is the landing page of a vs code so it will automatically detect your operating system but if it didn't you can just click on this drop down menu can download there for the Mac OS for the windows and also for the Linux as well so I want you to download and install that as well so now let me make a set of photo recording Journey so I'm going to just create a folder with the name of like open AI you can give it any name that you like and now let me open this folder in my vs code so I'm going to just right click on there and open that in my vs code and here you can see I have this folder right here and chances are your us code will not look the same like mine because I have changed a lot of stuff inside there so now let me just create a file I'm going to give it the name of like index. P because we're going to be working with the python so the first thing which you have to do the we have to get our API key and we already got there so I'm going to just copy every single thing from here now let me just place there and comment this line out so that's the first thing now the next thing which you have to do is that we have to install the open AI package in our machine and how we are going to be doing that to do that we're going to be using pip install and then the open AI come on open AI package so now let me just copy there and I'm going to open my terminal right here and now let me just run this Command right here so I already installed it and now let me just hit right here so here you can see it's going to give us like a requirement already satisfied because I already installed it in this area right here okay so in your case it's going to take a bit of time to install this package in your machine so that's then now let me just remove that from here and now the next thing which you have to do is that we have to import the open AI come on open Ai and now let's just import the open AI Constructor from here okay so we just have to write this line of code the first thing which you want to do is that you want to import something from the open AI package and then something will be or open AI Constructor so now that we successfully import that right here so now let me just make a instance of there okay so now let me just write like open Ai and now let me just call it right here and here you can see it requires a few parameters the first thing it requires is the open AI key then it also requires the organization the base URL and the timeout and so on and so forth so we are now only interested in providing like API key okay so now let me just write like API key right here inside there so I'm going to just write like API key key and now let me provide my API key right here inside the codes and now let me just copy that from here once again I don't know why I just delete that but now let me just place it right here let's just go back and now we have to store in some sort of a variable so I'm going to just give it the name of like client and you can give it any name that you like okay so in my case I'm going to just give it the name of like client and there you have it so now let me just print this out so we have a client let me just save this file and now let me just run there it's going to just give us like this something which means like yeah our open air is now working totally correctly okay so now let me just clear this out and now the next thing which I want to do is that I'm going to just remove that from here let's just use our Chad GPT API okay so we are going to be using the GPT 3.5 turbo and how we're going to be using that so now we store the response of this open AI Constructor inside this client variable so I'm going to copy there and now let me just place it right here so if I just write a DOT and here you can see we have the API key we have the audio and we have a few things right here and I'm only interested in this chat so I'm going to just click on this chat right here now the next which I want to do is that I'm going to just write the dot once again and here you can see we have a completion we have the wrw response the streaming response and we have a lot of things we are only interested in this completion so now let me just select there and now finally we just have to write a DOT and we have to select this create method on this so now let me just execute this method and now this method requires a few parameters so here you can see it requires the model as a string it also requires the frequency something which we going to be discussing later but not right now and so on and so forth so you know what for now I'm not going to explain all of their parameters but I'm going to just P like two perimeters and I'm going to explain that in a few seconds so now let me just proide the model like which kind of model you want to use so we're going to be using like GPT and then we're going to be writing like d3.5 and we are going to be using the turbo okay so now we just have to write that so that's going to be the model which we are going to be using for our application now let me provide a comma Now the next parameter which we have to spef ify is the messages okay so now messages will be now equals to the list and now inside this list we're going to be passing our dictionary as a response okay so don't worry about all of that stuff which I'm writing right here like don't worry about the model and also don't worry about the messages this is going to be something which I'm going to be explaining in a few seconds but I want you to just give me a bit of time okay so now let me just provide like rle and which kind of role that we want we have assistant we have a system and also the user so I'm going to just specify the system in this case now let me just provide a comma and now the next we have to do is that we have to specify the content and content like that and now let me just provide my own prompt right here like which kind of prompts we want to provide so I'm going to just write like what do you think 2 + 2 is okay I guess that's going to be fine and now the next thing which I want to do is that I want to store this response in some sort of a variable so I'm going to just write like response and now let me just store that right here I'm going to copy that and finally we just have to print this out so I'm going to just write like print and response let me just save my file and now let me just run my code right here okay so here you can see it's going to take a bit of time and we are now getting some sort of error at line five so now let me just check this out and Yeah to r instead of Tob we're going to be writing a turbo so t b so now let me just save my file and rerun there and what I want to do is that I want to run there and first of all let me just clear this out and now let me just rerun that once again so here you can see it's going to gives us this response right here so we have a chair completion we have our ID and we have a lot of stuff which we are not going to be inspecting right now but what I want to show you is that it's going to giv us this response right here oh my God there we go so here you can see we have a content and that 2 + 2 is equal to 4 so it's going to give us this response and there you have it okay so now if you want to get the specific response so for there we're going to be just writing like response and by the way I also changed this response right here that was a misspelling but now I just Chang that and now for this response we're going to be getting the choices let me just show you there and we are now getting their choices come on let me just show you there okay so we are now getting this choices which you can see you know let me just search for the choices which you can see right here so we have these choices right here and now inside these choices we are only interested in the first one and we are going to be getting the message from there so we are going to be just writing like the first thing and now let me just write a message and then finally we're going to be getting only the content okay so now let me just stor in some sort of a variable like message and now let me just copy this message from here and now let me just place it right here semi file and now let me just rerun there for the final time so it's going to only gives us that response right here like 2 + 2 is equal to 4 which is super amazing so this is how we are going to be using our chair gbt API but now let me just show you all of their parameters it requires so you know what let me just break this down for you so before I show you the perimeter first of all I want to talk to you about something called the tokens so when we provide a prompt to our open AI models they comes something called the tokens so what in the world are tokens tokens are like a tiny pieces of text that open AI uses to understand and also process the information and they can be individual words part of a word or even a special character so that's just a basic definition of a tokens but now let's talk about the money and by the way you don't have to spend any money throughout the course but now let me just talk about it open AI uses those token as the unit for building their services and that also means that you get Char based on a total number of token used in your request and also the response you got back okay so yeah now let me just show you there in action so here you can see I have this tokenizer right here and if you want to come to this same link so you just have to write like uh platform. open.com and then tokenizer and here we're going to be passing some sort of a promt and our promt will become a token so you know I'm going to just write like uh what do you think 2 + 2 is come on is there we go so so here you can see our response is now becoming something called the token so this is going to be one token this is going to be another token and so on and so forth so here you can see we're now getting like this prompt which we specified right here we used 27 characters and it generated 11 tokens out of our Tex okay so yeah this is how token works and yeah you can also choose different models like CH gbt Legacy I me like free Legacy and it's going to make it like nine tokens and 27 characters totally the same so that's there but now let me just show you the pricing okay so here you can see I already show you there but now let me just show you there once again if you're using this faster model which is a gb4 turbo so for 1 million token let me just zoom in a bit by the time of recording this video these are all the prices but I don't know if you're watching this video in the future like I don't know maybe in 2025 or something like that their prices will be totally changed so yeah this is going to be for the first model then for the second model once again for 1 million tokens as an input we're going to be getting charged $30 and for the output it gives us is going to charge us $60 and throughout the course we're going to be using uh GPT 3.5 turbo and yeah for 1 million tokens is going to only charge 50 cents okay so that's not even a dollar okay so yeah for 1 million output tokens we're going to be charged $150 so yeah if you're using a assistant API or find tuning or embeding or some other models like denture or something like that and by the way for the image models it's going to take a bit more money than the chat models right here okay so you can see like for the resolutions something which we're going to be discussing later in this course for specific resolution of image it's going to charge us like different kinds of money right here okay so yeah that was the basics of tokens and you know what let's get into the coding so now let's talk about a basic perimeter which our model will take and there are a lot more perimeters than that something which I'm going to be showing you throughout the course but you don't have to worry about that for now so the first one we have is a model and as the name suggest that this is going to be the name of our model like if you want to use GPT 3.5 turbo or GPT 4 or GPT 4 Turbo or maybe DCI or B or something like that okay so this is going to be the name of our model now the next one we have is a messages and it's going to be a list of messages object or in our case a list of dictionary so each dictionary will require two Fields so the role and also the content okay so the role will be the messenger for example if you want to use the system user or assistant something which I'm going to show you there in a few seconds so now the next one we have is a content and content will be the actual prompt like what do you want our model to do okay so now let's just discuss the system user and assistant the system role is used to set up the behavior for or assistant for example we can specify the personality of assistant or instructor to follow some sort of a specific guidelines now the next one we have is a user the user role is used to provide a requests or commments for assistant to respond to and then the final one we have is assistant and this is going to be the output which we are going to be getting from the chair GPT or from our model okay so that's that now let's just discuss the max token so as we just learned a few seconds ago that whenever we provide some sort of a prompt or prompt will become a token but in some situation we would want to work with a lot of data let's suppose we build some sort of a web application and that application uses the GPT 3.5 turbo so a lot of people can come to our website and they can provide like different kind of Articles and different kind of things and they can ask our model to summarize all of that so that's going to be requiring a lot of tokens because article and PDFs are a huge thing and we just saw that how much tokens it cost for a lot of prompts Max token as the name suggest that it will set the maximum number of generated token in the chat completion Okay so something which I'm going to be showing you in a few second but you don't have to worry about that for now now the next one we have is a stop and stop specifies up to four sequences where the API should stop generating the tokens now the final one we have is the n and it generate a specified number of chart completion choices for each inputs so you know what let me just show you all of them so here what I want you to do is that I want you to just click on this icon right here and once you do then I want you to click on this API reference and here I want you to just click on this chair here you can see it's going to show you all of that uh perimeter right here so the first one we have is a message and it is now required like you have to specify there the next one we have is a model and it is also required and we have these few of them if you want to learn about that you totally can but if you don't want to learn about that you don't have to okay so here you can see we have a maximum token and we have a n and so on and so forth okay so you know what let me just write some code and then you'll get to know what I'm talking about so here you can see back to our code okay so now here you can see in this case let me just zoom in a bit in this case we are using a GPT 3.5 turbo but we are not just limited to that we can use different kind of models so if I just click on that then I can go ahead and go to the text generation so we have a lot of models right here you can use the GPT 4 gp4 Turbo or GPT 3.5 which we are using right now or you can also use this bage or D Vinci okay so yeah in this case we are now using uh GPT 3.5 turbo now we are telling our llm to use this specific model okay now the next one we have is a messages and it requires a dictionary or object whatever you want to call that for each dictionary we would want to provide a role and the role can be either a system or user or assistant so you know I'm going to just stict to the system for now and I'm going to just make it that you know let's just remove this problem you are a language translator okay so now we are working with the system and we are now telling our model that you are something like you are a language translator okay so now let me just duplicate this line of code let me just remove that from here and I'm going to also change the role to the user so now let me just provide a user right here and now I'm going to give it the actual prompt right here I'm telling my model that you are a language translator and now I'm specifying the actual prompt right here okay so I'm going to just ask it to like uh translate English to Chinese or something like that and I'm going to just write an animal so I only want you to translate the animal word to Chinese language so now let me just go back and we cannot run this code by using the code Runner we're going to have to use our own terminal right here okay so now let me just WR LS so here you can see we have this index. P right here and now if I want to run that let me just zoom in a bit so now if I want to run that so I'm going to be using like Python and then index. p and now if I hit enter so let's just wait for that and here you can see it's going to give us third response right here and why is that because now we are extracting that specific response content and we are now storing the inside a message so that's why we are now getting this message right here or we can just comment this line out and we can just get our entire response so now let me just print this out and print out the response there we go which is going to be the response of this Cod right here so now let me just save this file and now let me run there and here you can see it's going to gives us this entire response right here like we have a choices then we have a finish reason stop and we have a index and we have uh different kind of things right here we can also see our model like we're using GPT 3.5 turbo and here you can see we will get our actual data right here you know let me just highlight that for you here you can see we are now getting our actual response there we go okay so then then now let me provide that more perimeters so I'm going to just write like I don't know Max uh tokens if I just write Max tokens it's going to be equals to 2,000 by default I guess it's going to set to 16 I'm not quite sure about that but I guess maybe by default it's going to be set to like a 16 or you know let me just delete this line of code from here and I'm going to just specify like uh show me come on show show me the or you know what give me the list of 20 uh popular PC games I guess that's going to be fine so I'm going to just remove the max content from here I mean like Max token from here let me just sa my file and go back and let me just uh comment this line out and let me uncom these line out right here it's now let me just semi file and run them so watch what happened oh it did gives us all of that funny games right here so you know what I'm going to just ask it to give me I don't know maybe uh 100 or you know what not 100 or 50 would be fine so now let me just save them and now let me just run there and let's just wait for it wow it is giving us all of that 50 games right here come on I want you to give me all of that you know I'm going to just change that to like some other model okay so let me just change that to some other model like d Vinci I guess I'm going to just change that to D Vinci let me just change that to D Vinci okay I guess this is deprecated I'm not quite sure about that but now let me just check this out and let me just rerun my code oh we have to provide some different perimeter for that so now let me just go back and I'm going to ask it to like provide I don't know maybe 100 games let's suppose I'm quite sure that will not gives us 100 games let me just run there oh oh my God it gave me 100 100 games right here come on I was trying to show you that uh mix tokens but anyways you get the idea you know I'm going to just set that to 10 and I'm going to specify like the maximum token we want you to use only uh I don't know maybe 100 tokens I'm going to just set the maximum token to only 100 right here okay so now if I run my code you know what and instead of writing a 100 I'm going to just set there to like I don't know maybe uh 10 would be fine so now let me just set that to 10 and now let me just write a python index. pi and here you can see it will only gives us these two games right here why is that because we set were maximum token to only 10 and we now providing this prompt to print only the 10 popular user or not user but PC games and we are now setting our maximum tokens to only 10 so that's why we are only getting these two right here but if I ask it to I don't know maybe if I set that to like I don't know 50 or something like that sve my file and rerun that and here you can see it's going to give us a bit okay so here you can see now it will gives us only eight it will also try to gives us ninth but then it will hit this maximum token size so that's why it is not able to gives us the full response right here okay so that's the maximum token now we also have a stop and for the Stop we are going to be providing a string of number now you want your model to stop only on the five tokens let me just send my file and now let me just rerun them and here you can see our model will stop till the fifth token we can specify like 10 let me just put a 10 right here and now let me just run my code and then our model will be stopped from the 10th which you can see right here I can also tell it to provide like 20 and you know let me just rerun there and here you can see it did complete our job in this case but now here is the conflict between the maximum tokens and also the stop it is doing its job totally correctly but this one isn't I mean like both of them are doing their job totally correctly but in this case we are now telling our model to only use the maximum token of 50 and in this case we're now telling our model to stop when you use 20 tokens okay so that's that we can also provide like n now let me just provide an n and this n will gives us the time like you can think about that as a time okay so now let me just provide a 10 right here and you know what I'm going to just set this one to five and this one to maybe 200 and and generate a specified number of chck completion choices for each input so you know what we already specified 10 now let me just save there and now let me just rerun there so we're going to be using python index. pi and now let me just run there and here you can see it's going to gives us only four right here that's because we now specifying this uh stop right here but if I comment this line out and save my file and now let me just rerun them and here you can see it's going to give us only 10 games right here so yeah that's the basic perimeter which we just learned and by the way you can try out all of that perimeter by yourself you just have to go ahead and go to this chat and you can learn more about this perimeter and also you can specify there and check it out by yourself and now I also forgot to show you that how many tokens we've already used if I go to the usage let me just go to the usage right here and I already recorded a lot of videos so that's why I have spent a lot of tokens but in your case that's not going to be the case right here okay here you can see I already used the images model and so on and so forth and it's going to give us the free credit of only $5 and I spend almost $1 now let's talk about one of the most important part of this course which is how we are going to be hiding our API key okay so you will never write your code like this this is totally public and whenever you push this code to your gab repository so a lot of people can just copy this uh API key and they can use that and now at this point of the course we did not specify any credit card but if you did a lot of people will just steal your credit and trust me they will I guarantee they will now to secure this API key first of all we have to install a package called the python. EnV so we're going to be using pip and then install then python D do come on Dov let me just zoom in a bit this is the command which you have to run I already installed that but if I hit enter right here so it's going to tell me that yeah we already installed that but in your case it's going to take a bit of time to install this package so that's there but now the next thing which you have to do is that we have to create a file which will be dot andv let me just zoom in a bit you have to provide the dot and then e andv and once we hit enter and here we're going to be just writing like something you can give your API key as the name of like anything that you want but in my case I'm going to give it the name of like API and then uh keyword here in this version it's going to be equals 2 or actual API key so now let me just go ahead and cut out this API key from here so now let me just cut this out from here let me remove these codes from here and now let me p right here let me just go back save my file and that's what you have to do now your API key is totally secure no it's not this is how we going to be creating a EnV file this is how we going to be creating some sort of a variable and this is how we going to be assigning our API key for that variable okay so now how in the world we are going to be using there and to use that the first thing which you have to do that we have to import uh from the EnV package which we just installed a few second ago EnV package there we go we are going to be only importing the load and then EnV which you can see right here so you just have to write this line of code and after that you have to import the operating system or Os for short and then finally you just have to write this load. EnV which you just imported right here okay so you just have to execute there and then you have to use the OS and then that uh load EnV so I'm going to be using like OS and then we have a method inside there which will be a get EnV let me just write a get EnV and now inside there what do you have to do you just have to write this uh variable name right here so I'm going to copy there and now let me just place it right here so now if I save my file now my API key is Totally Secure totally like from A to Z no it's still not secure if you're pushing your code to G repository it's still not secure and I'm going to show you how you're going to be making it secure but now let me just test this out like whether our API key is working or not okay so if I just write like python index. pi and now if I hit enter right here let's just wait for that and here you can see everything is working totally correctly so which means like we are now accessing this API key from this.v file to this file right here or actual file so now the final thing which we have to do is that we have to just create a file which will be do get ignore so this is the kind of file which will ignore all of your file which you're going to be specifying inside this file whenever you are pushing your code to your G we have repository so now let me just hit enter right here so it's going to just create this do get ignore file right here now the next thing which you have to do is that we just have to specify which kind of file you want to ignore so we are only interested in ignoring this EnV file okay so we are going to be just writing like EnV and now let me just save my file and this is how you're going to be ignoring your file totally completely okay so now your API key is super secure you know let me just test this out once again so I'm going to be using index. pi and let's just word for it and here you can see everything is working totally correctly so yeah this is how you're going to be securing your API key in Python welcome to the next section of this course so in this section we're going to be focusing on the image generation which also means that we're going to be using the open AI doll e model so now a lot of people will ask me husin why not use the dol3 and that's because I want this course to be accessible for every single person out there so if you don't want to pay so for that you're going to be using a dolly to but if you want to pay so you're going to have to use the dolly three okay so I'm going to show you both of them I me like you just have to change the model name to D 3 and there you have it okay so you know what this is a d two and now let's get into the coding so let me just go back and here what I want to do is that I want to remove you know what let me just remove every single thing from here and I guess I'm going to create a new folder I'm going to give it the name of like doll e okay so now let me just grab this folder from here and now let me just replace it right here and the first thing which I want to do is that I want to create a index. pi and now the next thing which I want to do is that I want to create A.V file and finally the get ignore okay so you know what I'm going to have to just write like API and then key and it's going to be equals to this API key let's just copy that and now let me just place it right here but if you don't know how to generate this API key so you know let me just show you how you're going to be doing there the first thing that you have to do is that you have to go ahead head and go to this open and you have to create your account and once you do then you have to click on this API key and click on this create new secret and copy there that's it baby that's it okay so that's then now let me just ignore my file which will be the EnV files now let me just save there and the first thing which I want to do is that I want to import from the open AI come on open AI we're going to be importing the open AI there we go let me just zoom in a bit now the next thing which I want to do is that I want to import the EnV now we are going to be importing from the EnV package EnV we're going to be importing the load. EnV okay so now let me just import the operating system as well and finally let me just use my load. EnV and now underneath that we're going to be using our Constructor which we already grabbed from the open Ai and now let me provide API key to them and we are going to be just using like os. get EnV get EnV okay so let me just go back and provide my API key right here so we are going to be providing our API key and now let me just store it in the client variable let's just sa our file and I guess that's every single thing that we need for now and you know what let's start working on the image generation so now if you want to create image so still we're going to be using this client and now inside this client we have a property of images right here a few seconds ago we used the chat but now we are going to be using the images and then I'm going to write a DOT and here you can see we have this few method right here like edit uh create variation and we also have a generate right here so I'm going to just write a generate and now let me just execute there and now inside there we're going to be using a few models and we're going to be also discussing the perimeters which we are going to be specifying right here but now in this case we're going to be using d e and then two okay so that's that and now in this case we're going to be also providing the prompt not the messages but the prompt so I'm going to just write like cat using a computer or something like that okay so that's there now finally let me just St in some sort of variable like response it's going to be equals to this client r p come on r p NS e there there we go now let me just copy there and now let me just print out this response so now let me just save my file and let's just run there okay so I'm going to be using python index. pi and now let me just run there it's going to take a bit of time because it is now generating that image for us and here you can see it's going to use us this image URL right here and the response is that we have a data and we can totally grab that and I'm going to show you there in a few second but now let me just click on this image and open there and here you can see this is our amazing image based on or prom which we are specifying right here like K using a computer and you can specify different kind of prompts if you wanted to so yeah that's working now let me just hit contrl Z and now the next thing which I want to do is that I only want to get the image so I'm going to be writing like image URL and it's going to be equals to the response and we're going to be getting the data and we only want to get the first data and we want to get the URL from that data Okay so now instead of using a response I'm going to just write like image URL right here okay so now let me just save there and now let me just ream there by using python index. pi and here you can see it's going to giv us that one image right here but if I click on that let me just open that once again and let's just spr for it and here you can see C staring a computer or PC whatever you want to call that but now let me just show you the prompts which we are going to be specifying for these images now let's talk about the basic parameters we can specify for the do 2 and the dolly 3 okay so we have more than that but throughout the course we're going to be using these four okay so the first one we have is a prom so it's going to be a text description for a desired image or more images if you wanted to okay so the maximum length will be 1,000 character for the dolly 2 and 4,000 for the dly 3 do you want your image to be HD SD or high quality 4K or something like that and then the next one we have is a size so which kind of format of size that you want so uh you want 2 2 56 by 256 which means like 256 for the width and 256 for the height or something like that for the do2 or we can also provide these one for the dolly 3 but throughout the course we're going to be only focusing on the dolly 2 but if you want to use the dolly 3 you can totally do that now the next one we have is a style so as name suggest which style of image that we want do you want a wd images or a natural images okay so we can also specify there so you know what let me just write some code or you know what before I write some code let me just go ahead and show you all of this so now let me just go ahead and go to the API reference we can go to the images right here now let me just click on this create image and here you can see the prompt is required and we can also provide a model like which kind of model that we want to use and we have a n as we already learned there then we have a quality and we have a response format size style and so on and so forth so you know let me just write some code and then you'll get to know what I'm talking about so here let me just hit enter right here so here you can see we provide the model of Dolly 2 and if you already have a dolly 3 so you can just change there to the dolly 3 there we go so throughout the course we're going to be using a dolly two for over images but you can totally choose like Dolly 3 if you wanted to now the next one we have is a prompt so I'm asking here to like create C using a computer okay so this is my PR I can totally change that to like I don't know um head using chair GPT I guess that's going to be amazing promt and now the next thing which I want want to provide is that which kind of size of image that we want okay so for that we're going to be using a string and here you can see we have different kind of formats right here so we have like the width of 1024 x 1024 and we also have the 17 one and so on and so forth so if you want to get like a low quality image so I'm going to just choose this one now let me just provide a comma here we can also tell it like how many that you like so I'm going to just write like n is equal to 1 we only want to get only one so now let me just save my file and now let me just run that right here so I'm going to be using python index. Pi let me just run my code it's going to take a bit of time because it is now generating the image for us okay so let's just wait for that and here you can see it's going of gives us only one image right here so if I hold control and click on there and now let me just open there and it's going to gives us the most awful quality image right here and what oh my God I thought it's going to be awful quality but look at it it's super amazing anyways I really like it so yeah anyways so what I want to do is that I want to change the size of that so let's just clear that and I'm going to just hold control and space and here you can see we have all of these qualities right here so this one I guess this one is only available for the doly 3 so you know let me just try this out so let's just save our file and at this point it's going to take a lot of time okay so now let me just hit enter and yeah it is only available for the dolly 3 so if you have Dolly 3 so you just have to change that to the dolly 3 and it's going to work for you so now let me just undo that and now let's just try out this another one which will be I guess this format right here so now let me just save my file and I guess this is also for the dolly 2 Yep this is also for the dolly 3 so let's just remove that and now let me just change that to I don't know maybe I guess I'm going to just stick with this quality so now let me just save there and I'm going to also change there to like I don't know maybe five images and let me just try out like a python index. Pi so it's going to give us all of their images let's wait for that baby let's wait for that and here you can see it's going to gives us this image now let me just click on there and open there and here you can see we have this rud anyway so you get the idea so this is how we going to be working with the dolly 2 and you can totally change that to Dolly 3 if you wanted to so yeah that's it about for the DL all right guys so welcome to the whisper model so now let me just remove that and I'm going to just create a new folder I'm going to give it the name of like whh IP for The Whisper and now in this uh model we're going to be learning about how we're going to be converting our text to speech and also how we're going to be converting our speech to text okay so that's going to be a lot of fun so now let me just make that a bit bigger and you know what we're going to have to write all of that stuff a bit fast so I'm going to just fast forward the vide all right so that was the entire setup and now let's talk about how we are going to be converting our text to spage so how in that we're going to be doing that first of all we have to write our client which we already stored right here as a variable so first of all we have to access that we already learned about the chat we already learn about the images but now it's time to learn about the audio okay so now let me just write audio and then we're going to be writing a speech and now I'm not going to be executing the inside the speech we're going to be using this create method right here and this cre method will tell a few parameters so I'm going to just specify like a model first of all and model will be TTS And1 which means like text come on text to speech and we're going to be using the model one which is totally free and you know what we're going to be specifying different kind of perameters so now let me just explain there the first thing which you have to specify is the input then the wise then the response format and speed okay so the first one we have is the in the text to generate audio 4 the maximum length will be that much characters now the next one we have is a voice and the wi to use when generating the audio okay so it support these uh people like aloy Echo flb and these names right here okay now the next one we have the response format and this is going to be the format in which we want our audio to be if you want like MP3 we can totally get there or Opus or AAC or F laac or web or PCM okay so this is going to be the response format now the next one we have is a speed like how much faster or how much slow you want your voice to be so you know what let me just provide a few perimeter right here well you can also learn about that by going into the API reference you just have to go there then you have to click on the audio and then we have a create right here so we have a model we have a input wise and response format and also the speed okay so you can learn more about that if you wanted to but now let me just WR a code so this is going to be the model which we are going to be using right now then we have a wise so we have different kind of wises for different kind of peoples right here like we have a aloy echo and something like that so I'm going to just copy this one and now let me just place it right here here now the next thing which you have to do is that we have to provide our input like what you want to convert to the Y so I'm going to just say like hello word or you know instead of writing a hello word please subscribe to hen 2.0 uh YouTube come on YouTube channel come on c a n e l there we go okay so now let me just uh save my file and now the next thing which you have to do is that we have to Output this audio okay so we're going to be using the width and then we're going to be using the open and I'm going to give my file as the name of like output. MP3 and now let me just write the WB as a flag and ASF now it's going to gives us a chunks so I'm going to be itating over through that chunks uh in and by the way I have to store that in the response variable so now let me just WR the response k r e s p o n s e so now we have to itate over through their chunks so we are going to be using like for Chunk in response and then we are going to be using this method which is a stream to file and they show in the vs code that this method is deprecated but I'm not quite sure about that it totally worked for me but I guess if it didn't work for you so you can go ahead and go to the documentation and figure out what's wrong okay so now let me just write like um what do we call it let me just write like f. write and we're going to be just providing our chunk to there okay so now let me just save this file so we have S Str M there we go St Str M stream to file and finger cross now let me just save my file and we are doing something wrong so now let me just put a comma here and here you can see it's going to give us St line through but whenever I hold my mouse over to there so they are suggesting like this method is now deprecated and you should use this one right here stream response. method and I tried that and it didn't work for me and this one did work for me maybe in future if they change this method so you can try out something else or you can go ahead and go to the document and you can read more about that so you know what here you can see I don't have any output file right here but as soon as I run my Cod so you know what let me just write like python index. pi and once I hit enter right here so it's going to generate that output file for me which you can see right here so it did generate that output file and it also gives us this error like you should change that to this method right here and it will not work for you and I'm going to show you how now I'm going to copy that and now let me just remove that from here and now let me play this output right here so if I play there please subscribe to hxn 2.0 YouTube channel cool so it did work but now the next thing which I want to show you is that it gives us an error but now let me just replace that with this method instead and here you can see we have this method so I'm going to just remove that or you know let me just cut out this thing and let me just try out this way I'm going to save this file and now let me just delete this output from here and now let's try it out once again okay so I'm going to also open this sidebar and let's just write python index start Pi now let me just run there and it is giving us an error right here and it is still generating our output right here but now in this case it is not opening I don't know why I guess it didn't work so that's why so you know I'm going to just undo this code but if it didn't work for you in the future you should definitely go ahead and go to the documentation so now let me just save this file so this how we going to be changing our text to the audio format so now let me just delete that and I'm going to just recreate that Python and index. py so now let me just recreate there it's going to give us that error so just ignore there let me just open there and it will work totally F subcribe to yep it is working totally fine so yeah this is how we're going to be converting Text to Speech but I'm going to just create a new folder and this is going to be folder TTS like text to speech and now let's talk about speech to text so speech to text and now I'm going to just copy every single thing from here or you know I'm going to cut that from here and now let me just place it right here to this text to speech and I'm going to also copy every single thing from here let me just copy that and place that in the speech to text now let me just place that right here I'm going to delete this output file from here now let me just go ahead and open my index. pi and everything is working totally correctly but what I want to do is that in this case I'm going to be specifying some sort of audio output and based on that output we're going to be getting a transcription or you can say some sort of a text okay so I'm going to just remove that from here let me just save my file and that's everything that we have to do for now and I'm going to just generate some sort of audio in the front of you here is my audio recording software I'm using a windows so yeah here you can see I have my voice or Sound Recorder right here I'm going to start recording something againin and W YouTube channel so in this video we are going to be learning about the whisper model and now let me just play there oh it didn't work so I'm going to have to delete the let me just delete the come on and I'm going to change this one to this microphone so now let me just change that now let me just start recording againin and YouTube channel so in this video we are going to be learning about the whisper API and now let me just test this out guessin and yeah that's really working so I'm going to have to copy this recording and I'm going to have to place that in this folder let me just right click on that and then I'm going to go to my show in fold and now here you can see here is my recording right here and I'm going to just cut that from here and let me just go to the desktop and I'm working with this whisper and let me just go ahead and go to this stt and now let me just place it right here and now let me make there as a lowercase recording okay and here you can see we have that recording right here which you can see right here but it is not opening that's because the format of the file is totally changed so you know what let's start working on our recording so now let's just change our recording to the text the first thing which we have to do is that we have to get our recording okay so or some sort of a wi so we're going to be using that open method and let me just for a path and we're going to be going into the recording which you can see right here so I'm going to just copy this entire thing from here and now let me just place it right here and let me just go outside from there and I'm going to just specify this RB as a flag and now let me just store that in the audio come on audio file it's going to be equals to this uh audio recording right here now the next thing which you have to do is that we have to use our recording so we're going to be using like client. audio and then the transcription method we are going to be using that and now let's just create a transcription for our audio okay so we're going to be providing a model and the model will be uh whisp or whisper one and then we have to specify the file okay so we have to provide like where is your audio located so we are now grabbing that from here I'm going to copy the andl right here and finally the response format so we're going to be writing like response format and we want or audio to be in the text response and finally let me just store there some sort of variable like transcriptions so we have a transcriptions okaye and it's going to be equals to this method or you know let me just copy there and place it right here save my file and now finally let me just print this out so we're going to be just printing out this transcription and now let me use my python to get the transcription so index. Pi why it's not working God damn it index. oh we have to go ahead and go to that folder first of all so we have to write LS and then we are going to be going into this stt folder so now let me just write stt and hit enter and now if I just write LS so here you can see we have all of that files I'm going to be using python index. pi and hit enter so it's going to take a bit of time and it is not working I don't know why but it is not working so we have a client and we are using every single thing totally correctly so we have a client audio I just check out and the spelling is incorrect let me just remove that from here and I'm going to just replace that with whh i s p r and then dh1 so now let me just save this file and let's just write Python index. py and finger crossed I guess this time it will work hey guys this is Hussein and welcome to the YouTube channel did I specify husse anyway so hey guys hin and welcome to the YouTube channel so in this video we are going to be learning about the whisper API yeah this is how we're going to be converting our audio file to the actual text before we getting into the prom engineering first of all let me just show you there how you're going to be checking out these documentation so now let me just go ahead and go to the API reference you can totally click on the audio and then you can click on this create transcriptions right here and it require the file and then the model then the language you can also specify the language that you like and I was reading this documentation and I just learned a totally new thing if you want to provide different kind of languages or if you want to convert your audio to different kind of language so for that you're going to have to specify this ISO format so I'm going to click on that and here you can see we have different kind of languages right here so I'm going to just search for the Hindi and here you can see we can specify hi or h n or h n something like that so you know let me just try this out I never tried that so let's just try there I'm going to specify hi and let's just write python index. Pine and finger crossed I'm not quite sure if this is actual Hindi but yeah this is the response I got in return I can also specify different kind of languages like for instance Chinese Chinese come on c h i n a c h i n i e s we're going to have to specify Zed H for there okay so let's just write a zed and Edge so let's just s our file let's just run there and if you guys already know Hindi or Chinese KN oh this is a this is a English uh I'm going to specify z z h o o z h let's just write there and let me rerun there and no it's not working let's try out some other language like I don't know Arabic I'm going to write a or a a I'm going to try the AR first of all and let's just save our file and run there and this is no this is not Arabic this is just a split out sentence I know Arabic but this isn't Arabic language anyways you get the idea so this is how we are going to be working with the whisper model so now let me show you how you're going to be using that models using JavaScript but if you guys don't know what a JavaScript is so you can totally definitely skript this section okay so using or you know what models injs okay let's just open this folder right here come on let me open that the first thing you would need is that you're going to have to install the nodejs okay so I want you to check this so I'm using nodejs 20 and now the next thing which I want to do is that I want to just create index.js file and we're going to be also creating the EnV file to secure our API and for that to secure our API the first thing which we have to do is that we have to install something called the EnV package so I'm going to be using npmi and then Dov and let me just hit enter right here so here you can see that successfully install and now I'm going to be also creating a get ignore come on get ignore file and let me just ignore the EnV file let's just s file and yeah this is how we're going to be working with that but we're going to also have to go ahead and go to our package.json file and let me just change the type to module okay so we're going to be using a module so let's just save there and this how we're going to be using there the first thing which I want to do is that I want to place my API keyword here inside this EnV file and now let me just go ahead and go to the index.js file and we're going to be importing the EnV from the EnV and now let me just configure this we're going to be using like EnV and now let me just use a config method on there and now let's just access our API key so we're going to be writing like API key it's going to be equals to process. EnV and then our API key right here so if I just log that to a console like API key and let's just sa our file and run there and here you can see it's going to gives us my API key right here which is super amazing let me just remove that from from here and now finally let's just create our function or asynchronous function so we're going to be making a request so let's just write your asynchronous function and I'm going to give it the name of like fetch data and for the perimeter we're not going to be specifying anything to that and let me just provide like a we and we're going to be using a fetch method and you are more than welcome to use x us or anything like that okay so we're going to be making a request to this API so let's just copy there and let me just show you there so we're going to be making request to this API and if you're wondering like where in the word is this API coming from let me just show you there okay so we just have to click on this chat and this is that API which we're going to be using so I'm going to copy that and let me just place that right in here there we go so then then now the next which we have to do is that we have to provide our basic stuff like the method which we going to be using and stuff like that so method will be set to post and headers come on H H RS and headers will be equals to follow we have to specify our authorization so a u t h o r i z a t i o n and we are going to be using the barrier b e eer barrier and now let me specify my API key right here inside there provide a comma there and we're going to be using content type and now let me provide the content type of application Json and this should be in uppercase yeah and now the next thing which I want to do is that I want to put a comma and these are just the basic stuff so I'm going to just hide that from here and now the next which I want to do is that I want to just get the Bor so we're going to be just writing like Bor and it's going to be equals to Json stringify and now let's just proide our model so we're going to be using the model of GPT 3.5 and then turbo and now the next thing will be a messages so we can specify the array of objects and now let me provide the role and the role will be user and we can also specify the content and the content will be hello word well you know what hello word is not looking that cool I'm going to give it the prompt of like um give me a list of Po movies okay so I'm going to just specify this prompt now underneath that we're going to be getting word data so I'm going to just write like a word and then response. Json are you on storing the in the response yep you are not so now let me just write response it's going to be equals to RNs e so let's just copy that and change that to response. Json and let's just log this out so we're going to be just getting the data and finally we have to run or or execute our method let's just say our file and I'm going to be using not python but node index.js let's wait for that and here you can see we got our response right so we are getting the ID object created model and also the choices so now inside these choices we're going to be getting this messages right here okay so how in the we're going to be doing there let's just comment this line out and I'm going to just write like conso log of data we're going to be going into the choice say c h o i c s and we're going to be getting only the first choice and inside that choice we have a message not a messages but we only have a message right here so now let me just save my file and let's just use the node index.js and here we are now getting all of that content so we are now getting like Titanic Godfather and so on and so forth so yeah this how we're going to be using a chat API but now let's talk about how in the world we're going to be using I guess the dolly and to use them we're going to have to go ahead and go to the images and now let me copy this link come on let's just copy there and let me provide that right in here this is going to be the API which we're going to be using right now and let's just remove that from here we're going to be still using the post method and for the header I guess that's going to be totally fine and now we don't need the model and messages so now let me just remove that and let me provide the prompt and prompt will be equals to A C staring come on s a r i n s a r i NG there we go staring at computer or something like that let me just put a comma and we want them to be two times let's just provide a size and size will be 1024 and then times 1024 I guess this is not going to work but we will change the later so yeah we are only interested in that but you know let me just remove that from here I'm going to also remove that and let me just log out this entire data so let's just WR the data save my file and run there by using node index. Pi so here you can see it's going to generate these two images for me so I'm going to just click on there let me open that and I'm going to also click on this one and open this one as well okay so here you can see K staring computer kid staring at computer and yeah this is another one but let's suppose if I want maybe 10 of them I guess it's not going to give me 10 but I'm going to try it anyway so let's just save our file and let me use index. uh node index.js there we go uh yeah rate limit exceeded for the images per minute yeah I'm going to have to wait for one minute you get the idea like this is how we're going to be using all of their apis and so on and so forth so you know what let's get into the next section in which we're going to be learning about the prom engineering baby welcome to the most exciting part of this course so in this one we are going to be learning about something called the prom engineering okay so what in the world is a prom engineering and why you should care about that so prom engineering is basically the art of giving instruction to your llm or large language model in a way that gets you desired response it's like giving a recipe to a chef and you provide the ingredient and also the instruction and the shf in this case your large language model or chat GPT whatever you want to call it uses that information to create something specific out of it okay so yeah this is just a basic definition and analogy of a prom engineer ering but now let's talk about the basic structure of your prom you don't have to provide all of that but it will help you or it will make your prom amazing the first one we have is a task like what you want then we have a context like help the model by providing the context then we have the output desired output you want to get examples provide some sort of example for your model to get better responses okay then we have a toone so this is going to be basically the tone or style or language of the output you want to get okay so this is just a basic structure of your prom and now let's talk about the basic design so we're going to be providing some sort of a input forward model and then we going to be also providing some sort of a data based on that input and our model will gives us the output based on that in some situation we can also specify the output by yourself as well and based on that it will gives us amazing responses so you know let me just show you example of that okay so here you can see we have a input right here you don't have to worry about this promp right here this promp includes something called the JavaScript programming language but if you guys don't know what a JavaScript is you don't have to worry about that we are now giving an input like write a program in JavaScript programming language and the program will receive a number as an input from the user now we are providing some sort of a data or information for our model the program will also need to know the original unit of temperature Celsius or Fahrenheit from the user now finally we are also providing the output we don't have to do that but in some situation it will be a bit helpful to provide output forward model the program should convert the user input temperature to the other units like Fahrenheit or Celsius or Celsius to Fahrenheit and display the converted temperature on the screen so this is just a basic prom which you want to provide and by the way if you don't want to provide your email address I mean like if you don't want to log in to the chat GPT so for that you're going to have to go ahead and go to this link which is a chat. open.com okay so here you can provide your prompts but that prompts will not be saved right here okay so what I want to do is that I want to provide that specific prom which I just show you I'm now telling my model like this is going to be some sort of a input this is going to be some sort of a data and this is how I want my output to be you don't have to provide the output the data and also the input but in my case I'm doing that because I want to get a bit better response so now let me just hit enter right now and here you can see it write that code for me and also this description for me and I'm not even going to bother testing the result of this code so if you want to test the result of this code you totally can it is using the older way of JavaScript like a war isard keyword if andl statement nowadays we have a tary and also the const and let keywords but here you can see this is amazing prom and now we are getting totally completely response we are also getting the introduction we are also getting the code and finally we are also getting the review forward code so this is how we're going to be providing the input data and also the output now let's talk about the summarization so you can also make your model to summarize some sort of a text for you okay so you can specify the desired L the target audience and also the key points as well okay so for that you're going to have to provide some sort of a data and here is the example like here you can see we're going to be using the summarized keyword and then the desired length and here you can see we are now providing a complicated English this is the writer English so now let me just show you there okay so what I want to do is that I'm going to just refresh my browser and now let me just provide that same prompt right here so here you can see we are now asking your llm summarize the following text into two or four sentences okay so here you can see we have this huge amount of text right here and we can provide this data right here but we don't have to let me just remove that from here and I'm going to just hit enter right now and then it's going to gives us the result based on this text right here okay so now let me just refresh there and this is how we going to be summarizing some sort for text by using a chair GPT so now let's talk about the zero short prom so a zero short prom is a special instruction given to the model that allow it to complete a task without any specific training on that task itself and it is like giving a llm a nudge in the right direction so which also means that we are not training our model on any data whatsoever so we are just giving get some sort of a task and we are now leaving that task on our llm to do it by itself like how that's going to look like this is how it's going to look like so here you can see I have this promp word here and I am not training my model on any data whatsoever the year is 2077 and robot have taken over and stuff like that so you know what let me just try this out and then you'll get to know what I'm talking about and here you can see I am not training my model on any data and I'm asking it to provide some sort of a news headline or article with the style of the onion so now let me just hit enter right now and it's going to just gives us this headline right here which is super amazing but this is not the best way so what is the best way the best way is a few shot prom Oro by by a few shart a f shot prom is a technique used to guide or train or model towards a specific kind of response it works by providing the model with a few examples of input and the desired output something which we already learned but I'm going to also show you that in a few seconds right now this helps the llm understand the format and the style of the response you are looking for so here you can see we are going to be training our model by first of all providing some sort of input and output then again input and also output and finally we're going to be telling or model to write something based on this data so you know what let me just write this code not a code but you know what let me just write this prompt okay so let me just place it right here so here you can see I'm providing some sort of input and also the output then once again we have the input and also once again output then finally I'm asking my model like now it's your turn write something which I'm specifying right here just like this input and output which I just give you right here okay so now let me just hit enter and then it's going to gives us output just like these responses which you can see right here so yeah if you want to pause the video and read through there you can totally do that but I'm not planning to because it's going to just waste a lot of your time now let's talk about six strategies for getting better results so these stuff are now coming from the open AI website okay which I'm about to show you so number one provide as much detail as you can so how that's going to look like this is how it's going to look like so for the worst part we can just ask our model like how do I add numbers in Excel for the better part we can provide this entire prompt once again we have a worse part like write a code to calculate the Fibonacci sequence and you don't have to worry about what a Fibonacci sequence is and we can also ask for model like uh summarize the meeting notes and that's not the better way the better ways are these which you can see right here and I'm not going to even bother reading through all of them because it's going to just waste a lot of your time so now let me just try this out the first thing which I want to do is that I'm going to just it like how do I add numbers in Excel so now let me just hit enter and it's going to tell me that how can I add numbers in Excel okay so that's a pretty good response which you can see right here so you know let me just add this prom instead how do I add up a row of dollar amount in Excel that's the first question and I want to do it automatically for the whole sheet of rows with all of the total ending up with the right colum C toal so now let me just hit enter and watch what happened now at this point it's going to give me every single thing in a very great detail so instead of just asking it like how do I add numbers in Excel this is going to be a better prom and based on a better prom it's going to give you a better response which you can see right here I am not going to waste your time by reading through all of that stuff but here you can see the length like yeah here we have like equal to sign in the sum now in this case it's going to tell us exactly what we have to do it's going to gives us a lot of information and we can even ask it a bit more if if you wanted to but yeah this is going to be the first one and now you know what let me just try out something else now let me just refresh there I'm going to just ask it to write a code to calculate the Fibonacci sequence so now let me just hit enter Fibonacci series or Fibonacci Sequence whatever you want to call that and here you can see it's going to just give us that uh code right here and also this description but now let me just give it this from like write a typescript function to efficiently calculate the Fibonacci sequence come in the code library to explain what each piece does and why it's written that way so now let me just hit enter right now so here you can see it's going to gives us a typescript code also it's going to show us why this thing works that way okay so let's just wait for that and here is the explanation part right here okay so in this part it did a pretty good job I'm not going to say like this is a worst part it did a pretty good job and this is a python code by the way and now we are asking it to provide a typescript code or a JavaScript code and here you can see it will also gives us that explanation so yeah this how we going to be providing more information to our model strategy number two ask the model to pretend to be someone okay so here you can see we're going to be just ask it that you are something and we want you to do something like you are a language translator and I want you to translate like um animal from English to Chinese or something like that so in this case when I ask you for have toite something you will reply with a document that contains at least one joke or playful comment in every paragraph okay so then we are providing there something it's going to giv us at least the joke and playful comment so you know what let me just refresh them and now let me provide that same prompt right here okay so we are now first of all telling our model that you are someone or something and then we want you to do something based on that specific row do something okay so know let me just hit ENT right here we're going to be searching for some sort of a jog and now let me just ask my model like where is the jog and here you can see it gives us all of that result right here I'm not going to even bother reading through all of that but now let me just ask my model like where is the joke now show me the joke that you've made so now let me just hit enter and it's going to tell me that joke so where did the Bol go to school because it wanted to be a little bold clever yeah cool so anyways you get the idea like we can ask our model to pretend to be someone strategy number three so you can also use delimiters like triple ques or a markdown language like hashes and something like that so how that's going to look like it's going to look something like this summarize the text Del limited by triple codes and here you're going to be specifying some sort of a text so your model will not focus on anything else but it will only focus on that specific text which is delimited by double quotes Okay so you know let me just show you the example of that let's just refresh there and now let me just provide this prompt right here so here you can see we're now asking our model to summarize the following text which is now written in the triple quotes Okay so here you can see we have that same text right here so our model will not focus on anything else it will only focus on this text which we specified inside these triple code so now let me just hit enter and it's going to give us response based on this text right here so we can use these triple codes or we can just write a pound symbols if you wanted to so yeah let me just copy there and it's going to gives us that same response right here but instead of writing a triple quotes we're going to be just writing like uh this one pound symbol so now let me just hit enter right here so now in this case it's going to giv us that same response so yeah this is how we're going to be using delimiters strategy number four specify the steps required to complete a task so we can also specify different kind of steps for what model to be trained on and based on that training data it's going to gives us some sort of response so like use the following step-by-step instruction to respond to the user input step number one the user will provide you with text in triple quotes summarize that text in one sentence with a prefix that says summary and step two translate the summary from Step One into Spanish with the prefix says translation so you know what this is how we are going to be telling our model that you have to do something and then we're going to be providing some sort of a response or some sort of data it's going to first of all summarize our text and then it's going to translate that text right here to the Spanish okay so let me just refresh there here is that same response which you can see right here and we are now providing a step one then the step two and then finally we are now providing our data right here so now let me just hit enter so it's going to gives us response based on this so here you can see first of all it's going to giv us the summary and this is the summary and then finally it's going to give us the translation I'm not a Spanish speaker but it is what it is right here okay so yeah this is how we going to be providing a step by-step instruction for our model strategy number five so provide examples if you can here you can see this is how we're going to be providing our prom like system answering the consistent style user teach me about the patient and we are now teaching our model that you are going to be also giving us response just like this one which you can see right here then we are going to be asking one model that teach me about the ocean and it's going to gives us response just like this so you know what let me just show you there let's just refresh there and here is that same response right here so uh answering the consistent style and then teach me about the patient and this is how you're going to be teaching me about the patience and now I want you to teach me about the ocean okay so now let me just hit enter and here you can see the response is just like uh this text right here a writer Style English this is how we can specify example for over model and based on that specific model is going to gives us responses based on that so the final strategy we have is that provide references if you can okay so here you can see I have this example like use the provided article delimited by triple quotes to answer a question if the answer cannot be found in the article right I could not find the answer this is how we going to be inserting our article and based on this specific article we're going to be asking some sort of a questions so how that's going to look like this is how it's going to look like so the first thing which I want to do is that I want to provide this prompt right here and then we're going to be specifying in triple codes we're going to be specifying our actual data so here you can see I'm now inside of video games wikip PDF page and I'm going to copy a lot of text from there so I'm going to just copy there and now let me just place it right here inside these codes and now underneath there let me just ask a question question when was the first video game Prototype made so now let me just hit enter and the first video game Prototype was made in 1950s and 1960s which are example extension of electronic games so you know what let me just copy that and let me just place it right here and here you can see we have 1950s and 1960s so this how we're going to be providing our example references and B from this reference or data is going to give us output so yeah that was a lot to take in that was a huge course so if you enjoyed this course so feel free to subscribe to this channel yeah I just want to say like take care man and enjoy your life this is a life you're going to be learning a lot of stuff throughout your life and I don't even know how to end this video but I just want you to know that I love you and if you have any other courses or suggestions about any other courses or something like that so feel free to drop that in the comment below and I'm going to I'm going to do my best to make a separate courses on there
Info
Channel: HuXn WebDev
Views: 3,744
Rating: undefined out of 5
Keywords: python, using openai with python, tech with tim python, tech with tim, create ai content generator with openai and python, creating ai with python, automation with python, getting started with machine learning and python, fine-tuning with openai | python tutorial, python tutorial, openai api python, openai gpt-3 python, automation with python and chatgpt, how to make money with chat gpt, how to use openai api using python, gpt-3 python, python developers
Id: Us-kPtnaFU8
Channel Id: undefined
Length: 84min 32sec (5072 seconds)
Published: Sun Apr 14 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.