all right the recording started Roman um please take it over from you I wasn't able to show the project creation um so if you could show uh the console then it'll be great yeah okay so let me uh just share my screen and then I'll take it over from there give me a minute share the screen time to some other screens let me know if my screen is visible it should be uh and my audio is fine I can get going okay all right so um let's let's kind of start off but uh you know in case uh some of you are looking at the console which you see over here uh so let me know if the screen is good enough or do you want me to maybe increase the size it's fair enough okay I'll just put it over here so in case some of you are still uh I think either new to Google cloud or using it for the first time or maybe even uh trying to see where to create the project so or want to just use a different project for for this you know you can come over here and uh just click on a new project over here so I'll just show you again um like in in the top bar here once you're logged in uh this is my current project but you could just click that do a new project and then take it from there right give the name and so on so hopefully that gets you all going with uh the new project in case you need to create that now uh just focus focusing on this session that we have today right let me just put up one slide and then we'll take off from there right as to what what really is our shared goal today while working on the specific lab that we have so first up right I mean you would have probably got an introduction to gen AI uh you would have got familiar with some of the things that is there in vertex AI for example maybe you've gone to some of the Vex AI functionality in Google Cloud console tried out a few prompts so on and so forth right now the challenge that usually one faces I'm not saying everyone faces that challenge it could be depending on what the spectrum is but the the key point is that you need to start integrating some of those models into your applications so the point now is how do we integrate that right uh now your application could be anything your application could be a mobile application it could be a web application it could be a command line tool it's spread all across but the the point is that you want that apis such that you can invoke uh you know those functionalities because maybe the jna models that you're invoking which are hosted in vertex is probably some part of your application it's not the entire application so the whole idea here is and we'll see one or two examples today but the first sentence which you see over there which is like can we understand some projects that will show the you know integration with vertex AI Palm apis uh and that means that we are going to be ending up using certain services in Google Cloud we want to make this simple we want to ensure that you don't get too much hung up on the whole um provisioning and things of that nature so that's why the second Point mentions that there are going to be some serverless tools and by serverless tools uh we'll probably look at some Cloud functions maybe an upcoming session we'll look at Cloud run that's going to be used also moving forward but the idea is that you've got something working on vertex's AI the Palm or the text model or Cod model could be any of those models but how do we now sort of wrap this around maybe an API some functionality so that you can then integrated in as many applications or as many integration points which you requir so that's the whole idea out here just to make or put some sense to the whole process as as to why are we doing this remember once it's there as a cloud function um just maybe a show of hands whether some of you or most of you are familiar with what a cloud function is okay even in case you aren't don't worry about it because you'll be writing one and all we are trying to do is basically provide our own API around the vertex AI models such that tomorrow you could potentially do a lot in front of this API you could do your own authentication you could maybe rate limited you could do some other kinds of logging any kind of special Telemetry monitoring observability you could do so it's almost like saying let's create an API first it's controlled by us and then we integrate it with our application so I'll just go back and I'll go to the link that's there for today's code lab and I'm sure this is looking at the other screen also so I'm hoping maybe a very quick show off F that all of you are right now in Google Cloud console and at the same time somewhere in another tab another screen you have this code lab opened up a quick show of hands okay yeah thanks for the link also in case anyone of you needs it it's put there right now in chat so this is the code lab you need to open up that's the code lab you're seeing right now on my screen which is shared currently so what are we going to do right so in in other words right you're going to be writing a cloud function a cloud function the abstraction is that of a functions as a service some of you who are new to Google Cloud platform but have used maybe an Azure or even AWS you would have seen they have a function as a service functionality there too so those of you are familiar with AWS Lambda or as your functions the equivalent of that fast abstraction in Google cloud is called Google Cloud functions and basically the abstraction is that is that at a function uh level so you write a function it supports multiple languages but today we are going to be looking at python specifically but nothing stops you from writing it in any other language that's supported by Cloud function but what we have been doing is writing a function that takes in a prompt and passes on that prompt basically to a Vertex AI Palm text bison model right so that's the whole idea of this Cod lab uh so moving forward right to the next step what could be some of the requirements obviously um this is all straightforward I'm assuming you are in your Cloud console you've got a Google Cloud project and of course the credits Etc or the billing account that we generate behind the scenes has been assigned to the cloud project now few things uh before you begin and all of this obviously uh so we at step Tre I'm currently at step Tre and at step Tre it's it's all about just ensuring that you're in the right project uh so for example um I'm just showing you I'm in uh the cloud console and the step also mentions that you should be doing the activate uh the cloud shell or going basically into Cloud shell which is our uh you know think of it like a nice Linux machine in the cloud that you get as part of your Google account uh so I'm in Cloud console those of you using it first time just observe it's available as an activate Cloud shell button out here up where I am but those of you are familiar will know what to do so go ahead and activate it this can take some time uh for those of you who are doing it for the first time it has to provision create a home directory so on so forth but just think of it like you've got a nice Linux machine with most of the developer tools uh already in place over here especially things like uh Cloud gcloud command line tool which we have and obviously I'll also show all the editor in a while that makes it a bit easier to do now uh first thing you could do is uh and I think before you hit even activate Cloud CH it should come through muscle memory again and again as you're using with using Google Cloud that just observe I'll just probably reduce this a bit at the beginning so you got this particular project this is my project that I in obviously remember what you see out there may not be the project ID so just click it and you will obviously see the project ID that's listed out here so please keep that in mind so make sure you're in the right project and then of course you activate cloudshell you will also find that if all is well it'll tell you that you know you are in that specific Cloud project for those of you who just want to try out you could do g-cloud config list and uh also so it shows you a few you know I would say metadata about what's currently going on in the section and the most important one uh yes abami you something to say Just one thought Roman um I just wanted to wanted you to show the new project from the dropdown in case um they didn't see the project already listed there how to create a new project from the top left corner the drop down for project where where it's showing gcp experiments yeah okay so over here right uh if you click that you'll see something uh called the new project out here which I'm highlighting uh so in case you allow to create a new project please come over here and enter or sorry click that button obviously you might see slightly different values for an organization or location but ideally just go ahead and put in a specific project uh name so for example if you do say my uh new project or something right keep in mind that uh it'll also generate a unique project ID this name can be anything but the project ID has to be unique so if you see though you give my new project it give an ID because behind the scenes we expect a globally unique ID so if you're lucky enough with a nice project name that's unique you can you will get that but otherwise it'll try and uh you know append a specific ID to so this becomes then your project go ahead and create it once it's done make sure that the billing account which you're provisioning or for which you're claiming the credits is then assigned to or allocated or assigned I would say to that particular project let me know abirami if you're still good to go or should we wait for a few folks to create that we should be good to go just that if folks of uh if any of you is facing issue with um the billing account which if it says that credits are already uh fully redeemed um it means that you probably have the credit the $5 in your account so go back to the project that it is associated with the credits if not try using a different uh email account to get log to Google cloud and then create a new new email basically and then as um activate $5 credits using the credits link so that's the other option so these two things you could do uh please type in the questions uh let's not take up questions here uh type the questions in the chat uh you don't need to create create a new project uh Kumar Rajiv Kumar you only need it if if it's if for some people it's the first time and they don't see any project in the drop down then they have to create so that's why I wanted Roman to walk through that uh if billing account is closed then probably you have to uh use a different email to access that for those folks who are unable to do um either or if it's too short notice to create a new email account I'm sharing another link uh but I do not encourage this because this has only very limit credits left so only if you do not have another email that you can associate with um the previously provisioned credits link only those folks please access this otherwise don't this will also give you $5 credits but not if many of you would have already used it so don't try this if you have $5 get started but this is only for few folks for whom it's already too late to create a new email account use this other link to add the $5 and get started okay um can you can um some of you show comes and uh let us know that you're um all set and Roman can continue with the rest of the session perfect thank you go ahead Roman sorry for the interruption no no problem okay so uh if I just go back to the code lab right basically we are saying you're in the Google Cloud console step one right and you've selected your specific project for which the building is enabled then as I mentioned uh you're going to be activating the Cloud shell uh and that was as simple as just activating that IC can up there and I'm right now in Cloud shell as you can see and the g-cloud uh list command that I gave was sorry g-cloud config list command that I gave of course you can see the project ID here you'll see a different one in your case but this is also a good way by which you can actually see what's the current project and in case you I mean it's rare but in case it's not set or something of that sort that's why we have this command that says gcloud config set project and you set it to your project ID then it should be set to the right one but if it's uh all done correctly you should be able to uh have it but just in case you don't uh do go ahead and give this command also now we require two uh what you can say environment variables because we will use that subsequently uh in our deployment commands also you can obviously hardcode it also while giving those commands but just as a good practice I've created two variables over here uh environment variables one is gcp project and the other one is gcp region uh we'll discuss why these variables are there later on when we see the code but basically the the thing should be as straightforward as for example uh like export so I'm just doing it you can do it along with me GCB project and this should be equal to that um project ID so in my case is gcp experiments and that number so I'm going to be do that but don't copy me as is this should be your project ID that's why the instruction here says please put in your project IDE as is right so just put that variable which you sorry the value which you see so in my case I'm just going to be doing this as a first one and the next one which is uh just if I go back to that it's the gcp region right so uh gcp region this is where we'll be deploying our um you know Cloud function so obviously take a look at the documentation Cloud function like many other Google cloud services are available in various uh you know Google Cloud regions uh so like there's us Central for example there is Asia there is Europe there are many regions across and if you go to Google Cloud functions or Cloud run or GK or computer engine any other the services Pages you will see in which locations they are so in this case the region that I'm going to go with uh is the US Central one you can go with that too right so I'm just setting these two variables now keep in mind uh it's happened to me several times still keeps happening I sometimes end up typing those words wrong or something or the other so just make sure that you just use you know uh these practices to ensure that the values are indeed there right so just as a maybe I just have this habit so uh after having got burned several times so that's why just make sure that these variables are indeed set correctly and they are pointing to the values which are respective project ID but us Central one is fine so far so good this is absolutely essential folks before we go ahead just a show of hands where you focus on okay okay a few more seconds but ensure these two variables because even the repository that we will point you to uh there are several examples there and all of these depend upon these two variables remember if you don't want to set this then when you give the command later on you will need to then explicitly give the value so it's up to you it can be done in either way it's no hard and fast that you have to do it to all right so having said that let's move forward to the next Next Step which is that um and very important one which is that um you know you have to enable certain Cloud uh Services now you will see here there is a command that we've already given to you so it's a gcloud command so for example if you are in Cloud shell here and if you just type gcloud that just shows you that the tool is already installed okay so uh and we're going to give the specific command for enabling services and that Command right what does it it do is it enables several of the services in one shot there is cloud build there is cloud functions there is cloud run uh and then of course there are some logging storage apis and of course the vertex AI uh invocation that we are building so like literally five to six services are enabled so carefully go ahead and uh you know just copy this uh you know command whatever as is uh and uh paste it in your Google Cloud out shell and ensure that it's execute successfully and these services are enabled there are many ways to enable sorry many other ways also to enable it uh in my case obviously I've enabled but just in case you're curious I'm just showing that to you you can also go to for example uh if you just type the above search bar apis uh and you will you will obviously see you you might get confused of which API and things like that also right so one of the other ways to do that that's of course by the search bar if you know what you're doing but otherwise here if you just come down to the main menu on the left you'll see something called API services and you'll see this enabled you can get through multiple places I'm just showing you different ways so if you go to enabled apis and services the g-cloud command just makes it easy and enables it for you but just in case you wanted to do it on your own manually you know which service to enable you can always come to this page click on enable apis and services and you can now select for example like if you say translate right so uh it'll show you various services that could be there and then when you click it it'll tell you whether it's enabled or not you can accordingly do it that management is already there but otherwise you'll see an enable button I'm just showing you multiple ways so ensure I'll just go back to you know my dashboard here so Ure sure that you have run this command and all the services that are mentioned over here ideally just past it you should be fine it'll just tell you the operation uh successfully completed in my case I've already done this uh for this project so I'm not running it in front of you but looks fine everyone just looking at the screen everything looking okay fair enough if they are not enabled be assured that the commands when you try to run them will complain right something will go wrong So eventually you're going to be forced to sort of pick this up but remember just as a thought uh not as a thought but as a rule we have multiple Google cloud services now you might always say why don't we just enable all of these Services you know straight away why are we told to enable each one U you know on their own just little digression but just to make sure that a you don't enable all because otherwise it means the services are on people could misuse it second these Services end up costing so you need to be very sure as to what you you know really enabled so by default uh you know of course a few ones will be but not all of them so if you're running into any issues typically look at the error there might be a chance that these services are not enabled g-cloud commands will actually Force you they will tell you hey you're trying to do this but this is not enabled so do you want me to enable yes if you hit some of that please go ahead and enable it so having said that let's go to the next step which is to deploy the cloud function now there's no fun trying to just say hey just copy this deploy it and we are done and it works right let's try to understand uh what's going on so first up before I actually get into the code right so don't go ahead and run this just be patient with me um I just want you all first to go ahead and uh you know clone this repository uh and before you just clone the repository let me just go there for a moment which is uh I just go here this is the GitHub report that we have for uh various uh Google Cloud applications and you will see here just if you go down there is a nice little table that we've done our best to try and explain what's going on so here you will see multiple applications out of which we are going to be using one of them which is the text predict Cloud function right in Python but you can see those of you who feel like using other applications for integration whether it's a flutter app to maybe even a gradio or a streamlit app or even um you know Chrome extension appscript slack stuff whatever you want to call it right so there are uh various applications that we've made available this is the repository that we are telling you to clone and today we are going to be going into one of them to actually show you integration with the text bom moduel but this is a great way by which you can then extend your knowledge and maybe I think the next session that we have session five of cod Persona season 4 we'll be looking at another one application from this repository itself so as a start right let's go once again to our you know Cloud shell just in case for those of you who are new if Cloud shell remains active for a certain amount of time it might end up disconnecting so you if you try to type something it'll tell you it's got disconnected do you want to reconnect you will see a reconnect button feel free to just click that and all will be fine after that you'll be once again into the console over here now um so what I want you to do and of course uh let me do this since I was testing it out I might be having the repository so I'm going to just delete it so that it's all there from scratch as I do it with you okay so we are done with this now let's go to the fourth step which said first clone this repository right so just take this whole command that you see and uh we will just be here and be in your home directory for those of you are not sure what it is uh you know just uh do a present whatever working directory and you will see whatever home and most likely your account name so I'm going to just to paste in this git clone command which you see it should take a few seconds and should ideally you know uh get all the things into this gen app templates Google Cloud please don't hold me to this name I tried my best but this is the best I could come up with so uh what the next step tells you is that um navigate to the folder of the project that we'll be building right so uh of course CD command do that but I just wanted to show it in a slightly different way so obviously if I go to the jna app templates the thing that we cloned right now uh obviously here you're going to be seeing all of those uh you know uh projects that I showed you in the GitHub repo out of that we're going to be going to this particular text credit Cloud function so that's what this command tells you that go to so and so and then go into the text credit Cloud function so I'm just going to go there and I'm out there okay so far so good everyone cloned went into that directory looks fine okay now before we jump into just deploying it let's understand what's going on so uh for those of you whove not um used Cloud shell remember there's also this nice editor called you know it's based on vs code itself so please use that so I'm in my current uh my current directory as you can see now is from the the home the one which we cloned and into the text predict Cloud function so I'm just going to be doing Cloud shell workpace and a doot right so this will open up the editor uh again I'm just showing you the code and explaining it to you though the code lab doesn't have it so as you can see it's uh uh you know I'm in the editor and see I can keep swapping between the terminal if you just click on open editor and go to that folder that's fine too either but I just opened it in that particular folder so as you can see now here uh I'm in the text predit Cloud function right and three files only nothing nothing great happening over here now this read me is similar to let's say the whole code lab which you got here so don't worry about that now what we're going to be doing is is something like this right uh and for a moment let me uh for those of you who attended the previous ones it might be clear to you but really speaking let me go for a moment to work that you get the whole picture right and there's no magic involved anywhere so I am in vertex AI slight digression but important one okay so I am in vertex AI right now and you see something here called generative AI studio and of course you know we have language models we have got the vision models in language as you know we've got our text model there is a chat model there's also the code model but over here right if you wanted to work with the Palm text model we give you this UI tool to play around with so for example if I say um like what happened in history today right something maybe if you do this up next year and say what happened in history hopefully it's going to answer that code we pass in season 4 happened today but for now it might give us a different answer sir so again here as you see um we're just giving a prompt you know ways we can play around with these parameters and models Etc but if you just submit this obviously it hits the text P model with the prompt and it's going to give you back a response okay and it give you some response right so let's not worry about that we got some answer back also but the thing I wanted to show you maybe you've seen it before is you seen this something called view code right which is that suppose if I have to invoke this model with the prompt get back a response how do I invoke it so the view code part when we click that right you see there is python collab Cur Etc but it's already given you the code that you can see for python right so uh this is actually the code that we will be taking putting it inside our Cloud function and then uh that's how we are going to be exposing this end point you see so this is what I wanted to explain to you so that you understand what we are doing from where have I got this code we're actually using what the vertex AI service itself is suggesting to go ahead and call this right so now if some of you are sharp you would have noticed I told you to set two parameters project ID and lo right if you can see there is a line here that says how do I initialize the vertex library in Python two parameters are required which is the project ID and the location that's why we set it so that we pass those things at runtime by environment variables and your function takes it you so we can hard code it but by hard code right when uh you can sort of parameterize or externalize it so hopefully this is giving you a picture as to what I'm doing why this code lab is where I've got the code from and what precisely is going on so this is the code that you will see now I'll just go back to my um editor and in the editor in the main. pile right so I'm going to be writing a cloud function is this code font okay or you still want it bigger I can try some other look okay fair enough thanks you folks even have it in front of you so you can even see that but in case you're following it on the screen so I'm writing a CL function now so obviously I'm using in in requirements you'll see we have got a framework called the functions framework you can look at look this up also but again here the python libraries that I'm taking again please pardon me if you're not a python person I will point out you to Java as well as you know some other code during the course of the session itself you got it in a sample so in case you want to not deal with python that's okay just follow it over here and then we'll take it from there so straightforward libraries we've got the functions framework which we use for writing our Cloud function obviously behind the scenes it's the you know vtex Ai and basically the cloud platform sorry Cloud AI platform so that's the another package we have here and obviously I like to do a bit of logging because my code never works the first time so I've got Google Cloud logging or if for those of you who are much better than me you might be straight away de working in production so you better start logging then from day one so we go back to uh the main dop and over here right um as you can see uh again don't worry if you're not a python person but whatever be the environment variables we are setting and we will see how to pass it to Cloud run also for deployment basically those two things which were needed for project IDE and region we just extracting out those values next is okay just some logging setup in Google Cloud you're not to uh you know worried about it you can skip that but then just focus on this function so in this function right it's a cloud function this functions as a service it gets in a we've just given it a name but we are extracting out the Json that's passed as a post to it if a prompt is there I'll just show you then how you invoke it basically the prompt variable is there in the in the in the post for that HTTP API call we are extracting that out then as you can see that same goes on we are initializing the vertex library with the project ID location next thing is important I'm selecting which model which is the text model again the same code from there some parameters being passed and that's it then you just go ahead and predict right and uh that's the method called that's there on the model so basically what we are saying is that when you invoke an API all you will need to do now is simply pass the prompt once the prompt is passed it ex racts it out it instantiates the text byon module and it just invokes that module and gets back a prompt response it gives back a Json uh you know response this very simple one you can tweak this if you want to this L this as you can see now right whether you're calling it from a mobile app or wherever it may be it's just going to be a question of making a simple rest a post you know API call pass in the prompt and you'll get back a Json response to it that's that's all that's going on in the code and hopefully now uh you will also understand what's going on in The Next Step so basically the fourth step in this sorry the the fourth point in this step tells you that there is the main do PI and the requirements do PI this is the one that we have you know discussed but in case you want to go by the GitHub thing this is what I've shown you I think this point this URL is a bit incorrect so don't go from there uh so maybe AB be just a note for us yeah okay so just whatever you have cloned please look at the main.py and requirements from there itself now hopefully if all this is good uh then we need to go ahead and deploy This Cloud function so we are going to be using the g-cloud command but remember just like how the enable apis was there you can always use the UI also to deploy the cloud function but let's pick this up because this helps you the even do other automation so before you just fire off this command just give me a minute so basically what we are doing is we are saying that please deploy this function the function is called predict text you can give any name you want but predict Tex is a function that we are calling uh Gen 2 we've got a different runtime for a cloud function which is based on generation two which is based on cloud run which actually does the containerization don't worry too much if you ignore this parameter also you'll get it on gen one and it'll be fine but take the latest this runtime specifies which language you have written your Cloud function so tomorrow if it is a Java thing or it is a nodejs one or it is even net and many others sometimes Ruby we support quite a bit of it please go ahead and change this to that one in this case it's python 311 then remember which region you want to put your function in that's why see it's reading the dollar the environment variable for region with reset source code where is the source code you're telling me to deploy a function but where is it right so in this case we're just saying it's in the current directory because we firing our g-cloud Command from that directory itself next from that uh you know file it needs to know what's the function what's the start point for it right so that's why if I just go over here as you can see in my main do PI there is this entry point don't worry this can be any method name but you need to give it what's that point so that's what we specifying Cloud functions can be triggered by directly by HTTP there can be even DCS trigger so when you upload a file it gets triggered or if you update a record in fire store it gets triggered in our case we just make it an end point so the trigger is directly HTTP now remember in the code right pay attention in the code I was directly reading from the environment variables I was not hardcoding these values so I could have done that but that's why if you're going to be reading it from the environment then you better pass it you know when you deploy the function so that's what we are doing so we are actually using a set EnV VES which is one of the ways and see we are actually saying GCB project is one variable which is through the value we've set and gcp region is the other one and that's why that's the two line two pieces of or two variables that we are reading out here right and finally there are ways by which you can secure you're your function Endo but in our case we're keeping it simple so I'm just doing a allow unauthenticated otherwise you to pass the correct token in order to make the call good practice in real world you not do allow unauthenticated but it's fine for now and obviously Max instances you can ignore it for the moment this is just to make sure that in case uh someone uh you know hits your end point and tries to really make measurable for you in a sense I'll start a load testing tool and I'll bombard from you know 10,000 you know threads hitting your end point basically since it's serverless uh you know it will start scaling up which means it'll start creating more instances but by doing this you protect yourself you make sure that whatever happens well it's going to be only one Max instance whatever it can take right so just a little bit of a thing over here so hopefully this explains to you each and everything what we are doing out here you can still look at the documentation but now is a good time go ahead and please uh you know copy this command Asis and paste it should take a while I'm going to be doing it together so I'm going to go to the terminal just make sure you are in that text predict Cloud function directory if confused just to NLS see those files they should be there otherwise the source dot will fail right so make sure you're there and and uh paste that command now in my case I already have a predict text deployed earlier so don't do this what I'm doing I'm just doing it for my sake so I'm just going to call it predict text two in my case because I've already got a predict text deployed and I want to keep it running for my other Integrations which might just break if I delete it but in your case it'll be predict text to so go ahead and uh just hit the command a lot of things happen behind the scenes this could take easily somewhere from from a minute to 2 minutes and what really happens is it's going to take all your source code when it says preparing function is taking your source code it's uh using some technology behind the scenes build packs Etc uh packaging that into uh container of course while doing that it'll compile your code check the dependencies install the dependencies all of that stuff once it's done it's going to push it into an artifact registry from which it goes and deploys it it does a health check to make sure hey is it really live working or not and if all goes well it should take a minute or so you will find a flurry of commands and you will get an end point for the function so I'm hoping all of you have launched this command at least us Central is not found vnav please correct that it should be us Central one yeah us- Central One correct okay so let's go on how many of you have been able to deploy it okay I'm still lagging behind so hopefully it gets true so remember even if you want to make changes to it right go ahead make changes to the code and again come and fire the same Command right so as you can see over here this completed for me this is something similar that you should see and you will see that uh somewhere at the end you see this URL right which is um Cloud functions. net predict 2 and because in my case my name was predict 2 but if you go back to the let's say instructions you will find that after you have deployed it successfully the URL should be something like this so I've just made it a shortcut here that it should be the region us Central 1 dash whatever your project ID Cloud functions. net and whatever be the name so that's what you're seeing so no mystery here it's just the same thing so my region then the project ID and then whatever whatever right so now don't invoke it directly I just wanted to show you a few other things before you fire a curl command and all that so since we are in the UI obviously we use g-cloud command and we uh what do you call deploy this function but uh let's say if you wanted to see what happened right like did it deploy not deploy can I see it in some different ways they're about to exit problem yeah okay that's fine so I'm here now as you can see in my cloud functions you might not see these many functions you might see that one particular Credit Point just just hold on uh folks if you are trying to pass the prompt that's what I'm trying to show you also so just follow uh and you got Cloud functions and uh in your UI you might not so many functions in my case you this is the cloud function that we deployed right now 22 November almost near 9:00 it's real so I not like you know con this screen or something like this so go ahead click that particular function which you have seen deployed and start looking at a few things which you see here tomorrow someone says your function is not working right I thought it was working come over here take a look at the metric see some of the dat that you could see here you also got logs for your function which might indicate something is going wrong or not uh you will also see the source which you deployed so the same thing right as you notice when you said preparing the function and I'm putting it up it actually took everything from your uh current directory and it put it up there so in case you want to edit directly here also you can just do an edit change the function you see this entry point which we did we did the runtime of python then remember variables we passed at environment so those are the two that you're seeing here trigger as you know was HTTP directly so that's the one you are having over here and testing and this is what I wanted to show you can do a curl directly from the command line which is there as one of the steps but we also have got this pre-built thing for you so instead of this name uh which is pre-built we need to pass a prompt okay and if you see here there's a URL that's ready if you just directly invoke it right what's going to happen there's going to be an error I'm not a good coder I written bad code I don't even check if prompt was passed or not and then do something and straight away do some crazy stuff that's the code you have to fix you you can improve it but if you just call it without invoking a prompt this is the error that you're going to Su but in our case here since I'm going to the testing part I can this is how you're passing the Json so I'm doing a prompt and I'm passing maybe not allow let me pass like let's say where is Mumbai let's ask this and you do test function now when this happens this is going to hit your Cloud function get back and see that it ran successfully with the whole U uh you know response text and the answer so far so good now the same thing right uh if if this is not how you would like to do things then that's what also the uh the step tells you which is your fifth step which is fire this curl command and this curl command is the same thing it's going to be hitting your endpoint of course make sure those environment variables are still valid in case you have restarted your Cloud shell the first thing that is going to disappear most likely is these environment variables or values or you can paste this thing from the uh Cloud function URL itself and again same stuff so if I just take this maybe and copy it and go back to let's say um our terminal I'll just put it out here too and paste it it's the same thing and you should see a response coming back soon right so just make sure that since you're calling it that way some of those variables are in place right otherwise you might just find that otherwise hardcoded and provide the actual URL that that's fine too I mean no hard and fasting it's just a one way of showing it show fans everyone's completed this that's pretty much what we have in the lab here okay I just went a little bit here and there to maybe just highlight what's going on behind the scenes what's happening where clean up uh of course up to you just hold on for a moment before you want to clean up things if it's there in your account let it be there if you want to to refer to it but keep in mind you can come here anytime suppose you say hey I lost my code you know source code what is it don't worry come over here to the cloud function whichever be your Cloud function right I'll just uh yeah so you can just go there go to this Source part and you will get and you see this download zip here so you can use that to get back all of your code also so you know things go wrong but that's why this has been made that way now uh I can take in some questions but before I take in some questions I just wanted to cover some part of it like very quickly which is the whole Lang chain way of doing things so so far right you would have seen that in our code right or even by vertex when we said view code or show us the code we directly are using Google packages out here right which is uh the vtex AI or the cloud AI platform that's made for you now tomorrow you might just say that you know what I think Google Cloud AI platform is good for a certain maybe functionality but maybe embeddings or something else I want to use from somewhere else uh so you know at times you want to mix and match or not match but basically mix aggregate or whatever sequence multiple llms that could be there also not just that but you know llms won't reside in isolation they'll have to have input data coming in from various Source systems maybe they have to invoke some external systems call it right so so many things are going on now do you write quote for each one of them or is there some kind of an abstraction that makes it easier right so if I just go quickly to um this particular uh I would say brief presentation that I've got right the L chain right we just wanted to highlight it so that in case you working with more than one llm more than one you know data sources let's show the some of the use cases so it becomes a bit easier for you to use instead of directly but if you just focus let's say only vertex a go ahead just use that particular API you should be fine so Lang chain it's a popular framework it's open source it's available of python JavaScript but in case some of you Java folks want to try similar abstractions there's also a line chain for Java but not from these guys it's a separate maintain one by interested folks again the use cases that I'm showing you are you may not have an llm in isolation right you might want to call some external things so as you're creating let's say a bigger application you might want to sequence their outputs maybe you might want to even aggregate their outputs right but how do we do all of this it becomes quite tedious to U sort of I would say talk to each one of these apis independently that's why again we won't be going into each one of them but this just shows you the scope of Lang chain which is there are various abstractions or building blocks that's the key to Lang chain right so models which you see in the top right so not just vertex a tomorrow even if you want the Facebook models or let's say even the open AI models Etc these are abstracted out for you similarly prompts how do we construct them how do we parameterize them Vector stores right different different ones why just you know Vex AI uh you know matching engine or something of that sort it could be even maybe uh the other Vector stores that you know about similarly like if I go back for a moment how do we change these things together how do we maybe aggregate them or how do we just say we want to do a task and then it needs to automatically take over pick the right agents model Etc so there are various aspects to Lang chain it's a very detailed thing but it's a great thing to maybe invest some of your time in case You're Building llm applications and see if that's a library or framework you might want to use the key thing is something like this right so you got Google Cloud now Lang chain goes somewhere by which it will be able to talk to all of these so if you see on the left side right there you might want to bring in data from bigquery you might want to bring in data from your PDF files which are on cloud storage and then index them right so instead of knowing each API you could just use LINE chain it's construct and why because this diagram hopefully shows you something this is something I put up today which is just see the scope right whether you want to which llms in Google cloud is integrated with which documents it can automatically load which Vector stores in Google Cloud it can work with even for example if now you want to do something like I have my PDF files on Google Cloud Storage I would like to take each of the PDF files and create a vector index out of it where is a vector store and then I would like to maybe interact with that llm and make a call all of this stuff right you can now chain together using uh you can do it on your own using the apis but Lang chain just gives you an abstraction and just as an example it's there on what do you call GitHub and everywhere uh which I put in that repository but I will just go hopefully I've shown you all predict t to right and you would have seen in the source code right now which you deployed it has some calls like okay I have to initialize it this way then I've got this text generation model and this is my code right this is basically from the vertex ai1 but I also deployed a lang chain version of it a little bit earlier in the evening and if I see this source code of course requirements you can see I've included the Lang chain dependency and in the main do PI you will see the code basically now I'm importing vertex a right because this is the llm supported one of them is vertex a and all I'm doing is as you can see I'm just instantiating an llm which is a vertex ai1 and simply I'm telling in this llm pass this prompt and it gives back a response and that's it now imagine this instead of vertex AI you could substitute it with an open AI also so uh if I go to this Lang chain documentation and the library right and if you look at um let's say for a moment a quick start okay and as you can see over here right instead of the vertex AI in this case it is a open AI one so you can continue to use cloud functions and if you feel you want to mix and match not just llm models I'm just showing you a very small piece of code but instead of vertex AI you could have imported completely some other llm also even for the vector search even for the prompts so this is a great abstraction that lets you mix and match Services across what you're seeing over here either llms or models or document loaders again this is only a mapping to Google Drive but if you go to Lang chain documentation and if I look at Integrations over here as you can see Google is one of the providers that's why you are seeing all of these things over here but you could even have AWS Microsoft open Ai and wow 187 more items so be my H and try it out so hopefully this also gives you some picture again all of these examples you are uh it's there on the repository that you cloned right and this repository again is available out here any point in time we just saw one of them today which is providing an API for the vertex AI Palm model and we saw This Cloud function python part those of you want Java go ahead try it Lang chain you can try that too in the next session obviously we're going to be looking at a chat model but it's a similar kind of a lab so hopefully this gives you a good picture of uh why we did this um and how you can use Google Cloud constructs to maybe externalize or provide an API see tomorrow your API could be doing many things you might say that I'll call an llm vertex Ai and then combine it with something else and provide a Json response so this this just gives you the constructs to start using it Cloud function and you saw how simple it was to deploy it and uh yeah that's that's pretty much what I had llm sorry the line chain one was more to just tell you that you could potentially use that also inad of directly coding to the respective cloud provider or the or the llm API specific to that cloud provider all right so that's what I had hopefully you all were able to do the lab and uh in case you have some questions I'm happy to take them too so please go ahead I'm looking at the screen I don't know if you want to say the question or type it either way it's fine with me yeah sorry AB uh Roman I was just saying uh could you tell them what they need to submit for result uh just the screenshot of the app or the deployed Cloud function URL right yeah so ideally if you go to your Cloud functions maybe just show us that you've deployed it so if you just go to the detail page maybe uh just send us a screenshot of this this is one and uh of course the next thing you you ideally should give us is just give this curl command and show that whole thing so this screenshot also would be nice to see so that we can validate that you indeed called what you had to yeah yeah any one of those screenshots would be good yeah yeah okay let's take uh two questions for regarding deletion of project you don't have to delete the project for this Pro this particular assignment because um this one does not include any instance like we had for the spanner instance session rate this one does not have any instance and it won't eat up any credit while it's deployed but if you're sh going to share your link somewhere publicly be careful because that will if someone keeps hitting it it will use up all the credits if you're using it one time it's fine it'll only cost you like very um negligible amount which is like 01 or2 cents sorry dollars so it's very minimum that's okay um you can still delete the deployed function by going to the cloud functions page and um just selecting that particular Cloud function and click delete that's it Roman's pointing to that one yeah one once you submit the result you can delete it if you want you you could delete it if you don't want to keep the code so that's totally fine U Roman do you want to take Leia's question she has had some um internal server error I don't know which Step you completed Le Leia but you can unmute yourself and speak up because I know that you the only thing I see is as if you not passed the prompt so I hope you've not clicked the function directly uh so if you click like this you'll obviously see an error because no prompt is passed and and my code doesn't have all the checks in place so best thing would be that you should go to either the testing thing that we showed here change so for example if I if I give nothing here and I'm going to just say that uh sorry let me minimize this a bit and if I just say uh test the function what is that what happened I can't even see those things so for example the way I would do it is obviously here it's it's telling you so if you give this prom and we say uh let's say how are you and we test it so this extracts out the prompt variable it'll need to be passed in this Json format and see it just gives you back a response over here however let's say uh I make a mistake and pass something wrong uh then obviously and you see that I got a 500 surve because uh if I see the source code I'm not really uh written the code in the right way but this is something that you can uh you know bulletproof yeah I mean I've intentionally kept it this way because there are reasons for this I have another demo that goes together with it where I then for example like if I'm within the functions thing then I also show that that look if there are errors then you can see the logs and you know here you go you can see why it failed so that's why I've kept it in intentionally that way so you can it also helps to show people we have got a logging thing and you can debug what's going on yeah that's right don't expect me to change the code at any point in time I'll keep with this one did it did it Sol that maybe you just called it directly how to go to the cloud functions page yeah this can be tricky at times um multiple ways uh one is you see this search bar on