Hello guys.
So we are going to continue the discussion with respect to our Langton series.
And in this video, we are going to create a generative AI application with the help of Lama uh, where
we will be using open source models.
So let me quickly go ahead and open my files.
So here you can see these are my entire files over here okay.
And I can do all this task which we did with OpenAI.
But here I've created another folder.
So let me just go ahead and create my app Dot Pi.
And we'll try to create an end to end project.
Okay.
And this end to end project we will be using Streamlit and we'll be using some requirements.txt and
all.
Okay.
So first of all, uh, as usual, uh, what I'm actually going to do quickly, first of all, let me
just go ahead and open this over here, okay?
I will be using all this information.
Okay.
Over here also, uh, because I really need to have I don't need to have OpenAI key.
Okay, I'll remove this.
But for my language tracking, I need to have all these particular values like API key and all and.
All right.
Now, uh, quickly, uh, what I am actually going to do is that, uh, from I will go ahead and, uh,
import some of the libraries and for importing some of the libraries, I will go again over here.
Okay.
Let's go ahead and from Lang Chain okay.
Underscore community.
Now ulama is basically present inside this uh, library itself long chain underscore community because
ulama Olama is something is just like a third party integration where you can use various models.
Right.
So Langston underscore community dot LMS.
Okay.
If you use this, I will be able to import Olama.
Okay.
And Olama will be specifically used in order to create my, uh, LM models.
Okay.
So here we have this olama.
Okay.
Um, along with this, you'll be able to see that I'm going to use Streamlit.
So let's go ahead and write, uh, import Streamlit as st.
And since we are working in the virtual environment right now, Streamlit is not available.
So let me just quickly go ahead and install this also in the requirement dot txt.
So here in my requirement dot txt I have this uh let's go ahead and install this so quickly we'll go
ahead and write pip install minus r requirement dot txt.
Okay.
So here you can see all the installation will start taking place.
Uh, and uh my Streamlit library which is the recent one that will also get installed.
Okay.
So let this installation takes place.
It will probably take some amount of time with respect to this.
Now I'll go to my app Dot Pi.
And since you know that I have imported Streamlit as St.
Along with this, I will go ahead and uh, from lang che dot from lang chain underscore core.
I'm going to basically use long chain underscore core dot prompts.
Okay I'm going to just import chart prompt template okay.
Chart prompt template.
So chart prompt template is basically to design my own chart prompt.
Uh like what I really want this open source models to do.
So that entire thing I will be defining in this particular chart prompt template like how we did it
in the simple app.
Right?
We also imported this C over here somewhere.
We have used chart prompt.
Right.
So if I go and show you down this is what is my chart prompt template.
Right.
So I'm going to also going to use it over here.
Now once this is done uh now let's quickly go ahead and right from uh from line chain okay.
So I think the installation has been done right.
It's complete.
Perfect.
Uh, so we are good to go.
Let me do one thing.
Let me just hide my face so that you'll be able to clearly see the text.
Okay, then.
Uh, quickly, I'll go ahead and write from Langston.
Underscore code, dot output parser.
I'll also be using this string output parser SDR output parser.
Okay.
So all these things are there.
Okay.
Now quickly let me just close this file and again open it, uh, so that I'll be able to load all these
libraries.
Uh, clearly.
Right.
I don't know why this libraries are not getting loaded, because, uh, we'll just be able to see some
green color, something like that.
Okay.
Uh, but since we are using Streamlit, uh, let me do one thing.
Let me just quickly run this.
So in order to run Streamlit, I will just go ahead and write Streamlit, run.app.py.
pi.
So quickly you'll be able to see.
Okay app dot Pi does not exist.
It's okay because I need to go inside this particular folder lang chain and then Olama.
Okay.
So here I will go ahead and write CD, uh CD one lang chain.
So inside this particular folder I'll go.
Please make sure that you see this, how I'm running this particular file.
Because this app dot Pi is available inside this 1.20 llama folder, right inside one lang chain and
1.20 llama.
So I will go again back to this 1.20 llama okay.
And here I'm just going to write Streamlit run app dot pi okay.
So we'll go ahead and execute it.
See any error is probably coming up.
So this is the Streamlit app right now.
No error is there.
It is a blank page.
So I think uh whatever things we are doing, it is working absolutely fine.
Okay, so, uh, this is the local host where it is specifically running.
Running.
Okay.
Uh, so let me just close this again.
Uh, we'll go ahead and close this particular terminal and we'll continue our coding.
Uh, with respect to this.
Okay.
Now we have actually done this, we have also used this length metric, uh, tracking.
Now, the thing is that we need to use this LM model.
So.
Which have actually imported it over here.
Okay, so let's quickly do this.
Uh, first of all, I will go ahead and design my prompt template.
Okay.
Now, inside this prompt template I will go ahead and create my prompt.
This will be my chat prompt template okay.
Template dot from underscore message okay.
And inside this uh I'm going to I'm going to basically define my prompts.
So first of all, I will go ahead and say this will be my system prompt write system basically means
what I really want the AI assistant to do.
So I'll put a message over here.
Hey, you are a helpful assistant, okay.
Please respond.
Respond to the question asked.
Okay, so this is a simple prompt that I'm writing over here.
Okay.
So this basically becomes for my system.
And now with respect to the user, I will give an input to the user saying that, hey, uh, this will
be my question okay.
So this will be my question.
And this question will be I'll be using an input variable which is like question over here.
Okay.
So this basically becomes my chat prompt template.
Very much simple over here.
Right.
And uh this is my language tracking.
Everything is fine.
And I've also created my chart prompt template.
Perfect.
Now let's go ahead and design my Streamlit framework okay.
So here I will go ahead and write Streamlit framework okay.
And inside the string framework let me go ahead and write my s t dot title.
Now with respect to the title I'll say hey this is my launch and demo with let's say I want to go ahead
and use, uh, llama two or Google Gamma model, or let's go ahead and say, right, Google gamma model,
okay, Google Gamma or let's go ahead and see llama two.
Okay.
I have also installed llama two.
Llama two is a model LM model but from Facebook okay.
So llama two okay.
Now again you can go ahead and use llama three.
Whatever you want.
You can go ahead and use it okay.
So I'll just go ahead and write my input underscore text.
And here I'll be saying hey this is my text underscore input okay.
Uh with respect to this.
So here you can see everything is got loaded.
You know it will take some time.
But right now you can see everything is in green color.
Now inside this text dot input I will say, hey, uh, uh, what what question you have in mind.
Okay.
Something you have in mind?
Okay, so this is my first question.
It is a text input over here.
So I will probably write any question over here.
And I will go ahead and ask my LM models and shot.
Okay.
Then uh, quickly, uh, what I'm actually going to do over here is that I will just go ahead and call
my llama llama two model.
Now, see, this is the most important thing.
How do I specifically call it?
Right?
You know that llama is basically present in long chain underscore communities dot lm.
So I can use this class of llama and I can create my own llama.
I can go ahead and create my llama two model okay.
So if I go ahead and write llama two so that basically it will go and search in the local, whether
llama two is model is present or not, if it is not present, then you have to probably go ahead and
use your command prompt and go ahead and just write Llama Run llama two along with llama two.
You can also go ahead and explore any other model that you want.
Let's say in this particular case I will be writing.
So llama two is here.
I will just use gamma to be okay.
So if you want this I will also show you this.
So here you can see this is my model I'm going to use gamma.
Gamma is my uh Google open source model okay.
Again it is an LM model altogether.
Right now let's say that I have used this particular LM model.
So I'll just go ahead and update this gamma model itself okay.
And let's call this.
And you can call any other model right.
Whatever model name is over there.
You can just go ahead and write it over here okay.
But please make sure that you do the, you do the, uh, installation or you download that particular
model in your local just by writing to run that specific model name.
Now, I'll go ahead and probably create my output parser to just show that how my output should be displayed.
And then finally I'll go ahead and create my chain.
Now I have already in chain what I'll do.
First I will go ahead and use my prompt.
Then after using prompt, I'm just going to use my LM and after using my LM I'll be using output parser.
Right.
So all these things will be there.
Now finally, in order to run it, I'll say, hey, if I put any thing in my input text and if I press
enter, right, what it should do, it should basically take this particular chain and invoke invoke
my invoke this chain by giving this input parameter of question.
And whatever input is basically coming, it will basically come from this input text.
Okay.
Now with respect to this, I will be getting some kind of response.
And this response I will just go ahead and write it in my in my system.
Okay.
So here you can see I'm writing it in my system.
So here this is what I have actually done it right.
And this is a beautiful thing.
I've used the open source model over here.
No open API and all.
You'll also be able to see that we'll be keeping the track in the Lange Smith.
And this time you will not be having any cost involved.
So let me go ahead and execute this.
So here, first of all, I will just go ahead and open my command prompt okay.
Let me quickly delete this okay.
Now I will go ahead and write Streamlit run app dot Pi.
This is how you run a Streamlit file.
Uh, please make sure that this will give me an error.
The reason is very simple.
I am not inside the right folder where app dot Pi is present, right?
App dot Pi is basically present in 1.20 folder, which is inside one lang chain.
Many people will find this as a confusion.
They are not able to run it and it shows file does not exist over here, right?
So what we will do, we will go to this location CD one Lang chain, then CD uh, one point let's say
two Olama.
And here I'll create the screen.
Now, before I run this, I will just make one changes over here inside this olama, I'm just going
to give my model parameter okay.
So this will be my model parameter.
Otherwise it will give us an error okay.
Uh, the reason is very simple because, uh, you know, uh, it will say that, hey, you have given
one additional parameter or something like that.
Okay.
So let's go ahead and now run it.
Uh, for running it, uh, I have to make sure that I have to just go ahead and write Streamlit.
Run.
App.py.
Now, let's go ahead and run this entire thing.
Now, here you can actually see this is what it is.
They're launching demo with gamma model.
Now what question I have in mind.
So I'll just go ahead and ask hey what is generative AI so quickly?
I'll go ahead and press enter.
You'll be able to see that I will be able to quickly get the response.
Uh, and again, everything is running over here.
You can see we will be communicating with this gamma model.
And finally you can see that I am able to see that entire response.
Right.
So I hope you are able to understand that how we can probably use Lama and, uh, create our entire
end to end AI application with any custom, uh, with any open source models like llama three, llama
two, gamma, or any other models that is available or supportable by llama.
So yes, this was it for my side.
So let me quickly go ahead and close this particular connection so that, you know, I will be able
to open some more things.
Okay.
And now in my next video I'll be discussing about more amazing things, uh, with respect to developing
generative AI application.
But yes, this was it from my side.
I will see you in the next video.
Thank you.