tool or a data processing step, right? So the primary support, uh, supported way to do this is LCL. Now basically the primary supported way is nothing LCL. Uh, we forgot about this. uh, we forgot about this legacy chain and all So recently I have introduced couple of classes if you will look into my previous tutorial, Uh, there actually I discussed about the history of a retriever Okay. And uh, in between I was using the create stuff document chain, Okay. Like these kind of chains and all so guys, these all the chains, this latest chain, actually, it is inspired from the LCL only means uh, like the development developer has created this particular classes, okay, directly you are using, but in back end, the concept or the which concept is being used, they are using the LCL concept, L-Lang chain, expression language only. So what is the syntax of the Lang and expression language? How to do it? How to write it? everything we are going to disc over here, got it guys. I hope it is clear, right? So just look over here. You can read about this as well, chains basically. uh, how to chains that are built with LCL. In this case, L-chin offers a high level construction method. However, all this being done under the H in constructing a chain with LCL mean, they are saying LCL, basically it's a way of defining a chain, whatever functionality is there, they are defining it in a back end. Okay, you are just need to use the high level abstraction, Okay, operator syntax only no need to go inside the in-depth functionality. right. Then they are talking about the legacy chain as well. So legacy chain was nothing. It was just a simple classes. Okay, as we know, now, let me do one thing. Let me go with this latest version of this L chain. Okay. and let me show you what they have defined with respect to this LCL. So here they are talking about this LC. Okay, and here, uh, it's a complete, uh, like a detail of it. Okay, so you can find it out now, uh, inside the LCL, what is the LCL? See, LCL designed to stream line the process of building useful apps with LLM and combining related component and all okay complete detail. So let me uh, show you some uh points with respect to this LCL the important point, Okay, which is very much important. So uh, once you will go through with it. uh once you will click on it, okay, this LCL so here they are giving you the different different points. See uh first it support to this streaming. Okay, what is this streaming? I will let you know I kept this particular point inside my notebook at the end if you will look into it. See here Now after the streaming guys see what they are doing. So just a second this one. so async support. Now what is this async support asynchronization? Python is having one library asyn right? So uh that also support by that this LCL also support this async. Okay, Uh, for the faster inferencing and here I kept the graph and all everything just to explain you the meaning of the async here. See I I will let you know what it is async and the synchronization and then after optimize parallel execution. so I was talking about the runnable of right runnable classes so this will provide the parallel execution Okay, we can do it retries and fall back right? so as many as time basically we can retry it. Okay, we can create a fallback, right? Uh, what is the retries and fall back? I will let you know okay in sometime once I will create a chain you will get to know access immediate result so you can access the immediate result as well input and output schema, right? so this is the this is the like, uh important point, Okay, beh like uh that why we should use this LCL maybe it is not being clear, Uh, if I'm teaching you this verbally, but no need to worry about it guys once I will implement it in terms of practical, most of the thing is being is is going to be clear. Okay, now guys apart from this one see chains and all everything is clear, Okay. Uh, so here if you will look into this documentation itself, you'll find out, uh, they are giving you many more thing with respect to this LCL. So, uh, here guys, L and expression language. Uh, so once you will click on it, so this is a complete detail which you are reading. Now here is what here is a runes. okay. This runnables actually, it's a class, okay, which they have coded in a back end. And this is a use code. If you will go and check with the Github itself. So you'll find out this is a huge code, right? Just look into the number of lines. so around 5,863 line of code. Okay, this rebles runnables Basically it is including all the runable like runable parallel runable uh, like uh, runable lambda, Okay, Runable pass through right here is the LCL cheet seat. right? There are so many things with respect to the LCL they have provided but our main aim to understand it like just with respect to our application only that's why I have concluded it inside this particular point. So if you know about these points, right, if you know about these particular points with respect to this LC you are good to go right, no need to learn anything else apart from this one. So guys, uh, here I will provide you this important link inside the like description so that you can go through with it. And if you want to learn something extra, you can learn from your own. I hope it is getting clear to all of you. Now without wasting a time, let's start with the practical for practical guys. We required couple of library here. I install it. So here Google Gener, VI Lin Community Lang chin Langin, Hugging Phas. Okay. And Lenin Gro. So, uh, here I install it. Uh now I defined the I like, uh, I set the API key, Okay. As an environment variable here. Also, I set the API key as an environment variable. Uh, so why I'm using this GRo in this Google API so that anyone of anyone I can use from anyone I can use for accessing the LLM model, Right. So Grock API key basically grock. it gives me the, uh, like what it gives. So here you can see it's a like API key. Okay. Grock API key Now it gives us a model. So different different model, different different LM model. Okay. they have hosted it somewhere. You can directly read it, Okay, for your like purpose means for your PC purpose and all or you can deploy it as well. It is up to you now. uh, here you can see Google API key. So if this is not working well, I can use the Google Jimney model because till some extent it works well. Okay. This Google Jimy model, I seen that compared to the open source model. Okay, so you have both choice, any one of them you can use. So I kept this code as well. So if you want to use this one, you can go ahead, go ahead with it. Otherwise you can use the Google one as well. Uh, other we have the open a cloud a uh we have like Jurassic right many more models. So there is no limitation of the LLM and all nowadays Uh and but yeah, some model basically perform well I know uh, like OpenI based model uh even this uh Jimes model as well. Okay different different variant of the Jimes and cloud also it's a good one with respect to couple of tasks. So yeah, any of them you can use it is up to you only now See so we got the LLM And after getting the LLM what I'm doing here See here is what here is my prompt template. Okay this one a very simple prompt template. I'm saying hi am a learning skill. Okay, can you suggest me five things? Now what I'm doing See here I'm creating a prompt template. I'm passing my template over here. Okay, I'm getting what I'm getting my prompt. now this particular prompt I'm passing to my LLM chain. So inside the LLM chain I have what I have my prompt and this LLM both component now I have uh what I did I just running this LM chain lM. run and I'm passing my scale value. so it is giving me a complete detail okay this LLM is generating the answer based on what based on this particular prompt getting my point. Now here we can pass the skills inser in this way as well means we can pass in the form of key and value means this is what This is my key skill. Okay and here is what here is my uh, like a skill name. So skill is what my key and this is what this is my value. So yeah see uh in this in this way. also it is generating the output. So this is called, uh, like a simple chain. Okay. So here I can write one thing. Uh, here I can give the text. This is mine. This is mine simple chain. And this is my old chain. Okay. So here I can write, this is my old chaining concept. I hope this is clear now. see if I want to do the same thing using the LCL. So how I'm going to do it, let me show you that part as well. So first guys, what I will have to do, I will have to keep the LLM. See here is what here is my LLM right inside this particular variable. Then what I have, I have my prompt template, P-R-O-M-P-PromP template. Okay. I think this is the one. only now let me check prompt is here. Correct prompt is here. Now what I will do, I will take this particular prompt. So let me take this prom. Okay and here I can use the pip operator and see here is what here is my LL. So guys now this is become my this become my chain. So uh here what I can do, I can call this chain. Okay. so uh, I can call this chain with invoke. So this chain is having this invoke. Uh, why? How I can call this invoke on top of see here, I'm not going to here actually I'm not going to like create any sort for object but how I able to create an invoke on top of it because this both classes this LLM and this uh prompt actually it is having an invoke method. If you don't believe me, you can check with the API. So just go and check with this prompt or template API. Okay, API from provided by the lecture itself. So you will get the complete detail of it detail of the different, different parameter and function. So just scroll down. Uh, once you will scroll down, you will get the different different methods of it. See, uh, in between you will find out somewhere you will find out the invoke. See here is the invoke method, right? And many more method is there. So this, uh, LLM class, this, this particular class, this prompt actually it is is having a invoke method. So that's why I'm able to call it. Now what I can do, I can simply uh, call it. So let me call in this particular way. So here we can pass the sk as a key. And here is a value. Okay, value is what value is a big data. Now let me execute it. And what I'm getting here, I'm getting my complete detail, see how simple it is, right, how simple it is. Now let's say if I want to add on one more components over here. So for adding the one more component, I can simply import this output parsel. Okay. Now after doing it, see here, I can create a object of it. So let me create a object of this output parer I can keep it inside the variable. So my variable is going to be parer. Okay. Now what I can do, I can, uh, combine along with my chain. Now this output parser also, uh, this output parer also will be having this invoke method, getting my point. Now what I can do, I can connect with this, I can connect this parcel now, see how easy it is, how easy you like to create this particular chain. Now what I can do, I can print this particular chain. So here instead of this big data, I can provide the machine learning. Okay, so here I can write machine learning. Now see what I'll be getting. I'll be getting my output in a precise way because here I'm using the parcel, which is parsing the output. Uh, so I hope this is clear now how it is, how easy to create a chain using the LCL as you, you can see. So let me write a comment over here. So this is the implementation. Let me write a comment. This is a implementation simple. I use it just to take the input. So this is also taking an input. This is also taking an input. This is also taking an input. And that's why we are getting this particular output right. What is my input? This is my input. And here is my output. If you will change it. Welcome to my welcome to my Youtube chanel. Welcome to my sun's Youtube channel. Okay, so welcome to Sun's my Youtube channel. So here what i can do, I can put like this and see getting my point guys. I hope it is getting clear Okay, as many as time you will execute it, you'll be getting this particular output, whatever you are passing as a input. Now guys let me add on few more thing over here. Let me explain you the work of the lambda Okay, runable lambda. So what i'm doing guys here, I'm going to create a chain now. Inside the chain i'm going to connect. I'm going to like uh, connect two component first is runable pass through which will take any sort of input and enable lambda basically for what it is executing the function. Let me create a function over here. So what is my name? So here the name of the function is, uh, str string upper. Okay, I have to convert my string into the upper case So whatever input I will be getting from the runable pass through, right? I will just call this input. upper. Got it guys. Now this method, actually, I can pass it to the this method, I can pass it to the renable lambda. Let me pass it over here. And here is what here is my chain. Okay. chain. Now what I'll be doing, I going to pass the same thing to my chain. Now you'll find out the guys what is happening over here. See, enable, pass through. It will take the input and this particular component, enable lambda, It will based on this particular method. Okay. It will be working. This runable lambda is nothing. It is using the lambda function behind it. Okay. And like whatever method, whatever input and all we are passing b according to that, it is working right now, guys. See, let me execute it. And here, here, here, you'll find out that here, here you'll find out this input actually is being converted into the upper case, getting my point. I hope this is getting clear. It is very easy. Now let me do one thing. See, I was telling to you this method. Okay, this this class, this class or this method, it is supporting to this invoke method. Understood this method, this custom method, Does it having a inv invoke method? Let me show you. So here I am going to call uh, just a, I am going to call the invoke on top of it. Or I can take this one. See, I can take this one. I can pass it over here and you will find out, guys, it is generating an error. why it is generating an error because is not having this invoke method. But this method, okay, this method, this class, whatever thing, I'm going to write it down over here. it is having access of the invoke method. The code has been written in such a way. In back end, I hope it is getting clear, right? It is not very much difficult. You just need to understand part. So now what I'm doing here, see in industry, you have to work it, you have to work like this. I will show you the complex chain, very, very complex chain. I kept one example for all of you. This one, and you have to implement it from your end is complete code, a very amazing article on top of the LCL. I just figure it out for all of you. You have to work on top of it. You will be industry day guys. Blame me now. what I'm doing. So yes. Uh, this is perfect. Uh, this is working fine Now let's look into the other example Uh now guys one more example I would like to show to all of you Uh Here here, here, Uh what I can do I can use this runable lambda so simply I can uh, keep it inside the chain t h a i n And what's the name of it? What's the name of my method? Check out the name is string upper so here is what here is my string s str r iing Okay, the spelling is not correct s r iing. Okay now perfect Perfect perfect And here s strg Perfect. Okayng Perfect. This is a error. Now here is what here is my chain Now what I can do I can call this particular invoke on top of it. Okay, so here I'm writing invo and what I can do, i can pass my message. So what's whatever message I'm going to pass so it is going to be converted into the uppercase Okay, so see it's going to be converted to the uppercase and yes, it is working fine. Now anything you can pass it will work There is one more way I can pass the multiple input also, Okay, so here see runable parallel, this runable parallel what it will will do it will create two separate branch, okay, it will create the parallel execution Now one is for what one is for this uh, particular input okay which is I'm which I'm will be getting inside the X and what one for this particular input which I will be getting inside the y getting my point and this runable parallel b, what it will do it will create two parallel execution. I'll show you this particular example with respect to the rag only so don't worry about it. Uh, this is my duty to explain you about uh this thing where it is being used now let me do it let me pass some data, Okay, so here guys what I'm passing let's say I'm passing my name to this one right now so here I can write invoke invoke and And uh here I can pass name let's say sunny so what I'll be getting See x sunny, y sunny getting my point so parall it is creating two execution this one and this one I hope it is getting clear now let me show you couple of, uh uh let me show you a couple of like difficult example now let's look into so now guys what I did over here, See uh instead of taking this uh simple input I'm uh, I written this dictionary so uh once i will call it chain. invoke what i'm getting now see inside the x i'm getting this dictionary inside the y also i getting the same dictionary y because at both places i'm taking this input understood and this is working in parallel using this runnable parallel i hope it is clear now see uh what i can do i'm uh calling this runable parallel in x i'm taking the input from the user okay and in y over here okay a second this one over here what i'm doing here i'm calling this lambda method lambda function it's my own lambda method lambda function i'm not calling that runable lambda i will include it that later on not right now so here is my key and in the value I'm using so see what i'm passing here uh i'm passing this particular dictionary okay so once I will pass the dictionary let me run it let me executed. so this is what this is my chain I am passing this dictionary okay once I will pass the dictionary you will find out the output so inside the x i'm getting my input okay this one whatever input whatever input I'm passing which because I'm running this runnable pass through and here inside the y okay inside of this y i'm keeping this blog so inside the blog what i'm getting see here so this blog is coming uh from this particular x from this particular x what I'm doing I'm going to be capture this block and this is my block and this particular value i'm going to assign over here okay this particular value I'm going to assign over here i hope it is getting clear see it's a simple lambda function now you can do one thing You can take it separately and you can keep it like uh, you can keep it over here. So what is this? It's a simple lambda function means whatever x value is coming means this dictionary is coming from there itself. I'm going to extract the blog value. that's it. Nothing is there. Okay, now see guys one more thing here. Uh, we you can do like one more thing. I'm just increasing the complexity step by step and then we'll create the rack pipeline just to showcase you how this thing I have implemented in my previous videos But now you are getting it Why tell me? Because here i'm explaining you each and everything that's fine. and guys if you're watching till here then please uh subscribe the channel hit the like button and write the comments share with your friends and all whoever is required this type of content and in future I'll be coming up with many more these type of videos and content. Okay, now Uh here what I'm doing. See here I created one method this a fetch website, What it is doing. It is taking an input. The input type is what it's a dict. Now here I'm calling this input. get okay if there is a website if there is a key website will return that otherwise it will say not found. Let me show you how it is working then you will get to know So this is my method. Okay now here I'm taking the input I'm taking an input from the user. Okay this one this is my input this one. Now from this input what I will do see here once the input will come I will pass it to over here. Okay to this runable lambda here. I will pass this particular input, uh, to this runable lambda. Now this is what this my dict now from here what I'm doing, i'm searching this website. Okay, do we have website over here Inside this particular dictionary? No, we don't have this website. So what it will do, it will return this not found. And where I will get, I'll be getting it over here. Okay, let me show you how it is working Then you will get to know So first of all okay first of all let me execute this particular chain latest chain And here is my output. See what is happening. It is saying website not found. But