Using OpenAI, LangChain, and Gradio to Build Custom GenAI Applications

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
over the last few months we've seen an explosion of interest in generative AI largely due to the popularization of chat GPT released in November of last year now of course it's obvious why people are really interested in it you can do a lot of really cool things that we could not have even dreamed of doing just five years ago we can do things from the more silly and mundane like writing a silly poem to uh doing something that's more useful for a business context like generating a code for software engineering naturally companies are assessing their own business strategies now to see how they can make use of this technology for the core value of their own respective businesses and to that end I think the real value of generative AI is going to come in the form of building custom use applications whether that be a user interface or some sort of back-end uh process that's going on behind the scenes now to that end I'm going to talk about two specific use cases today of something that I built uh two little UI applications but before we jump into those I want to talk about the text stack that I'm going to be using to build these the first piece of this is obviously the openai API I don't necessarily need to use the openai API but because it is very simple to use and very similar to the chat GPT interface you are already in familiar with we're going to make use of that in this video the second concept is what is known as Lang chain Lang chain is one popular variant of a a concept known as Auto GPT and that is this idea where you take a set of tasks and you feed in an input and then after each task the output is fed into the next set of inputs so that you have this chain effect going on of getting the outputs into the inputs and then creating this whole process and you'll see how we're going to use that in our Second Use case and finally in order to enable the UI elements of this project we're going to be using radio radio is an open source python Library created by hugging face which is a company open source company largely known for their natural language processing offerings and you'll see how we can very easily write a nice little UI application for each of these respective use cases okay so our first use case is a chat bot very similar to the interface that you are familiar with in the form of chat GPT already the difference with this one is that I'm running this on my local machine this user interface you're looking at here is uh served out by gradio as we mentioned before and you'll notice specifically here that I've already asked a couple questions and then I specifically have my chatbot here answering the questions in the form of Jar Jar Binks from Star Wars just because I thought it was funny but the goal here is just to show you that you can do custom things just like this and not only that the more important one that companies may be really interested in is the capability of protecting your own data so one of the rules that I built into my chatbot here is that if I put in something that looks like a social security number here it will catch the social security number and it will not go out to the API so let me go ahead and give you a demonstration of that so I'm going to type I have the social security number one two three one two one two three four I know I'm not supposed to be submitting this but here we are and now that we've gone ahead and submitted that you can see that jarger's telling us that our prompt contains sensitive information and that it will not allow us to post this out to the open aibi now this is really great because as you know specifically with openai they keep your data for 30 days so if you are a company who is really really concerned about protecting your data you may want to opt for a user interface like this as opposed to allowing the vanilla chat GPT user interface so that way you can catch these bits of information and not have them go out to a source in which you do not want your data stored there our Second Use case here is where we involve length chain so what Lang chain is going to do here is what I call a business profiler tool so if you put in a high profile company name here off on the left chat and then you press enter it is going to do a number of things on your behalf so the first one is obviously going to just be displaying the company name uh the top five competitors that's pretty benign but where it starts to get really interesting is where we start to get into the top five business strategies and then the top five actions to support the first recommended business strategy so what Lang chain is doing behind the scenes here is it is asking the open AI API to generate the top five business strategies and then it's taking those strategies and piping them into the next part of Lang chain which is then taking the business actions to support the first recommended business strategy so for example if it said the first business strategy should be that you need to build up your digital marketing campaign it would say in the top five business actions that the way you might do that would be to start a a Twitter campaign or an ad campaign on Twitter or having some sort of uh you know app or website or something like that Additionally you can see also what it is also going to be doing behind the scenes it is is that it is going to grab the full text uh of the Wikipedia entry about the company and summarize it into a single paragraph to and then just for fun again we are going to translate that same output and show how Jar Jar Binks might dictate that and then there are a couple other things too but the whole idea here is you can see how when you use Lang chain with open API you can start to do some really cool things so just for fun I'm going to type in apple the company Apple uh the one who makes computers iPhones what not now this is going to take a second so let's pause here and I'll restart when this finishes in just a minute okay at right about the one minute Mark our profiler finished so this is what our results were so again we put in apple and here are the top five competitors it notes Samsung Microsoft Huawei Sony and LG I think that sounds right and like I was noting here so what the first business strategy is to expand the product line let's look down here so looking at the first strategy so the first strategy being of the expanding of the product line you can see that chat GPT has recommend these five specific actions in order to further that strategy season so that includes you know increasing research and develop uh introducing new products expanding into new markets investing in marketing things like that as we scroll on down so you can see that we got the company history here so again this was using Wikipedia's entry and then summarizing that appropriately into a single paragraph here to actually demonstrate the Apple history and then we take this exact same output and put it back in through open AI with Lang Chan to see how Jar Jar Binks might dictate that and then we get a little bit of a humorous kind of thing here now I did a couple of other fun things down here too so I asked if you could if openai could write a jingle specifically for apple and here's the fun little jingle that it wrote uh complete with choruses verses and everything and then finally if we scroll down to the bottom this is a little bit difficult to see but what this here is is actually an HTML code block that if we wanted to take the same output here all we would have to do is copy and paste this code but the idea here is that you can even generate code this way and this was all just off of typing one or two single little words here right from this user interface and when I click clear results we are back to a clean screen ready for the next one so I hope that gives you a sense of some of the cool things you can really do with generative AI if you do a little bit of customization now the one thing that I also want to indicate here is you might be surprised to enable both of these use cases it took me about five hours of coding work and the five part of the five hours was simply just learning radio if you ask me to do this again I could probably do this in much quicker maybe even an hour so it's not as if it takes a long time to even get up and going of course we demonstrated a user interface here but you could imagine how we might use the same length chain or open AI Technologies or even some other provider whether that be a Google bard or one of hugging faces own models or AWS Bedrock all these different options you could bake into a holistic system to produce similar results to what I did in my use cases here so I hope you found that really interesting I think it's really cool I'm really excited about the future of business and to see what people are going to come out with so that brings us to the end of this video thank you again for watching I hope you really enjoyed this I really enjoyed making it and uh writing this whole code um and we will see you in the next video
Info
Channel: David Hundley
Views: 5,785
Rating: undefined out of 5
Keywords:
Id: 1MsmqMg3yUc
Channel Id: undefined
Length: 8min 44sec (524 seconds)
Published: Mon May 01 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.