1
00:00:00,000 --> 00:00:00,000
Hello guys.

2
00:00:00,000 --> 00:00:03,000
So we are going to continue a discussion with respect to this end to end project.

3
00:00:03,000 --> 00:00:07,000
So you could see that we had created this particular function called as generate response in our previous

4
00:00:07,000 --> 00:00:08,000
video.

5
00:00:08,000 --> 00:00:14,000
Um, now what we are basically going to do is that we are going to create, uh, entire web app using

6
00:00:14,000 --> 00:00:14,000
Streamlit.

7
00:00:14,000 --> 00:00:15,000
Right?

8
00:00:15,000 --> 00:00:18,000
So first of all, I'll just go ahead and give it the title of the app.

9
00:00:18,000 --> 00:00:21,000
So the title of the app will be something like this.

10
00:00:21,000 --> 00:00:25,000
And you know how to use Streamlit for this title.

11
00:00:25,000 --> 00:00:27,000
And then Q and a chat bot with OpenAI.

12
00:00:28,000 --> 00:00:33,000
Now as I said, uh, I need to pass my open API key during the runtime, right?

13
00:00:33,000 --> 00:00:36,000
So for that, what I will do, I will keep a sidebar.

14
00:00:36,000 --> 00:00:37,000
Okay.

15
00:00:37,000 --> 00:00:42,000
In in Streamlit, you have a sidebar where you can probably enter your OpenAI API key.

16
00:00:42,000 --> 00:00:46,000
So here I have written st dot sidebar dot title which will be settings.

17
00:00:46,000 --> 00:00:51,000
And here you can see API underscore key which will be nothing but st dot sidebar underscore text underscore

18
00:00:51,000 --> 00:00:52,000
input.

19
00:00:52,000 --> 00:00:56,000
And I'm saying hey give your opening API key and the type will be password.

20
00:00:56,000 --> 00:00:58,000
That basically means no one will be able to see the password.

21
00:00:58,000 --> 00:00:58,000
Right.

22
00:00:58,000 --> 00:01:03,000
And then I'll just press enter so that it will keep that particular value inside this particular variable.

23
00:01:03,000 --> 00:01:04,000
Okay.

24
00:01:04,000 --> 00:01:16,000
Now I will also going to create a drop down to select various OpenAI models okay I'm actually going

25
00:01:16,000 --> 00:01:16,000
to create this.

26
00:01:16,000 --> 00:01:21,000
So for this what I'll say I'll write LM is equal to nothing but SD dot.

27
00:01:21,000 --> 00:01:24,000
Again this will also be in the sidebar the left hand side okay.

28
00:01:24,000 --> 00:01:26,000
So I'll be using sidebar.

29
00:01:26,000 --> 00:01:31,000
And here inside the sidebar I will go ahead and say hey let's go ahead and see the select box.

30
00:01:31,000 --> 00:01:32,000
I'll use a select box over here.

31
00:01:33,000 --> 00:01:41,000
And then I will go ahead and write select uh select an OpenAI model okay.

32
00:01:41,000 --> 00:01:43,000
So we'll go ahead and do this.

33
00:01:43,000 --> 00:01:49,000
And inside this OpenAI model we will give uh some of the models like which model we need to select.

34
00:01:49,000 --> 00:01:55,000
So in order to get what values need to be there in the model, I will just go ahead and open this.

35
00:01:55,000 --> 00:02:00,000
So here you can see I have just searched for OpenAI models itself.

36
00:02:00,000 --> 00:02:00,000
Right.

37
00:02:00,000 --> 00:02:02,000
So if you go in the model page you have so many different models.

38
00:02:02,000 --> 00:02:07,000
You have like GPT four, GPT four turbo, GPT five, 3.5.

39
00:02:07,000 --> 00:02:07,000
53.5, right?

40
00:02:07,000 --> 00:02:08,000
So, so many different models are there.

41
00:02:09,000 --> 00:02:12,000
And as we go ahead, we will also be seeing about Dall-E and all.

42
00:02:12,000 --> 00:02:15,000
So there is also like embeddings which we have already seen.

43
00:02:15,000 --> 00:02:21,000
So what I will suggest is that right now these three are the best models I guess in GPT four and GPT.

44
00:02:21,000 --> 00:02:21,000
Right.

45
00:02:21,000 --> 00:02:24,000
So GPT four or GPT four turbo, GPT 3.5.

46
00:02:24,000 --> 00:02:26,000
So we will be discussing about this okay.

47
00:02:26,000 --> 00:02:29,000
So right now let me just go ahead and write this particular model.

48
00:02:29,000 --> 00:02:30,000
So it will be GPT four.

49
00:02:30,000 --> 00:02:32,000
Oh okay.

50
00:02:32,000 --> 00:02:34,000
This will be my first model.

51
00:02:34,000 --> 00:02:38,000
Then I will go ahead and write GPT four turbo.

52
00:02:39,000 --> 00:02:39,000
Right.

53
00:02:39,000 --> 00:02:44,000
And then finally I have this GPT four okay.

54
00:02:44,000 --> 00:02:48,000
So this three is the is in the drop down that I'm actually getting.

55
00:02:48,000 --> 00:02:48,000
Right.

56
00:02:48,000 --> 00:02:50,000
Uh, I'm I'm getting in the drop down.

57
00:02:50,000 --> 00:02:51,000
I can select anything.

58
00:02:51,000 --> 00:02:55,000
So they should they are also two parameters that I'm passing in my generator response.

59
00:02:55,000 --> 00:02:57,000
One is temperature and one is max token.

60
00:02:57,000 --> 00:02:59,000
So we can also set up this particular values.

61
00:02:59,000 --> 00:03:02,000
And this time I'm just going to use a slider.

62
00:03:02,000 --> 00:03:02,000
Okay.

63
00:03:02,000 --> 00:03:05,000
In the sidebar I'm going to use a slider okay.

64
00:03:05,000 --> 00:03:09,000
And I'll say hey the temperature value should be ranging between 0 to 1.

65
00:03:09,000 --> 00:03:12,000
So here you can see I've created a variable called as temperature.

66
00:03:12,000 --> 00:03:16,000
I'm writing SD dot sidebar dot slider I've used temperature.

67
00:03:16,000 --> 00:03:17,000
The minimum value is 0.0.

68
00:03:17,000 --> 00:03:19,000
The maximum value is 1.0.

69
00:03:19,000 --> 00:03:22,000
And this particular value is nothing but 0.7.

70
00:03:22,000 --> 00:03:22,000
Right?

71
00:03:22,000 --> 00:03:26,000
Point seven is nothing but a default value where the slider will be pointing to.

72
00:03:26,000 --> 00:03:28,000
Okay, then you have this max token.

73
00:03:28,000 --> 00:03:33,000
Similarly, I'm keeping the max tokens between 50 to 300 and the default will be 150.

74
00:03:33,000 --> 00:03:43,000
Okay, now quickly what I will do I will just go ahead and define the main interface, uh, for user

75
00:03:43,000 --> 00:03:44,000
input okay.

76
00:03:44,000 --> 00:03:44,000
Okay.

77
00:03:44,000 --> 00:03:46,000
And here is what I'll write.

78
00:03:46,000 --> 00:03:47,000
So I'll say.

79
00:03:49,000 --> 00:03:53,000
SD dot write okay.

80
00:03:54,000 --> 00:03:58,000
Go ahead and ask any question.

81
00:03:59,000 --> 00:03:59,000
Okay.

82
00:04:00,000 --> 00:04:02,000
So I'll say hey let's define our user input.

83
00:04:02,000 --> 00:04:07,000
So user input is nothing but SD dot text underscore input okay.

84
00:04:08,000 --> 00:04:15,000
And here we are just going to use this I'll say you whatever question you have you can ask okay.

85
00:04:15,000 --> 00:04:19,000
So now whenever I give a user input.

86
00:04:19,000 --> 00:04:21,000
So if I go ahead and write if user input.

87
00:04:21,000 --> 00:04:26,000
So here uh we will go ahead and create a response.

88
00:04:28,000 --> 00:04:31,000
Is equal to generate response.

89
00:04:32,000 --> 00:04:35,000
Now inside this generate response I'm going to call this particular function.

90
00:04:35,000 --> 00:04:36,000
And you know what.

91
00:04:36,000 --> 00:04:37,000
All things I have I have this question.

92
00:04:37,000 --> 00:04:38,000
Question is nothing.

93
00:04:38,000 --> 00:04:42,000
But whatever user input is probably coming up I'll have to give this.

94
00:04:42,000 --> 00:04:44,000
I have my API key.

95
00:04:44,000 --> 00:04:50,000
So I'll go ahead and call my API key because from this, uh, you know, the text input, whatever API

96
00:04:50,000 --> 00:04:53,000
key I'm actually giving it will be written over here.

97
00:04:53,000 --> 00:04:55,000
So I have this particular variable.

98
00:04:55,000 --> 00:04:58,000
Along with that I have my LM model also.

99
00:04:58,000 --> 00:05:00,000
So which LM model I'm actually selecting.

100
00:05:00,000 --> 00:05:02,000
I will go ahead and give my LM model.

101
00:05:02,000 --> 00:05:06,000
And then uh other than this you also have temperature max tokens.

102
00:05:06,000 --> 00:05:08,000
So temperature and max token is already set over here.

103
00:05:08,000 --> 00:05:16,000
So let me just go ahead and write temperature comma max underscore token okay.

104
00:05:16,000 --> 00:05:18,000
So here uh all the values are over here.

105
00:05:18,000 --> 00:05:22,000
So I will quickly go ahead and write SD dot write.

106
00:05:23,000 --> 00:05:24,000
response okay.

107
00:05:25,000 --> 00:05:31,000
So once I'm doing this, that basically means the response will be, uh, written over here in the page

108
00:05:31,000 --> 00:05:32,000
itself and you'll be able to see it.

109
00:05:32,000 --> 00:05:33,000
Okay.

110
00:05:33,000 --> 00:05:36,000
Uh, if user does not enter any input.

111
00:05:36,000 --> 00:05:45,000
So I'll say else lf or else there is no input, I can go ahead and write SD dot write okay.

112
00:05:45,000 --> 00:05:50,000
Please provide the user.

113
00:05:51,000 --> 00:05:53,000
Please provide the query.

114
00:05:53,000 --> 00:05:53,000
Okay.

115
00:05:53,000 --> 00:05:54,000
Something like this.

116
00:05:54,000 --> 00:05:58,000
So till here I think everything has been implemented.

117
00:05:58,000 --> 00:05:59,000
It looks good itself okay.

118
00:05:59,000 --> 00:06:01,000
And we are good to go.

119
00:06:01,000 --> 00:06:03,000
I think uh let me just quickly revise.

120
00:06:03,000 --> 00:06:06,000
So first of all, we did the langsamt tracking over here.

121
00:06:06,000 --> 00:06:08,000
Then we develop our chat prompt template.

122
00:06:08,000 --> 00:06:11,000
Then we created a function which will be able to generate the response.

123
00:06:11,000 --> 00:06:14,000
And these are all my fields user input values.

124
00:06:14,000 --> 00:06:15,000
Everything is over here.

125
00:06:15,000 --> 00:06:18,000
And then I'm probably calling this I'm writing the response.

126
00:06:18,000 --> 00:06:20,000
It's a quick simple application.

127
00:06:20,000 --> 00:06:27,000
So finally guys let's go ahead and run this entire application now so quickly we will do this.

128
00:06:27,000 --> 00:06:31,000
Just a second I'll clear the screen.

129
00:06:31,000 --> 00:06:39,000
And here I'm going to just write Streamlit run main.py.

130
00:06:39,000 --> 00:06:44,000
So once I do this, uh, this is my entire app that is running right now.

131
00:06:45,000 --> 00:06:45,000
Um, okay.

132
00:06:45,000 --> 00:06:46,000
Perfect.

133
00:06:46,000 --> 00:06:47,000
Uh, enter your OpenAI API key.

134
00:06:47,000 --> 00:06:49,000
I will just go ahead and press enter.

135
00:06:49,000 --> 00:06:50,000
Perfect.

136
00:06:50,000 --> 00:06:53,000
Let's set some values over here.

137
00:06:53,000 --> 00:06:57,000
Let's say I will go ahead and ask what is machine learning?

138
00:06:58,000 --> 00:06:59,000
Press enter.

139
00:06:59,000 --> 00:07:03,000
And here is what I will be able to get my response okay.

140
00:07:03,000 --> 00:07:06,000
So it will take some time again based on the API itself.

141
00:07:06,000 --> 00:07:08,000
And here is my entire response.

142
00:07:08,000 --> 00:07:13,000
I'll also be able to see whether it is getting tracked in the Lange Smith quickly.

143
00:07:14,000 --> 00:07:17,000
So I will go ahead and hit this.

144
00:07:17,000 --> 00:07:18,000
Click on sign up automatically.

145
00:07:18,000 --> 00:07:19,000
It will come up.

146
00:07:19,000 --> 00:07:20,000
So here is my project.

147
00:07:20,000 --> 00:07:25,000
So here you can see yes this is the recent one.

148
00:07:25,000 --> 00:07:29,000
Uh, and uh, we have made this recent things.

149
00:07:29,000 --> 00:07:29,000
Right.

150
00:07:29,000 --> 00:07:33,000
So here you can see chat prompt template chat OpenAI string output parser.

151
00:07:33,000 --> 00:07:34,000
What is machine learning.

152
00:07:34,000 --> 00:07:35,000
Right.

153
00:07:36,000 --> 00:07:37,000
So this is the runnable sequence.

154
00:07:37,000 --> 00:07:39,000
You can see what is machine learning.

155
00:07:39,000 --> 00:07:41,000
And I've got this output right.

156
00:07:41,000 --> 00:07:46,000
If you see the first thing in the chain is chat prompt template.

157
00:07:46,000 --> 00:07:48,000
And then this is my output message.

158
00:07:48,000 --> 00:07:50,000
Then it is interacting with the chat open AI.

159
00:07:50,000 --> 00:07:52,000
Here you can see the entire response.

160
00:07:52,000 --> 00:07:55,000
And finally you'll be able to see the string output parser.

161
00:07:55,000 --> 00:07:56,000
Yeah.

162
00:07:56,000 --> 00:07:59,000
So yes, uh, everything looks fine.

163
00:07:59,000 --> 00:08:02,000
Uh, and everything is working over here.

164
00:08:02,000 --> 00:08:03,000
I hope you like this particular video.

165
00:08:03,000 --> 00:08:11,000
Now, in the next video, we'll try to modify this entire application with respect to the llama models.

166
00:08:11,000 --> 00:08:11,000
Okay.

167
00:08:11,000 --> 00:08:14,000
So that is what I'm actually going to show you in the next video.

168
00:08:14,000 --> 00:08:14,000
Thank you.

