DAY- 3: Introduction to LangChain | LangChain Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
for for for for for so I think uh I'm visible and audible to everyone can you confirm the chat guys if I'm uh Audible and visible can you see me can you hear me yeah hello all uh good afternoon to all I think I'm uh Audible and visible to all of you please do confirm in the chat if my voice is clear and if my video is also clear then please do let me know in the chat guys my voice is coming yeah it is clear so we'll start the session uh within two minute uh let everyone join and after 2 minute we'll start with the session guys voice is very low now it is fine I think now it is not uh low right so now it is uh now it is fine please do confirm in the chat if my voice Isle clear now great so will start by 3:10 I think still people are joining so let's wait for some time great fine so let's start with the session so this is the day three of the community session and in today's session we going to discuss uh more about the open and we'll try to discuss about the langon as well so guys uh this is the day three of the community session as you know so here first of all uh let me tell you that what all thing we have discussed in our previous days in our previous Community Days so uh uh actually see this is the dashboard of the community session uh let me show you that particular uh dashboard so just a second for uh just wait it is loading and uh I will show you the dashboard still it is loading and see guys this is the dashboard actually and here you will find out all the lectures all the sessions uh whatever I took in the previous uh two days and this session is also available yeah so here is a dashboard now let me show you all the lectures all the uh like resources and all and even we have uploaded the quiz so see guys this is the H session so day one and day two I took two sessions so uh at Day first actually I have discussed about the generative Ai and at day two I I have discussed about the open AI open Ai and understanding the open a API and I already clarify most of the thing related to this openi so just go through with this particular session and here you will find out complete detail introduction of the openai apart from that whatever resources apart from that whatever resources I'm going to use so all the resources basically I kept inside this resource section so just try to go through with this resource section and you can download all the resources what whatever I have discussed now here uh apart from this lecture and resources you will find out the quizzes also so just go through with this quiz section and here we have upd the quiz quiz regarding the topic now uh as I will uh as I will like like go ahead with my topics and all so all the quizzes and assignment will be updated over here itself so this is a dashboard guys you can uh sign up to Inon website if you are new and then you can log Lo in and then like you can uh access this particular dashboard and here uh you will find out each and every material now apart from this uh you will find out uh like the video video recording and all over the Inon YouTube channel as well so just try to go through with the ion YouTube channel they are going inside the live section and all the videos and all it is updated over there as well so guys if you want to uh check with the video so just uh go through with the Inon YouTube channel you will find out over there and apart from that so yes if you want resources and all everything uh basically so quizzes assignment so just try to visit the dashboard you will find out those particular thing so this thing is clear to all of you please do let me know if you join first time so uh that's why I'm guiding you regarding the dashboard material content and all because I already took two session and this is my third session yes The Notebook is not uploaded yet notebook is uploaded now just go through with this uh resource section and here you will find out the notebook this one so here is a notebook uh I already updated this particular notebook test open AI API so there is a notebook please go and check with this particular notebook you will find out each and every line of code whatever I have written inside the class so my python project so just okay great so don't worry we'll try to discuss about the project as well I will uh use a lenion I will use Lama index and I will use this openi by using this particular thing we'll try to create an inent project don't worry just wait for two to three uh classes uh let me cover the basics first uh regarding this length chain and this openi and then directly I will move to the project section and then only I will start with the some uh Advanced concept and in between actually I will take one session for the hugging phas API also so I think now everything is set uh we can start with the session so just give me quick confirmation in the chat uh if we can start with the session then tell me guys fast great so I think now we going to start you need to add credit card or uh debit card will will also work so either credit card or debit card but the international payment uh like should be enabled inside the card great so let's start with the session just allow me a minute I'm going to start with the session okay just allow me a minute for speeech for speech for okay I think uh we can start now so uh I'm visible to all of you right great I think my camera is also fine uh it's getting blood or what so please uh give me a confirmation in the chat okay it's fine then fine so let's start with the session now here guys you can see in the previous class I was talking about the openi API so uh most of the thing I have discussed regarding this open API now few of the thing is remaining so let me discuss that uh remaining thing regarding this open Ai and after that I will start with the Len chain so first of all Let Me Explain you the complete flow that what all thing we are going to discuss throughout this session got it so for that I'm you I'm opening my Blackboard and here I'm going to explain you the complete flow that whatever thing we are going to discuss throughout this particular session so here guys uh the first thing first thing basically uh we'll be talking about the function calling so in the open actually we have a very specific feature that is called function calling and it's a very important feature of the open API if we are going to use the openi API then definitely you must be aware about this function calling because by using this function calling you can do a multiple things I will tell you that what all thing you can perform by using this function calling which is a very uh important feature of the openi API so the very first thing which we're going to discuss in this particular session that will be a function calling so here I'll let me write it down the first point which we going to discuss uh that's going to be a function function calling function calling now the second thing after this function calling so directly I will move to the Len chain so uh first I will discuss this function calling and after this function calling I will move to the Leng chain and in the Leng chain actually I'll be talking about in the Leng chain I'll be talking about that how you can uh use a open AI by using this Len chain so the first thing basically uh we'll be discussing inside this inside this Lenin so open AI open AI use by a len chain so we'll try to discuss in a very detailed way and we'll try to discuss that what all difference we have between this Len chain and this open a so open a Ed via length chain and here I will explain you the differences between open a and Len chin then why we should use Len chin what all benefits we have if we are using a length chain what all thing we can do if we are using a len chain so how uh by using this Len chain we can create in to an application each and everything we'll try to discuss regarding this Len chain and in a very detailed way I will try to explain you this lench concept because it's going to be a very very important and this lench also it's a very important part if we are going to learn this generative AI if we are talking about the llm and if we are going to build any sort of application so along with this open AI this Lenin also plays a very important role so we'll try to discuss about this lench and we'll try to uh disc discuss the differences about this open AI API so let me write it down over here open AI API versus Lenin versus Lenin and after that after discussing this uh like the basics and all regarding this Lenin I will come to the prompt templating that how you can design a different different type of prompt so here let me write on the second point which we're going to discuss uh so the second Point basically prompt templating prompt templating after this prompt template so uh here what I will do I will I will show you the use of the hugging phase also uh after discussing this Lenin uh the differences between open and Lenin I will come to this open AI use via lenen promp templating and here I will show you that how you can use hugging face model whatever model is there on top of the hugging face Hub how you can utilize those particular model by using this Len chain so in between I will show you hugging face hugging face with Len chain hugging phase with Len chain why I'm uh why I'm going to show you this hugging phase with Len chin so you can use any sort of a open source model so whatever open source model is there so you can use all those model by using this hugging phase so here I will show you how you can generate hugging phase API key and by using that particular API key you can access any sort of a model whatever is there on top of the hugging face Hub so here I will show you hugging face with Len chin let me write it down over here hugging face with Len chin and then we'll try to discuss a few more concept regarding this Len chain which is going to be a very very important so here let me write down those particular topic as well so the third topic which we going to discuss over here we're going to talk about chain we're going to talk about about agents how like you can create agents and how you can use the agents so here the fourth topic basically it will be agents now let me write it down over here agents after that after this agents I will come to the memory so I will show you how you can create a memory by using this Len chain got getting my point yes or no so these are the very important part of the Len chain without knowing this particular thing you cannot develop any sort of of application okay so before starting with the end to end project definitely we have to discuss about this particular topic so here uh so in today's lecture actually we're going to talk about this function calling open use and prompt template and in tomorrow session I will be discussing about this hugging pH with Lenin chains agents and memory so this three to four topic we'll try to discuss in tomorrow session and this three to four topic we'll try to discuss in today's session and right after this one right after this topic right after this thing I will start with a project and uh we'll will try to create one project and there basically we'll be using a different different LMS from the openi and from the hugging pH we'll try to use Len chin we'll try to use Len chin and some other Concepts as well so here we're going to use a different different uh like model llms from the open ey hugging face Len chain and here we'll try to uh create one uh UI as well by using flask or streamlit each and everything I will show you in a live classes itself so flask and streamlit and I will show you the complete I will show you the complete uh setup how you can do a complete setup for any end to end project so first we'll try to create a project template and then we'll start with the project development so this idea is clear to all of you please do let me know in the chat if if the agenda is clear for today and for the tomorrow session I'm uh expecting the answer in the chat so please write it down the chat guys please do it fast yes we'll discuss the risk and all what all risk is there and we'll try to discuss about the different different point uh first let us uh uh create at least one project after creating this particular project definitely uh we'll try to uh discuss about the multiple things that uh basically which is a very very important in terms of the industry we'll come to that part don't worry fine so now each and everything is clear each and every part is clear so let's move to the Practical implementation so if you will go through with my notebook so which is already available in a resource section okay I have shown you how you can download this particular notebook so just try to go through with the dashboard and from the resource section you can download this notebook now uh here guys see uh The Notebook is there so just try to download it and try to run it inside your system uh how you have to do a system setup how you have to create an environment and all how you have to install the library inside the environment each and everything I have shown you in my previous class only so again I'm not going to repeat that particular thing so over here you can see already we have talked about the open AI now let's discuss more about this open AI so just uh give me a moment here uh from here itself basically inside uh uh this particular file itself I will be writing a code now I'm going to change the name of the file so here I'm going to write it down test open a API and Len chain because in today's session I'm going to include the Len chain as well and I will do in a same Jupiter notebook I'm not going to create any new notebook uh as of now I will be doing over here itself so here I'm going to be write it down I'm going to rename this particular file uh so here I'm going to write down this Lenin as well so test open API and Lang chain so this is the new name of my file now let me rename it and now everything is ready so here guys see if I'm going to write it down this import here if I'm going to write down import statement import Len chain now here you will find out it is saying that no module named L chain can anyone tell me how I can resolve this particular error please do let me know in the chat how I can resolve this particular error correct so here what I need to do tell me here I need to write it down pip install and the Len chain pip install and the module name so just try to open your anaconda prompt and there write it down pip install and Len chain so let let me show you that just a wait uh so here uh this is my prompt uh this is what this is my anaca prompt here already this jupyter notebook is running so I'm not going to stop the server of uh this particular prompt now let me open the new prompt over here so here I'm going to write it down this Anaconda prompt so first of all guys what I need to do I need to activate my virtual environment as of now we are in a base environment and this base environment is my default environment so here what I need to do tell me here I need to activate my virtual environment so for activating the virtual environment first of all we should be aware about the name uh in which environment actually we are working so let me show you all the name all the name of the environment M so here I'm going to write it down this cond ENB list here I'm going to write down this cond en list so once I will write it on this particular command I will get all the environment name so here you can see we have a different different name of the environment Len Chen open AI base testing and these are the other environment which is there inside my local folder now guys yesterday actually we have created this particular environment testing open AI now let me activate this environment over here so here I'm going to write it down cond cond activate cond activate and the environment name is what the environment name is testing open AI so if I'm going to write it now this testing open AI so definitely I will be able to activate my environment now if you want to check over here that my Lang chain is working or not so definitely you can do it so first of all you need to clear this screen and here if you are going to write it on the python so it will give you the python prompt so here let me write it down the python so this is what guys tell me this is my python cell or my python prompt now here itself you can write it down the uh statement import statement so let's try to write it down the import statement over here and here if I'm going to write down this Len chain Len chain now see guys it is saying that no module name Len chain and even you can check so for checking that what all module is there what all module is there in my current virtual environment so what is the command the command name is PIP list we are using pip manager over here right so over here what I'm going to do I'm going to write down the exit if I want to exit from this particular shell from the python shell now here what I will do guys here I I'm going to write it down pip list so once I will write it down this pip list you will find out all the packages name whatever packages is there inside my current environment so these are the package guys which is there inside my current environment you can read the name of the packages and here you will find out this length chain is not available so just try to go through with this particular package try to go through like alphabetically and here you will find out that we don't have any package with the name of link chain so here what I will do first I will install the L chain so for installing the Lang chain there's a simple command pip install pip install pip install Len chain so here once I will write down this pip install Len chain now guys see my lunch is getting installed inside this current virtual environment so are you doing along with me are you writing this thing or are you like following uh to me guys please do write it uh please write it on the chat so I will get some sort of idea that uh uh this many people are doing along with me I will come to the connects between this L chain and this open AI just allow me uh like 15 more minute each and everything will be clarified regarding this open and this elction just believe me so people are saying they are writing a code along with me that's great please do it guys please do it and uh yes please Implement along with me if you are uh getting stuck somewhere so please write it on the chat and let's uh make this session more interactive and yes definitely after the session you should uh you should be able to get something it's my guarantee to all of you fine now here guys you can see we have installed this lenon inside this current virtual environment now if you want to check it so here itself directly here itself you can check so just write it down this Python and here what you need to do you need to write it down this import Len chain let's write it down this import Len chain and here the name is wrong so let me write down the correct name now see guys we are able to import this Len chain means Len chain is there in my current virtual environment okay fine so I think till here everything is fine everything is clear now here again I'm going to import it so definitely I will be able to import but before starting with this length chain I would like to explain you the function calling so what is a function calling why I'm saying this function calling is very important uh definitely we should learn it actually it's a new feature inside this open AI so let's try to open this open a website and here okay so here already I opened it now guys once you will open the documentation of the open a so there itself you will find out this function calling so it's a new feature uh recently they have added maybe uh 4 to 5 months back and uh what we can do by using this particular function calling so by using this function calling there is a there is a many use of this function calling so the first use basically uh the very basic use which I would like to tell you we can format our output okay we can we can format our output in a we we can format the output in our desire desire format so whatever output we are getting now from the open let's say we are using openi API and we have a model openi API what it is doing tell me it is calling the llm model agree now whatever output we are getting now we can format that particular output in a design format in our required format that is the first use of this function calling now we have other use of this function calling some Advanced use of this function calling let's say uh we are uh calling any sort of a API means let's say we are asking something to my chat GPT and it is not able to answer for that particular question so for that what we are doing we are calling any third party API any any sort of a plugins and whatever output we are getting whatever output we are are getting right so we can format that particular output and we can append that output in our conversation chain that is really powerful and somehow Len chain is also doing the same thing but yeah so recently they have added this function colleag the this one feature actually uh inside this open Ai and here uh like it's really uh like a important one and it's like a really uh very very useful and in The Lure also we can do the same thing right but apart from this thing lench is having so many functionality in the lench actually we can perform so many thing I will come to that I will I will show you the differences between this openi and this Len chin why we are using this openi why uh why we are why we are going to use this Len chain why uh we are not going to use this openi API itself because see in a back end if we are going to talk about this Len chain so in the back end this Len chain this Len chain actually it's calling open API it's a wrap up on top of the open API come I I will come to that first of all let me clarify this function calling so guys to understand this function calling I will I draw the architecture and all I will I will try to uh explain you each and everything okay but before that let me write it down some sort of a code over here so here what I'm going to do here I'm going to open my IP NV file and here I'm going to write it down some sort of a code to understand this function calling so step by step I will try to explain you and uh please do along with me I think uh that would be great so for that guys what I did so here uh just a wait I have written one text great so here guys see uh I have written one text so let me copy and paste this particular text now here I'm going to run this particular uh cell and once I will print this student description so here you will get the entire description so I I just written a very basic description so uh s Savita is a computer SI it he's a Indian and he's having a 8.5 cgpa something something about me or something about like any person you you can write it down this uh particular description so here is a short description now guys what I will do see so here is what here is my short description now here I have designed one prompt and that prompt I would like to pass to my chat GPT means I would like to pass to my GPT model so here see uh whenever we are talking about a prompt so I told you that what is a prompt so let's say this is my llm model this is what this is my llm model now we are passing input to this llm model and we are getting response we are getting a output so this respon this input actually so this input is called input prompt and this prompt is nothing it's a collection of tokens so you can understand in such a way that this prompt is nothing it's a sentence and and this token is nothing it's a words what is this tell me it's a words so this uh sentence is nothing it's a token and sorry sentence is a prompt is nothing it's a sentence and token is nothing it's a words right so here we will be having input prompt and here we have a output prompt getting my point so here see I have written one description now I will write it down my prompt I will I have designed one prompt so let me uh copy and paste that particular prompt and let's see uh what will happen if we are going to paste uh if we are passing this particular prompt to my llm so here is my prompt guys so just try to read this thing over here and so this prompt is saying so let me run it first of all so this prompt is saying please extract the following information from the given text whatever text we are passing let's say this is a description so uh we are passing this particular description so from that particular description I have to extract a few useful information so here the information is what name College grade and Club so these are the information just just try to read this particular uh description and based on this definitely uh you can extract this particular information like name College grade and club now chat GPT or this GPT model will do it uh will do it for me uh something like this I have designed this particular prompt so here I'm saying please extract this particular information and this these are name and here this is the the body of the text and here I'm passing my text you can see so here I'm writing a f a string so I have defined one prompt and here I'm passing my description now see once I will run it so definitely I will be getting my prompt so here is what guys tell me here is what here is my prompt this is what this is my prompt okay it is fine not an issue now guys what I will do I'm going to pass this particular promt to my chat GPT right now what I can do I can pass this particular prompt to my chat GPT and over here uh first of all let me copy and paste this particular code or let me write it down that so here I'm going to write it down from open a import open AI so this is what this is a class now here what I'm going to do I'm going to create object of this particular class so here I'm going to create a object of this particular class so here I will write it down open Ai and here uh what I'm going to do so here is what here is my object now I can keep this object in inside one variable now here I'm going to say my variable name is what my variable name is client now if I want to make a connectivity so for making a connectivity what I need to do tell me so here I need to pass my API key so how I can do that so here is a a parameter uh we need to pass one parameter over here so the parameter name is what parameter name is API unor key so here I'm going to write it down API _ key and here I will pass my key so my key is what my key is my key so once I will uh run it so here you will be able to find out this is what this is my client so let me contrl Z and here is what here is my client so this is what guys tell me this is my client now by using this particular client definitely I can call my chat completion API so let's try to call this chat completion API and here I have already written the code for that so let me copy and paste U I have written some sort of a code already I kept in my notepad so from there sometimes I will copy it uh because I want to save my time otherwise uh if I'm going to write each and every line so definitely it's going to take more time now here uh you can see so we are going to call this chat completion API now chat completion this is the particular method that's it now here is what here is my prompt now once I will run it so you will be able to find out I will be getting one response so here is my response let me show you this particular response and here here is what guys here is my response definitely I can extract this response uh for that uh what I need to do so here I just need to write it down this response uh response and this response actually uh inside this response there you will find out this choices so I will write it down this dot choices dot choices now I will run it so here you will get this choices now from here what I need to do from here this is the list actually so here I will write it on this zero zero index whatever information is there on this zero index now from here I'm going to extract this particular information now here I will write it down this message message now here is what this is my message actually and from this message I'm going to write it down I'm going to except this content so here I'm going to write it down this dot content now guys see this is what this is my entire information now if I want to convert this particular information now if I want to convert this particular information in Json format so for that what I will have to do so here actually what I'm going to do I'm going to collect this thing in one variable that is what that is my output now here what I will do guys here I'm going to import Json so here I'm going to write it down import Json and here I'm going to write down json. load now to this load function I will uh provide my variable my variable name is what my variable name is output now here you will find out uh is saying this Json do load it is giving me Str Str object has no attribute read okay it's not going to read let me check what is the correct function just a second so the function name is loads here guys you can see so the uh the method basically which I was calling so the method name was loads so json. loads and here we are passing this output now you can see this is what this is my output are you getting my point guys are you able to see what I did I I given this uh I given this prompt I given this basically I given this description to my model and I asked that okay just give me this particular information just give me this particular information from this description and here what I did I passed this particular prompt to my tell me to my chat completion API actually this chat completion API is calling this GPD 3.5 turbo model and here guys you can see we are able to get a response whatever description we have given according to that whatever prompt we have designed and it is giving me that particular response we have given a description we have designed a prompt and according to that only we are getting a response here you can see this is the response actually I have converted it into a Json format so this is the first thing which I want to show you now here guys see this type of prompt it is called few short prompt it is called few short prompt where I'm giving my description and I'm saying that okay so uh you need to behave like this means whatever description I'm giving to my model and here regarding that particular description I want to extract some sort of a information so here actually this type of prompt is called fuse short prompt now directly I was asking something to my model in my previous one in my previous uh session so here actually directly I was asking uh the question to my model to my llm model so this is called actually zero short prompt this is what zero short prompt now here this type of prompt actually it is called few short prompt getting my point this idea is getting clear to all of you please do let me know in the chat if you are able to follow me till here please write it down in the chat I'm waiting for your reply I'm sharing the text uh don't worry I can share everything in the chat so just a second here is a text so here is a text guys uh I think it's a so half text let me give you the full so college and here is the full text because it is having a word limit I cannot uh like give more than 80 words I think I cannot uh like paste more more than 80 words in the inside the chat yes is it is it because we are asking for a number of variable in a second prompt correct your understanding is correct Goldie so zero short means we are not defining anything over here directly we are asking a question to my model now what is a few short so here we are giving some sort of a description and based on that particular description we are asking regarding some information we are asking some information okay so this is called few short and here is a zero short don't worry uh we have a many example here I just given you the glimpse of that just wait for some time one or two more classes you will get more about it because uh now we just we are going to design The Prompt and all and in the next session specifically I will I will be working on the prompt on a different different prompt and even uh for the uh inside the project also we are going to design a different different prompts got it now see uh definitely we are able to call our llm we are able to call our like open API and definitely we are able to get output also so from the llm models now here guys what is the use of the function calling so first of all let me uh Define one very basic function and then I will Define one Advanced function also so here what I'm going to do see here I did this particular thing by using this uh chat jpt Itself by using this completion API now let me show you the same thing by defining the function so here what I'm going to do so here I'm going to Define one function so let me do one thing let me Define one function and here this is my function guys see I'm going to define the function this is my function now from where I got this particular format so you must be thinking sir okay so sir you define this function now from where you got this particular format so just try to go through with the openi API and here uh sorry openi documentation and here just click on this function calling and once you will scroll down over here so here you will get the code is snippet so and inside this code snippet you will find out this function definition that how to decide or how to define this particular function getting my point I will come to this particular example I have designed one example for all of you but first of all let's try to understand a function calling from uh like very basic example and then I will come to the advanced part so here you can see we have a function and from here itself I took this function definition and how to decide how to define the function and all now let me tell you what I written over there so here I have opened this uh notebook now see uh what is the name of this function actually student custom function it's not a function like python we write it down that Def and all it's a like function basically which we are writing down for the open AI U actually we have to uh like pass this thing to the uh to inside the chat completion API itself I will come to that uh first of all let's try to understand this uh structure so first of all I I need to write it down the name so here I have written the name name is equal to extract student information then we have to write it on the description so here you can see this is the description of the function that why we are going to Define it now here you will find out some sort of a pairs so key and value pairs so first we have a parameter so here you can see we have a parameter now uh we have a type so which type of uh like object we are going to be defined over here and then we have a properties now here you will find out in inside this parameter you will find out of different different values like name school grade and Club whatever actually I Define over there inside my prompt the same thing the same thing over here right so first we have a name the second thing we have a description the third one we have a parameter inside the parameter we have a different different values like names school grade and Club getting my point now here just see the type of this name it's a string let's see the type of this school it's a string a college you can write down the college here is a college so let me write down the college instead of this school so here is what here is college so instead of this school I can write down this college now here is college the type of college is string right now here is a grade now grade type is integer now here is a club so Club type is integer again I think you getting my point that how to define this function it's a predefined format over the Inon platform itself you will get this particular form format now just run it okay now just run it and after that what you need to do so here see you need to uh call the chat completion API so here is your chat completion API let me copy this chant completion API from here and let me paste it down now here you need to Define some sort of a parameter now let me write it down those particular parameter and then I will run it so so here guys you can see we have this message so let me keep this message in a single line so here I'm going to keep this particular message in a single line so here is what guys here is what here is my message it is fine now after the message what you need to do you need to write it down one more parameter and the parameter will be what the parameter will be a function so here I'm going to write it down the parameter the parameter name is what function so here is my parameter function now tell me what is the name of the function function so here the name of the function is nothing it's a student custom function so let's try to copy it and try to paste it over here that's it you just need to copy the function name from here and you need to paste it over here okay as a value of this particular parameter now guys I can keep this particular response in response two so here I'm going to write it down this response two so here is what here is my response two now let me run it it and let's see what I will be getting so here is saying okay it is giving me error so I think uh chck completion role is fine I'm using client only let me check with the client yeah client uh now everything is fine what is the issue and you code incorrect API provided okay okay just a second let me use the correct client this is fine and here I can keep the client c l i e now see uh it is saying that incorrect invalid key uh why it is so just to check let me check this ke over here student custom information prompt is fine Oh but before it was giving me output now why it is saying like that let me check with a key over here so my key and here is what here is my key just a second guys let me take a correct key okay don't worry I will delete this particular key uh running in front of you everyone but after the session I will delete it fine so now I am having my key and here what I can do again I can run it great now let's see yeah now everything is working fine so this is what this is my response to and here guys you you will find out that we are getting a output so we are getting output in whatever format we have defined this thing so we have defined this thing like uh name College grade and club now here you will find out the same thing so name is there college is there grade is there and Club is there if you don't if you want to change any sort of a description you can change it and you again you can check it and now actually we are not we we are not uh doing directly this thing we are using a function over here and this is a very basic use of the function as of now which I have shown you getting my point so directly also you can do that you can call it but here they have given you the function by using this function also you can call it okay so here actually this is the basic use of the function and at this point of time you you won't be able to find out any differences in a direct call and in a function call both is looking same but now the difference will start once I will explain you the second example now over here you can see so this is the response which I'm getting now let's try to extract the response so over here what I can do I can write it down this a content and let's see what I will be getting over here so here is what here is my uh content which I want okay which I want to extract from here so let me copy it and let me paste it over here actually I want to extract the content so that's why I'm going to be writing down response to Choice message and content so once I will run it and over here I will be getting this content so here I am getting this content now let me check over here okay actually see here actually we have to get the content from the function called so till message it's fine so let me check with the message till message I think it fine now if I want to extract the content now so over here I will have to call this uh I will have to write it down this function call because before I was extracting the message because directly I did it directly I I called my llm model now here I'm calling it but by us using function so here I have defined the format in a function I have defined the format of the function and now by using this function I'm calling my API so the the API is hitting the model and whatever output desired output I want I'm getting it now over here what I will do so here I'm going to write it down this a DOT function call so let me copy and paste it over here function underscore call now over here guys you can see we are getting this particular value now let let me write argument over here arguments and this is what this is my output now yes same thing we can do over here as well so here I can write it down this uh Json json. loads and here what I can do I can write down the json. loads and now see I'm getting the same output but see guys here at this point of time definitely you are not able to find out a difference between the direct function call and between this uh Direct Call call and this function call right now I will show you one Advanced example and by seeing that particular example definitely you will be able to discriminate getting my point so till here everything is fine are you able to do it don't worry I will give you the code and uh I will give you each and everything whatever I'm writing over here and uh this file and all it will be available inside my resource section so here is a resource section guys uh so just try to enroll into the course and yes definitely you will be able to get this particular file inside this resource section and this is completely free you no need to pay anything you no need to P you no need to pay actually a single rupees for this for this particular dashboard so please try to enroll and try to download the resource from there so till here everything is fine please give me a quick yes then I will proceed with a further topic what is the difference between Json and function call so here you will find out so just check the type of this output so here you will find out the type of this output is nothing let me show you it's a string now here I have converted into a Json that's it okay I don't I I don't want to keep it in a string because uh it's not looking good to me if you will print it now if you will print it guys see it's not looking good to me that's why I converted into ajon now if you will check the type of this particular output so here you will find out a Json let me write it down the type over here and let me print it now so here is what guys tell me here is nothing it's a Json not dictionary got it so this is fine to everyone I think till here everything is clear great now let's start with the second concept so over here uh the first concept actually I shown you the basic use of the function and all now let's try to understand the advanced use of this function calling so over here guys see uh we have few more thing regarding these functions and all so first of all let me tell you that now let's say if you want if we are passing a description of two student all together so it can handle that thing also it can handle that thing also now over here let me show you that particular uh that particular thing also just a wait uh I have I have a code for that and I'm going to copy and paste see guys so what you need to do so over here I just written one for Loop and let me show you that particular for Loop and here see inside this for Loop what I have return so first of all I Define one uh list and inside this list we have a two description so the first one you know uh already I written this particular description now let me uh let me run it okay so what was the name of that so just a wait let me [Music] check okay where I have written this student I think this one so that name the name of the variable is student description so let me copy and paste over here let me copy and paste this student description so this is what this is the student description this is the first one so let me uh write it down a student description over here now let me keep it over here now student description now I'm going to Define one more so here I'm going to create one more variable and here student description two and here guys what I will do again I'm going to copy and paste a same thing so this is the value which I'm going to copy and paste and I'm going to some sort of a changes over here so instead of this s Savita I'm going to write down something else so let's say I'm going to write it down Krish n and here Krishna is a student of a computer science I uh maybe instead of this Delhi let me change the name so here is what here is Mumbai now here he is a cgpa so he's having more than 9.5 cgpa so let me write down this like cgp as well and here let me change the name so instead of Sunny what I'm saying I'm saying Krish is known for his programming skill and he's a member of here I can write down DS Club data science club data science club so here I am giving an information regarding two student now here see he hopes to pursue in a career in artif in after graduating something else right so now what I will do let me run it and let me keep this particular description over here so here what I'm going to do I'm going to keep this particular description now what I will do so over here uh I I'm just going to run the for Loop and here you can see one by one the description is coming and it is going through this particular uh completion API this Chad completion API and I will be getting a response so let's try to make some changes over here because it's a like old code let me give the latest one over here so this is the latest let me copy and paste the latest function so here is what here's a client chat completion. create now over here the model name is what model name is same now here message uh it's a same this one now let me write down the student so it will be more uh like clear to all of you so here uh you can see we are calling a function now here guys see we are calling which function this particular function let me copy the same name so here the function name is what student custom function so here I'm going to copy the name of the function and let me paste it over here so this is what guys tell me this is my function name and here is function call is auto right automatically the function is going to be called now what I want tell me I want a response so over here I'm going to print this particular response and let's see we'll be able to get a correct response or not so if I'm going to run it guys so you will be able to find out a response regarding two description so it is saying that chck completion is not a subscribable okay so over here I think I will have to paste this thing now let me copy it and let me paste it over here so this is the one I think it is fine now and this is going to be a response so response whatever response we are getting there is a choice and inside that we have a message and finally function call and from there we are going to collect argument so once I will this argument actually this arguments you can map this argument with this thing this uh thing basically which I have written over here inside the function name College grade and Club getting my point so here what I'm going to do now here I'm going to run it and let's see what I will be getting so once I will run it definitely I will get a response great so here it is giving it has given me a response regarding the first uh description and now guys you can see it has given me a response regarding the second description so the first one is s sabida and the second is kishna you can give as many as uh like description and all so over here let me take the third one and let me keep it over here and here I can say so here student description three three now over here instead of this krishak let's say I'm going to write down one more name let's say sudhansu Kumar and here I can say that he's a student of IIT Hyderabad or I let's say uh Bangalore now over here he's a Indian he's having a cgp around let's say 9.2 and his programming skill and he's a active member of mlops club now let me write it down over here ml Ops Club so now yes I have given this particular description over here and if I'm going to copy it and let me paste it over here so regarding this description also definitely we'll be able to call our model we be we call our API and finally we'll be getting a output it's doing a same thing which our chat completion API is doing directly without function right now we are doing along with a function along with the multiple description getting my point so here this is the basic use actually basic use of the function after this one I will come to the advanced use just wait now over here see if I'm going to run it so let's see what I will be getting uh so here I will be getting a First Response yes this is my first response now this is the second response and here you can see this is the third response getting my point guys yes or no we can call our llm model we can we can call our API we can hit the model and we can summarize the result according to the prompt if this thing is clear to all of you then please write it down yes in the chat please do let me know in the chat guys if this part is clear to all of you yes it's a case sensitive whatever variable you are going to Define in the function col it's a case sensitive so please make sure that you are going to write it on the correct name after this one the use of the function call will be clear just wait okay fine now this thing is clear to all of you now let me come to the next point so here actually what we are going to do see uh we are going to call a single function right regarding this particular description uh this is my function but we can call a multiple function also we can call a multiple function also so here guys let's say if you're are going to define a one more function here let's say if we going to define a one more function so you can Define any sort of a function over here let's say function 2 let me write it down over here function 2 function _ 2 you can Define a second function and after defining see you will Define in the same format whatever format is there this one in this format itself so in this format whatever format I have written now the variable and the parameter and the description U and those thing will be changed but the format will be a same because it's the same format which you will be find out over the tell me over the open API itself they already have given you that so this is what this is my function two now you can like Define a function to whatever information you want so let's say I just want this grade and club or whatever so right so if I'm going to remove it you can remove it or maybe you can Define one more function for some other information right and now if you want to call it so how you will do that tell me so for that actually uh here I have created this uh list right here we have created a list of the student information regarding a different different description now here again I can create one more list the list basically the list list regarding this function so here what I can do I can copy this code and I can paste it over here this particular code and here what I can do I can create one more list and inside this list what I can do I can write it down the function so here is what let me copy and paste so this see this is what this is my function parameter now here we have a first function and we have a second function so this is this is my first function which I defined already this one so let me copy this particular name and let me paste it over here this one so this is what tell me guys this is my first function which I'm going to write down over here and this is my second function already I given the same name so like this you can call a multiple function also getting my point so here I have defined this function and according to that I'm getting my desired output desired parameter you can create one more function on top of a same description and here you just need to do one thing instead of this specific function you just need to write it down this function you just need to provide this list and you are done according to the definition you will get output so this is your assignment you have to do by yourself I have given you the way I have given you the path now just Define a second function regarding whatever information is there inside the description whatever you want to extract just Define a function and call it over here so here I can mention this thing as assignment don't worry each and everything I will provide you uh this notebook will be available in the resource section you can download from there this is what this is your assignment guys now here this part is clear that uh we are calling up llm so here directly we are calling llm then what we are going to do see we have designed a prompt directly we are calling llm then what we are going to do we have defined a function then uh like we are getting that particular output that is also fine now we are going to call our llm by using openi with respect to different different description that is also fine means regarding a like different different description on the same time now we we can Define two function as well more on more than two function that is also fine now what is the actual use of it still we are not able to find out the actual use of this function everything is looking same now let me uh explain you that particular part I'm coming to the advaned example now so over here what I'm going to do I have written one Advanced example and uh let me copy and paste uh the code basically which I have written step by step I will copy and paste don't worry okay so here guys see again I'm going to start from scratch now Advanced example of function call Advanced example of function calling okay now over here guys see uh what I'm going to do I'm going to call my chat GPT so here I'm going to copy and paste one code now this code actually we have defined something over here so here I'm saying uh what I'm asking I'm asking to my llm that what is the next flight from so here I let me change the name let me write it down Delhi to Mumbai so here I'm going to write it down what would be the next from Delhi to Mumbai this is my PR now just tell me guys will my chat GPT able to answer for this particular question my CH chat GP is able to answer for this particular question the question which I asking over here I want your uh like p uh like I want your opinion on that please write down the chat I'm asking to all of you can my chat GP answer for this particular question no why why it cannot be answer because like this chat GPT has stayed on the limited amount of data right so not a limited amount of data it has Stained on uh the data basically which is available till September 2021 getting my point if you look into the chat GPD if you look into the open a just just go with the open a uh not this one so where it is this one so here guys just just uh go over here and uh what you can do you can go into the models now over here just click on this GPD 3.5 and uh just look over here training data so it has trained up to September 2021 data up to this particular data that's why it won't be able to answer for this particular question whatever I'm going to write it down here now let me run it and let's see the response that what response I will be getting so over here uh yes it is giving me a respon response let's wait for some time I got a response now and here I'm going to run it so see what it is saying that it is saying that as an AI language model I don't have a realtime information however you can easily find out next flight from Delhi to Mumbai by checking the website or mobile apps of Airlines so that operate the route such as air india indigo spice jet vistara goare Additionally you can contact travel agency or use online flight scratch engine for up to date now just tell me if you are going to create if you are going to create any chatbot by using this open API so will you give this type of answer to your user if your user is going to ask you that what is the next flight from Delhi to Mumbai definitely you will have to do some sort of a jugar right you will have to extract the information from somewhere you you cannot give this type of answer right so you will have to make your chat B that much of that much capable you you have to make your application that much capable so it can answer for this type of question as well okay now let me tell you uh the use of the function calling over here that how function calling can help to us so over here what I'm going to do here I'm going to Define one function what I'm going to do guys here I'm going to Define one function so this is what this is my function just just like observe step by step don't run anything don't write it down any sort of a code just observe whatever I'm explaining to you that's it so here is what here is my function function description now we have a name of the function get flight info we have a description get flight information between two location now here we have a parameter and inside parameter we have two things so the first one you will find out that is what that is a location origin and location destination so in my case what is the origin delhi now here in my case like whatever prompt or whatever question I'm asking in that case the destination is what destination is tell me Mumbai so there is two parameter I have here is a type here is a description here is a type here is a description that's it so let me let me change something inside the description also so here I'm I can write it down Delhi d e l and here let me write it down the Mumbai mu M mu M so this thing is fine now here if you will observe so I have mentioned one more thing I have mentioned one more parameter over here the parameter name is what the parameter name is required now what is required location required origin location required and destination is required two things is required over here okay that is fine till here everything is fine we are able to understand but still we didn't get a complete idea how you will get it first of all let me run the entire code right so here you can see we have a description so let let me run it and this is fine this is like perfectly fine now here I have a prompt so let me copy The Prompt over here I'm not writing from scratch because it might takes time so I already written in my notepad and all somewhere so I'm just going to copy and paste that's it so here guys um I'm asking to my chat GPD or sorry I'm asking to my GPD model when is the next flight from New Delhi to Mumbai this is my question now over here if I'm going to run it so here guys you will see that okay so this is my this is my user PR now what I'm going to do now I'm going to copy it now I'm again I'm going to copy the same thing this one and I'm hitting this particular prompt so here is what here is my model here is my role role is what role is a user and here is my prompt getting my point now here now I'm passing my function just focus over here just focus now over here I'm passing my function function underscore description this is what this is my function description now see over here uh this is my prompt and if I'm going to run it now if I'm going to run it now now you will see the response that what response I will be getting before actually I was getting this particular response before I was getting this response now just look into the response that what will be the response over here so here what I'm going to do I'm going to copy the same thing uh this particular thing and here I'm going to write it down response to response to choice choice message and cont so once I will run it so here you can see it's not giving me anything okay so why it is not giving me let me show you because there is no such content there is no such content that's why it is not giving me anything now let me print till message only and you will find out the uh the like values over here so over here guys see if I'm going to print till message so it is giving me a message whatever message I'm getting step by step we try to understand it don't worry now here let me copy this thing and let me check with this particular argument so here here I'm going to copy this argument and let's see what argument we have uh so over here it is saying okay first of all I need to call this function call and then only I can call this argument uh not an issue fine now over here we have a argument see we have two argument first is loc uh location origin that's a Delhi and location destination that's a Bombay getting my point guys see it is going to extract from here location origin and location destination and here is Delhi here is Mumbai there is a location origin location destination now it is not giving me answer but it is going to it is it is it is able to extract something right from this function call and here you can see these are this is two argument right there you will find out two argument this is the argument basically which we are able to get it from here because we have already defined it over here this thing okay that is fine this is clear to all of you now guys see how you will uh give this uh like flight actually so for that you will have to call any third party AP Pi then only you will be able to provide the information now right so let's say if I'm talking about the make my trip so what it does it is having access of a different different API if I'm going to book any train ticket so it is calling the IRCTC API and is giving me the entire detail make my trip is not a owner of the Railway where it is having the entire data entire information of the Railway Indian Railway no IRCTC actually it's a organization actually that is a portal which is like governed by the uh Indian government and like it it is having some sort of apis and all which is being called by the make my trip or any other website and because of that only you are able to get an information whatever rails and all whatever flights and all you are going to find out over there or maybe some other website right so here what you will do for getting this information you will call the API any third party API now here see I'm not going to call any sort of API I'm giving you as assignment this thing so you can call any sort of of API you can explore a different different API and you can exct the information from there I'm uh I can uh give you the very basic name rapid API just go through go and check with the rapid API there you will get the each and every API related to the weather related to the different different thing as of now what I did actually I created my own function which is working as a API I created my own function which is working as a API now let me give you that uh let me show you that particular function so here what I did I have created my own function which is working as a API you can think this working as a API but you can call your realtime API for extracting a real data don't worry I will show you that thing I will show you how you can call the Sur API in my next class when I will discuss about the agents in a l chain there I will discuss about the surp API and all so over here you can see guys we have a uh I have created one function get flight info location origin location destination now here I'm going to be uh like here I written some sort of a code that is what that is nothing as a flight information and it is in a dictionary format so here we have a location origin destination date time Airlines and flight this is the airlines line and this is the flight number and all now here this function is working as a API you can think like that now if I'm going to run it so over here uh is working fine now guys see what I'm going to do here so this function is working fine now here uh I'm going to collect this origin and this destination so first of all let me show you this particular thing uh argument I already showed you this one this is my argument and over here what I'm going to do I'm going to be convert this argument into a Json so json. loads now over here what I'm going to do so let me run it and here I am I having two argument uh first is Delhi and the second is Bombay this is my origin and this is my destination so this thing this information I'm going to collect in my like a variable that is perams now over over here we have a variable that is perams now from here I'm going to extract few more information I want to extract the origin and the destination so for that I already written the code let me copy and paste so this is my origin so I'm calling this get method on top of this uh dictionary actually this is my dictionary and I'm extracting a value of this particular key as like this I'm extracting a value of this particular key you you can see over here let me show you so this is what this is my dictionary now on top of this dictionary if I will call this get method now uh by using this uh key so get and over here what I will do I'm going to write it on the key so the key name is what location underscore origin now over here see if I'm going to run it now you will find out this Delhi so this is my origin and here you will find out the destination similarly I can get the destination also now it's not a big deal see now over here I can call this destination why I'm doing it entire thing will be clear and I will give you the quick revision also just wait for for some time just wait for more 5 minute everything will be fine so Delhi is there Delhi and Bombay is there so here we have origin and destination now we got both origin and destination right so parameter is uh we are able to get a parameter we are able to get origin and destination now let's try to find out the flight detail right so let's try to fight find out the flight detail so for that basically what I'm going to do here I'm going to call one uh so here I'm going to call one method that is a a right so what this EV will do so here actually I'm going to pass the name so let me show you this particular value what is happening over here so just a wait let me copy and paste over here so this is what this is the name this name is what this is the function name get flight information right now I'm giving this uh function name uh this uh function name this get flight info which is a string as of now let me show you the type of this function over here so over here what I'm going to do here I'm going to write it down type of this function so this type of the function is nothing it's a is string only so let me uh keep it inside the bracket so this is what this is a string now if I'm passing this thing to my EV function EV method so you will get the actual function this eval is doing nothing this eval is giving you the actual value that's it this is what this is the function now we have defined get flight information it will give you the actual value that's it so here you can see it is giving me the function only this is what this is my function this get flight info is what it's a function now it's not a string we have already defined it over here see this one so this is doing nothing it is just giving me actual value okay now let me show you one example very basic example let's say if I'm going to write down and here if I'm going to write down two now tell me what is this two if I'm going to write down like this uh type and here I'm going to write it down two just tell me what is this it's a string but two is a string no it's a integer right it's a integer so if I'm going to write it down like this now if I'm passing to my so it will provide an integer see this is what this an integer if you will check with the type so type the type will be an integer only so it is converting whatever value we are passing into the well method now it is converting into a original format into a original form so here we are getting a function so this is what this is my function which I collected over here now I just need to call this particular function so here I'm going to call this function now after calling this particular function I will be get see here I'm going to pass the parameter keyword argument keyword par like this this particular parameter params this one okay location origin and location destination this two thing we want over here this one right now once I will done it so here I will be getting my details so let me run it first of all uh where is a perms here is a perms and here is what here is my flight details so name date time is not defined let me Define the date time over here so from date time of date time import date time and it is done I think now let me run it time Delta is not defined let me check what all import statement is there just a wait time Delta also we can import from here itself so this is going to be a time Delta great now let me run it and over here you will find out a detail see so actually what we are going to do uh this function actually uh you can think it's a it is working as a API got it now here what we are going to do so we are extracting a information from the uh like whatever prompt and all we are passing now so from there basically we are extracting an information and we are collecting a detail of the flight okay from like this is the response actually see first what I did I defined a function this is what this is my function this is what this is my function right after that we are calling the uh after that we are hitting to the uh like model by by using this open API now after hitting it so actually whenever we are checking with a response so in argument actually in a function argument we have this two thing now by using this two thing now what we are going to do so we are uh like exting the information from here so as of now this is this function actually you can think it's my API but you can call actual API by using this particular information that is what I'm doing over here just just think over here that is what I'm doing so so now what I did what I got tell me guys so I I collected the information whatever see I Define the thing inside my function inside this particular function okay this what this is the value this is the like parameter which I defined now I uh I like called my model I called my open API and it is hitting the model right so whatever response I'm getting now from that particular response is I'm getting this particular argument because my chat GPT is not able to answer for this particular question and by using using this argument I'm hitting my API I'm hitting my API and after hitting the API guys you can see this is the detail this is the information I'm getting okay by using those particular argument now let me show you the complete one so once we are getting this particular information the flight information regarding those particular argument okay you can create an end application here I showing you in a notebook itself so here see guys what I'm getting now give you the final code so we are getting this particular information and is done now let me uh go for the final call so here you can see uh I can keep it as a uh response three client chat completion create now here is what here is my model and here is what here is my user prompt whatever prompt I was I'm passing now see guys over here see role is what role is a function now I have changed the role okay uh here is a role role is a user now role is a function now this is the value I'm extracting from the function whatever function I'm defined and here is is what here is a like content basically which I'm passing this is what this is a flight right so this is the argument which we are extracting from the function whatever function I've have defined right and then this is what this is my function description that's it right so here see guys uh my role role as a user as a role as a user basically what I'm asking to my uh chat GPT or sorry to my GPT model let me show you that so over here what I'm going to do I'm going to print it this user prompt this is my question this is my prompt this is what basically which I'm going to ask right now over here Ro again I defined one more role that is what that is a function right now over here I'm going to pass the name and here I'm going to extract the like function the the extract exact function over here you can check over here you can like copy it and you can paste it over here this one so just just paste and you will get this function called now just collect the name name of the function do name so what is the name of the function get flight info right now here is what content is nothing content is a flight now as soon as I will done it so here you will be able to find out that we are able to extract the information now let me show you this response three so here is what here is my response three and guys see what I'm getting over here so let me print the final one and here you will be able to find out a detail so let me run it see guys so now let me call the uh this uh function call just a second function underscore call function underscore call and over here guys you can see we have argument and actually we have a message over there just a wait let me show you that also uh function call and argument okay just a wait uh message inside the message itself I will be able to get it uh where my message is coming inside the choice and here okay I need to call a Content actually just a second message function call this is my function call that is fine now here Choice uh just a second choice what we have inside the choice okay it is a response three fine fine fine I was checking with the response too uh yeah this was a response now it is fine it was a response three I was checking with the response two it's my bad it's my bad U okay now let me collect the message from here so here is what here is a zero and now let me call this message so here is my message and let me collect the content content and here is what here is my content guys so did you get it what is the use of this function calling now let me give you the definition of this function calling in a single line so just a wait I'm giving you the definition and definitely you will be able to relate now so if we are talking about this function calling now so here is a definition of it let me copy and paste so what is the definition of the function calling so function calling is nothing learn how to connect large language model to the external tool that's we can define a function we can Define the parameters we can Define the values and according to that we can get our responses from the third party API and here I have defined this particular function mine function is a third party API but you can call the realtime API and you can get the information you can get the exact information this thing is clear to all of you yes or no how many of you you are able to get it how many of you you are able to understand this thing if you can let me know in the chat so I think that would be great again I will try to revise it uh I will give you the quick revision of it and then I will move to the length chain will you revise it please do let me know in the chat will you revise this concept I'm waiting for reply if you can answer me in the chat I think that would be great yes I'm going to revise it just wait just give me a second for first of all uh do let me know how much percent you got so if you can tell me uh in a percentage also so that would be great I will get some sort of idea that okay you are getting something from here whatever code I'm writing you are getting from here so please uh do let me know 80% great 70 70 80 yeah if you're getting 70 or 80% now so I think rest of the thing like you just need to revise Sor is saying sir I'm just getting 10% so s of in that case you need to follow from a very first session just check with the very first session and then come to the second one and then come to this third one if you are near to 70 to 80% now then you just need to revise it once that's it yes correct uh your understanding is correct here we are extracting value from given prompt using function call what is the meaning of the role is equal to function which one here we are defining now see we have a user so user is asking a question and rest of the information we are going to collect from here we are defining one more role we have we can Define many roles over here um we can Define uh like uh we can Define the system we can Define role as assistant we can Define role as a user we can refine role as a function user is asking something and uh and uh from wherever basically we are going to be get output or we are getting a uh we are we trying to exct the information regarding this particular prom so we are defining as a role over here that's it great so let's revise it now and then I will go for the Len chain so we'll try to understand the Len chain and all already I have installed this l and try to hit the open API and tomorrow we'll understand the lure in a very detailed way uh today uh just uh quick uh understanding quick uh uh first of all I will give you the quick recap of all those all this thing and then I will come to the langing part so let's understand this function calling one more time from scratch great so over here see we are talking about this uh we are talking about this chat completion API and I think you know about it how many time we have discussed so we're passing the prompt here is my prompt and we are getting the output now today I have started from the like a different type of prompt so uh today I have started from the function calling so here I have defined one description and here I'm am writing uh the prompts my prompt is saying that uh here you need to extract this information from the given description that's it now here you can see uh this is my client this is what this is my client now here I'm going to call my chat GPT and sorry I'm going to call my GPT model so after that what I'm getting I'm getting my response I'm going to convert into a Json and this is fine right this is fine anything you can ask to your model and you can print as a response you just need to define a prompt that's it now here the same thing I'm going to do by using this function so here I'm going to do uh the same thing by using this function now here I'm going to define a separate parameter so this is my parameter name College grade and Club it should be a same similar to this prompt itself whatever prompt I have defined I have written right so just look into the prompt I will share this notebook then you can check it should be similar to that only this particular properties this particular values now over here uh you will find out that okay again I'm going to call it again I'm working I'm like role I've defined as a user there's a prompt and you are getting a response and here you are getting a response now guys here you can see we are going to print a message and finally we are getting a same thing by calling this uh by using this function call as well now here actually once you will look into the prompt we have defined one thing over here we we are saying that uh return it as a Json object return it as a Json object so whatever response you are getting now from the openi side also I tested the same thing of the chat gptc I given the description this was my description and CH jpd has given me output is a Json format so if you are calling it now uh this uh like a GPD model so it will give you the output in a Json format this one so here it is giving you the output this particular output in a Json format this one actually it's a string but yeah we can convert into a Json and that is what I did now the same thing we are doing by using this function now over here H it's fine it's killar now here I've given you few more uh like functionality regarding this function I can call it for the several description in a single S I just need to keep the for I just need to write down the for Loop over here so I'm getting a multiple responses for sunny for Chris for sansu right so here I'm getting a multiple responses now here I given you an assignment so here I told you that you can call a multiple function also don't call a single function here I'm getting information from the single function but you can call a multiple function and here I shown you the way you just need to define a function in a list and that's it so here is a function just need to define a function in the list and just pass it over here and according to that only you will get a response getting my point now here I have shown you the advanced example of function calling and that's a real use of the function and here if you want to Define this function in a single word in a single line if you want to understand this function in a single line so here you can see this is the definition learn how to connect large language model to the external tool so here what I want to do so here let's say uh this is my model and here I'm going to write down some sort of a prompt where uh like it is going to be a request and here I'm getting a response now this prompt actually it's something uh related to a real time I'm asking a real time question that just give me the flight just tell me like what all matches uh we have in upcoming days or uh just tell me the weather okay something like that so I'm asking a real time information it won't be able to provide it to me in that case what you will do so you are not going to call your llm now because it is not train on that uh on it it has not been trained on top of that data actually if you are talking about this GPT so this GPT actually trained on this uh till actually till September 2021 so this GPD train till uh 2021 only now in that case whatever prompt you are going to be wrri it down you won't be able to get a response right so here here this function calling comes into a picture so once you will Define the function now so here what you will do you are going to define a function you are going to Def Define a different different arguments and all each and every information you're are passing to this function that's it now you just need see here this argument what you will do by using this particular argument you will call a third party API third party API third party API now you will call this third party API here or whatever function you are going to Define and whatever prompt you are writing according to that you will get a response because this llm is not able to provide you the response right and the same thing the each and everything you can do by using the chat completion API only chat completion method you can see chat completion API or CH completion method both are fine by using this chat completion method now let me show you in terms of coding so over here if you look into the code so I'm doing the same thing here I have defined a function see this is what uh first of all I'm asking to my first of all I'm asking to my uh llm model it is not able to answer now after that what I did I defined the function got it after that I defined the prompt I'm passing to my model I'm passing to my actually uh this uh like chat completion method so here is my user here is my prompt and here is my function description by doing that what I'm able to do I'm able to extract few of the uh few value whatever is there inside this function whatever I have defined over here because here I'm writing in this function description now after that this value I'm using and this is what this is my API okay this this is my like it's not a real API it's like a virtual API whatever you can say now whatever value I'm passing whatever uh thing I'm collecting from here I'm passing to this API and I'm getting a response over here this is the response this is my response got it now what I will do here now I compiled each and everything over here inside this chat chat completion method so how I compile this is my model this is my prompt this is my user this is my prompt this is my function call this is my function call along with the argument and over here this is my function that's it if I'm going to run it now is going to extract the information from the third party API which is my function as of now now you can take as assignment you can call the real time API you can use the rapid API you can do that you can call a real time API so now this function calling is clear to all of you you yes or no correct ran your understanding is correct now your understanding is correct and I think you are able to get it now let's start with the length chain so we have a 10 minute uh now we can understand the concept of the length chain and then from Tomorrow onwards I'm going to start with the length chain now first of all let me write it down the uh code for the length chain so here I'm going to write it down length chain and here uh you can I can mark down it and uh so first of all guys what I need to do so I'm going to start from the Len chain uh so the first thing very first thing uh I need to import it so let me give you the entire code okay so step by step let me write down each and everything so first of all I have to import the length chain so here I'm going to write it down import length chain now here I uted the Len chain now from this like in this Len chain actually we have a different different modules we have a different different module and inside that we have different different classes so as of now we are going to use the open AI so here I'm going to write it down from lenen from lenen we are going to import this open AI so lenen llms and here I'm going to write down this open AI okay so we are able to import this open AI now what I will do so initially I told you that this lenon is nothing it's a wrapper on top of this open AI so you can think that this is my open AI right this is what this is my open AI now on top of this open AI on top of this open AI API this Len CH is nothing it's a wrapper okay so this is what length CH now here whatever request we are making whatever request we are making right so now we are not directly using this open a now we are not directly using this open API instead of that we are using this Lang chain so our request is going through to this Len chain and then it is hitting this open AI but this Len chain it is not restricted to till here itself we have a many uses of the Len chain getting my point this length chain is not restricted to this one only we have a many uses of the length chain I will talk about those users and this link chain actually it's a very powerful uh it's a very powerful application it's a open source I will show you the source code as well even we can search about it so let me show you that uh let me show you the source code of the Len ched so here I'm going to write it down Len Chen Len Chen GitHub so here is what guys here is a lang chain GitHub uh just a second yeah so this is a lang chain GitHub now you will see the number of folks the number of star number of folks number of star number of watching right so number of watching in the real time and this L CH it's really amazing let me give you this link inside your chat please try to uh explore it by yourself and it's a very uh powerful and so very important as well if you want to build any llm based application so you can use the Len CH it's a it's completely open source and here you can see used by 40,000 people and here is the number of contributor you can also become a contributor if you like to contribute in a open source now here you can see the commit 7 hour ago they committed something just just go through with this commits and check what thing they have committed what what changes they have made over here try to understand it and this package actually it is available on the pii repository so just go over the pii repository pii Lang chain and search about the Len chain and here you will find out this Len chain this is what this is a len chain guys this a like they have hosted the package on pii repository and it is a latest version of The Lang CH now here also just just uh scroll down here also you will find out the same thing uh deployment so they are doing a deploy here is a package package see this is the release so 0. 0.346 0.0.3 46 this is the latest uh version which you can see over here as well this one is uh so far they did 297 release total 297 release see this is the total release actually total number of release now you can see over here as well just go inside the real uh just go just click on this release history and check the uh entire uh like release related to this Len chain got it so here is a latest version of the link chain similarly we have a llama index 2 also this lench is a open source and the Llama index 2 is a framework from The Meta we can do a same thing by using this llama index to also I will come to that I will come to the Llama Index right now over here see we have this Len chain we have this open ey now let's try to create now let's try to create object of this open Ai and here what I need to do guys tell me here I'm going to here I'm going to pass my open a key so first of all uh I will have to pass the parameter let me um give the parameter over here and here I need to write it down this my key and here is what here is my client right now I just need to call one method and my method is going to be a predict right so my the method name is going to be a predict so let me write it down over here client c l i n t do predict now here what I need to do here I just need to pass the prompt prompt is what prompt is a input whatever input we are passing to the model that's it so let me Define the prompt so here I'm going to write it on the prompt and this prompt let's say I'm going to ask to my model what I can ask so I can ask can you tell me total number of country total number of country in Asia so here is my question so I just asked a little tricky question not a tricky actually it's a straightforward so uh here is my question my question is what my question is can you tell me total number of country in Asia now this is called guys zero short prompting what is this tell me this is called zero short prompting this is what guys tell me this is the zero short prompting now here if I will run it and here if I will pass my prompt to My Method client don't predict so here you will get output so here it is saying that there are 48 country in Asia if you would like to uh if you want to name then here you can mention can you give me can you give me top 10 country name so here uh I have extended the question now and now see over here I will be getting a name of the country so it is giving me the Sash and S selection is nothing it means it means that if I'm going to print it now so it will print after two line so for that what you can do you can just call this strip strip STD and it will strip your output so here you will find out the correct output so there are 48 country in Asia the top 10 country by population in Asia these are the country now here if I'm going to write it on print so you will get a output in a correct format so here guys you can see you will get output in a correct format so there are total 48 count in Asia and these are the top 10 countries China India Indonesia Pakistan Bangladesh Japan Philippines vnam Iran and turkey got it guys how to use lench I just given you the introduction of that but but there are many more things so all the things uh uh the remaining thing definitely we are going to discuss in next session as of now just think that this uh lenen is nothing it's a rapper on top of the open a but it is having a lots of uses it can call any third party API it can call any sort of a data resource it can uh like uh it it it is having a power to read a different different documents it's a having a power to making a change to making a memory it is having a power it is uh it is not only for the open AI we can use this lenen for any op Source model any open source llm model and tomorrow I will show you here I have used so let me write out tomorrow's agenda what all thing we are going to discuss tomorrow tomorrow uh tomorrow's agenda so we are going to uh cover hugging phase hugging phase API with with Len chain uh and we'll try to understand the use of the Len chain use of the Len chain so we'll try to understand this use of the lenen in very detailed way so this will be the agenda for tomorrow's like this this is the agenda for tomorrow's class and after that I will directly jump to the project we'll try to create one project and with that your understanding will be clear and rest of the topic we'll cover after after the project and all so tell me guys how was the session did you like this session uh did you uh did you got everything yes or no whatever I have explained yeah meanwhile you can explore it by yourself that is a good idea tell me guys fast uh did you like the session please do let me know in the chat if you are liking the session if you're liking my content I written I I created each and everything from scratch by myself only and believe me if you are following this or notebook if you are following my content you won't face any issue and even in our interview also you can answer in a better way okay so I think uh now uh we have covered all the thing whatever I told you and uh yeah all the resources and all you can find it out over the dashboard so we are uploading each and every resources in a resource section so just visit the dashboard and here uh we have all the videos videos and quizzes assignment each and everything we are going to update over here so along with the session you can practice now here uh we have our resources regarding the first session so all the all the PDF and all all the PPT so at least you can revise the thing you no need to go through with the video again in again you can directly uh download the resource and you can look into that if you have attended my live session and here we have a ipb file also so just visit this uh resource section and this is the ipv file now I will update this ipb file in my day three video and along with that we'll be having some quizzes assignment and don't wor I will give you more assignment more quizzes and see in between whatever I'm leaving so here I told you that you need to create your own API this one uh in an advanced example of function calling so just use any API okay just search over the internet I told you you can use Rapid API and try to get a realtime data instead of this uh dummy function which I created over here you can take it as assignment here I told you that you need to you can use multiple function right in a single shot just try to create one more function function define it in your in your own way and then uh run it and get an information so here I'm getting an information regarding three user you can add more user and you can add multiple function over there got it so yeah this is it from my side and tomorrow uh is again we start on the same time 300 p.m. IST so don't miss the live session if you are liking the content then please hit the like button and subscribe the channel so we'll meet you soon uh we'll meet you in the next session thank you guys thank you bye-bye take care
Info
Channel: iNeuron Intelligence
Views: 7,228
Rating: undefined out of 5
Keywords: ineuron, langchain tutorial, LangChain Easy Explanation, LangChain Crash Course, LangChain, langchain 101, introduction to langchain, langchain openai, langchain demo, langchain in python, langchain prompt, langchain, #ineuron, langchain crash course, langchain ai, what is langchain, langchain agent, langchain ai tutorial, langchain prompts, langchain prompt template, langchain prompt template example, langchain prompt tutorial, python langchain
Id: UfdW5GvOjoA
Channel Id: undefined
Length: 119min 26sec (7166 seconds)
Published: Thu Dec 07 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.