Hello guys.
So we are going to continue a discussion with respect to this end to end project.
So you could see that we had created this particular function called as generate response in our previous
video.
Um, now what we are basically going to do is that we are going to create, uh, entire web app using
Streamlit.
Right?
So first of all, I'll just go ahead and give it the title of the app.
So the title of the app will be something like this.
And you know how to use Streamlit for this title.
And then Q and a chat bot with OpenAI.
Now as I said, uh, I need to pass my open API key during the runtime, right?
So for that, what I will do, I will keep a sidebar.
Okay.
In in Streamlit, you have a sidebar where you can probably enter your OpenAI API key.
So here I have written st dot sidebar dot title which will be settings.
And here you can see API underscore key which will be nothing but st dot sidebar underscore text underscore
input.
And I'm saying hey give your opening API key and the type will be password.
That basically means no one will be able to see the password.
Right.
And then I'll just press enter so that it will keep that particular value inside this particular variable.
Okay.
Now I will also going to create a drop down to select various OpenAI models okay I'm actually going
to create this.
So for this what I'll say I'll write LM is equal to nothing but SD dot.
Again this will also be in the sidebar the left hand side okay.
So I'll be using sidebar.
And here inside the sidebar I will go ahead and say hey let's go ahead and see the select box.
I'll use a select box over here.
And then I will go ahead and write select uh select an OpenAI model okay.
So we'll go ahead and do this.
And inside this OpenAI model we will give uh some of the models like which model we need to select.
So in order to get what values need to be there in the model, I will just go ahead and open this.
So here you can see I have just searched for OpenAI models itself.
Right.
So if you go in the model page you have so many different models.
You have like GPT four, GPT four turbo, GPT five, 3.5.
53.5, right?
So, so many different models are there.
And as we go ahead, we will also be seeing about Dall-E and all.
So there is also like embeddings which we have already seen.
So what I will suggest is that right now these three are the best models I guess in GPT four and GPT.
Right.
So GPT four or GPT four turbo, GPT 3.5.
So we will be discussing about this okay.
So right now let me just go ahead and write this particular model.
So it will be GPT four.
Oh okay.
This will be my first model.
Then I will go ahead and write GPT four turbo.
Right.
And then finally I have this GPT four okay.
So this three is the is in the drop down that I'm actually getting.
Right.
Uh, I'm I'm getting in the drop down.
I can select anything.
So they should they are also two parameters that I'm passing in my generator response.
One is temperature and one is max token.
So we can also set up this particular values.
And this time I'm just going to use a slider.
Okay.
In the sidebar I'm going to use a slider okay.
And I'll say hey the temperature value should be ranging between 0 to 1.
So here you can see I've created a variable called as temperature.
I'm writing SD dot sidebar dot slider I've used temperature.
The minimum value is 0.0.
The maximum value is 1.0.
And this particular value is nothing but 0.7.
Right?
Point seven is nothing but a default value where the slider will be pointing to.
Okay, then you have this max token.
Similarly, I'm keeping the max tokens between 50 to 300 and the default will be 150.
Okay, now quickly what I will do I will just go ahead and define the main interface, uh, for user
input okay.
Okay.
And here is what I'll write.
So I'll say.
SD dot write okay.
Go ahead and ask any question.
Okay.
So I'll say hey let's define our user input.
So user input is nothing but SD dot text underscore input okay.
And here we are just going to use this I'll say you whatever question you have you can ask okay.
So now whenever I give a user input.
So if I go ahead and write if user input.
So here uh we will go ahead and create a response.
Is equal to generate response.
Now inside this generate response I'm going to call this particular function.
And you know what.
All things I have I have this question.
Question is nothing.
But whatever user input is probably coming up I'll have to give this.
I have my API key.
So I'll go ahead and call my API key because from this, uh, you know, the text input, whatever API
key I'm actually giving it will be written over here.
So I have this particular variable.
Along with that I have my LM model also.
So which LM model I'm actually selecting.
I will go ahead and give my LM model.
And then uh other than this you also have temperature max tokens.
So temperature and max token is already set over here.
So let me just go ahead and write temperature comma max underscore token okay.
So here uh all the values are over here.
So I will quickly go ahead and write SD dot write.
response okay.
So once I'm doing this, that basically means the response will be, uh, written over here in the page
itself and you'll be able to see it.
Okay.
Uh, if user does not enter any input.
So I'll say else lf or else there is no input, I can go ahead and write SD dot write okay.
Please provide the user.
Please provide the query.
Okay.
Something like this.
So till here I think everything has been implemented.
It looks good itself okay.
And we are good to go.
I think uh let me just quickly revise.
So first of all, we did the langsamt tracking over here.
Then we develop our chat prompt template.
Then we created a function which will be able to generate the response.
And these are all my fields user input values.
Everything is over here.
And then I'm probably calling this I'm writing the response.
It's a quick simple application.
So finally guys let's go ahead and run this entire application now so quickly we will do this.
Just a second I'll clear the screen.
And here I'm going to just write Streamlit run main.py.
So once I do this, uh, this is my entire app that is running right now.
Um, okay.
Perfect.
Uh, enter your OpenAI API key.
I will just go ahead and press enter.
Perfect.
Let's set some values over here.
Let's say I will go ahead and ask what is machine learning?
Press enter.
And here is what I will be able to get my response okay.
So it will take some time again based on the API itself.
And here is my entire response.
I'll also be able to see whether it is getting tracked in the Lange Smith quickly.
So I will go ahead and hit this.
Click on sign up automatically.
It will come up.
So here is my project.
So here you can see yes this is the recent one.
Uh, and uh, we have made this recent things.
Right.
So here you can see chat prompt template chat OpenAI string output parser.
What is machine learning.
Right.
So this is the runnable sequence.
You can see what is machine learning.
And I've got this output right.
If you see the first thing in the chain is chat prompt template.
And then this is my output message.
Then it is interacting with the chat open AI.
Here you can see the entire response.
And finally you'll be able to see the string output parser.
Yeah.
So yes, uh, everything looks fine.
Uh, and everything is working over here.
I hope you like this particular video.
Now, in the next video, we'll try to modify this entire application with respect to the llama models.
Okay.
So that is what I'm actually going to show you in the next video.
Thank you.