1
00:00:00,000 --> 00:00:00,000
Hello guys.

2
00:00:00,000 --> 00:00:06,000
So let's go ahead and build our end to end generative AI application with respect to the demo that we

3
00:00:06,000 --> 00:00:07,000
have already seen.

4
00:00:07,000 --> 00:00:13,000
So quickly, to go ahead with what I will be doing is that I will be requiring the Streamlit library

5
00:00:13,000 --> 00:00:13,000
again.

6
00:00:13,000 --> 00:00:16,000
I'm going to create this entire end to end project with the help of Streamlit.

7
00:00:16,000 --> 00:00:21,000
Then, uh, we are just going to go ahead and import, uh, Chad Grok because we are going to use Google

8
00:00:21,000 --> 00:00:22,000
Gamma model.

9
00:00:22,000 --> 00:00:27,000
Now, along with this, uh, I will be using, uh, two important chain.

10
00:00:27,000 --> 00:00:30,000
One is called as LM chain and one is LM Mac chain.

11
00:00:30,000 --> 00:00:31,000
Okay.

12
00:00:31,000 --> 00:00:34,000
Since, uh, we need to do the entire mathematical calculation.

13
00:00:34,000 --> 00:00:37,000
So this will be the library that will be useful for us.

14
00:00:37,000 --> 00:00:37,000
Okay.

15
00:00:38,000 --> 00:00:44,000
Uh, along with that, as you know, that, uh, we also need we will be since, uh, I also want that

16
00:00:44,000 --> 00:00:47,000
thought of chain to have an interaction between the agents also.

17
00:00:47,000 --> 00:00:49,000
So I will be using Wikipedia.

18
00:00:49,000 --> 00:00:52,000
I will be using, uh, prompt template.

19
00:00:52,000 --> 00:00:56,000
Uh, I will be using Agent type, I'll be using a initialize agent.

20
00:00:56,000 --> 00:01:02,000
And all the tools will be created with this specific library called as uh, tools itself.

21
00:01:02,000 --> 00:01:04,000
And this is basically coming from Langston.

22
00:01:04,000 --> 00:01:10,000
Underscore agents uh load underscore dot env needs to be used if you really want to use the API key.

23
00:01:10,000 --> 00:01:14,000
But since we are completely giving the API key from the website itself.

24
00:01:14,000 --> 00:01:16,000
So I'll not be going to use that.

25
00:01:16,000 --> 00:01:20,000
And from launching callbacks, we'll be using the Streamlit callback handler.

26
00:01:20,000 --> 00:01:25,000
Now, the main importance of the Streamlit callback handler will be that the thought of chain, right?

27
00:01:25,000 --> 00:01:30,000
The kind of interaction that is basically going to happen between the tool, every thing we should be

28
00:01:30,000 --> 00:01:31,000
able to see it.

29
00:01:31,000 --> 00:01:35,000
And we will also be able to understand that how the entire conversation has started.

30
00:01:35,000 --> 00:01:35,000
Okay.

31
00:01:35,000 --> 00:01:38,000
So these are some of the libraries that we will be using.

32
00:01:38,000 --> 00:01:43,000
And I think in all our previous session we have discussed about all the specific libraries.

33
00:01:43,000 --> 00:01:50,000
Now quickly, uh, let's go ahead and set up the Streamlit lab or Streamlit app.

34
00:01:51,000 --> 00:01:55,000
So I'm going to go over here and go here and create our Streamlit app.

35
00:01:55,000 --> 00:01:59,000
Then I'm going to write SD dot set page config.

36
00:01:59,000 --> 00:02:10,000
And we are going to specifically use our page title which is called as text to Math Problem Solver,

37
00:02:10,000 --> 00:02:16,000
okay, and Data Search Assistant, since I'm also going to create some tools.

38
00:02:16,000 --> 00:02:17,000
Right.

39
00:02:17,000 --> 00:02:21,000
So this will basically be my, um, you know, the page title itself.

40
00:02:21,000 --> 00:02:27,000
And with respect to this, I will also go ahead and use some page icons so that whenever, uh, I see

41
00:02:27,000 --> 00:02:28,000
in my browser.

42
00:02:28,000 --> 00:02:28,000
Right.

43
00:02:28,000 --> 00:02:29,000
I should be able to see this.

44
00:02:29,000 --> 00:02:30,000
Right.

45
00:02:30,000 --> 00:02:34,000
So this will basically be my page icon that I'm actually going to use along with this.

46
00:02:34,000 --> 00:02:39,000
Uh, the next thing that I'm going to basically do is that provide my s t dot title.

47
00:02:39,000 --> 00:02:42,000
So let me just go ahead and write s t dot title is equal to.

48
00:02:42,000 --> 00:02:52,000
And here I'll say, hey this is my text to math math problem solver okay.

49
00:02:52,000 --> 00:02:52,000
Okay.

50
00:02:52,000 --> 00:02:59,000
And, uh, I'll just go ahead and write using Google Gamma two, because the linear model that I'm going

51
00:02:59,000 --> 00:03:00,000
to use is Google Gamma two.

52
00:03:00,000 --> 00:03:01,000
Okay.

53
00:03:01,000 --> 00:03:06,000
And, uh, you know, uh, I can still write more information that you want, like, uh, whatever things

54
00:03:06,000 --> 00:03:11,000
you really want, uh, you can go ahead and write it with the help of St Dot write if you want more

55
00:03:11,000 --> 00:03:12,000
description over here.

56
00:03:13,000 --> 00:03:17,000
Now quickly, let's go ahead and create our grok underscore API underscore key.

57
00:03:17,000 --> 00:03:21,000
Now with respect to this grok underscore API underscore key what I am actually going to do I'll just

58
00:03:21,000 --> 00:03:23,000
go ahead and write t dot sidebar.

59
00:03:23,000 --> 00:03:34,000
Sidebar dot text underscore input so that I get my input for the grok API.

60
00:03:34,000 --> 00:03:34,000
Right.

61
00:03:34,000 --> 00:03:38,000
So here I'm going to basically go ahead and write grok uh API key.

62
00:03:39,000 --> 00:03:39,000
Okay.

63
00:03:39,000 --> 00:03:45,000
Once I get this grok API key then the next thing that I'm actually going to do is my password.

64
00:03:45,000 --> 00:03:47,000
I'll go ahead and say, hey, it is basically a password.

65
00:03:47,000 --> 00:03:51,000
I really need to get this now my entire application start with this.

66
00:03:51,000 --> 00:03:57,000
So I will be giving a condition if grok underscore API underscore key colon I'll just go ahead and write

67
00:03:57,000 --> 00:04:00,000
sc.info okay.

68
00:04:00,000 --> 00:04:11,000
And I'll say hey please add your grok API key to continue.

69
00:04:11,000 --> 00:04:11,000
Okay.

70
00:04:11,000 --> 00:04:13,000
So we'll go ahead and write this.

71
00:04:13,000 --> 00:04:16,000
And here I'm also going to write SD dot stop okay.

72
00:04:16,000 --> 00:04:22,000
If we are not providing our grok API key that should really be the condition.

73
00:04:22,000 --> 00:04:26,000
If I'm saying hey uh, if grok API key, that won't make sense, I'll go ahead and write.

74
00:04:26,000 --> 00:04:29,000
If not, if the grok API key is not provided, you have to.

75
00:04:29,000 --> 00:04:31,000
First of all, go ahead and provide this.

76
00:04:31,000 --> 00:04:34,000
Now let's go ahead and initialize our language model.

77
00:04:34,000 --> 00:04:38,000
Now here my language model will be again by using chat grok.

78
00:04:38,000 --> 00:04:39,000
The model.

79
00:04:39,000 --> 00:04:43,000
That name that I'm actually going to specifically use is nothing but gamma.

80
00:04:43,000 --> 00:04:50,000
So this information I hope you will be able to get it from the, uh, the cloud API, the Grok Cloud

81
00:04:50,000 --> 00:04:50,000
API.

82
00:04:50,000 --> 00:04:50,000
Right.

83
00:04:50,000 --> 00:04:58,000
So here I'll be going and writing 9BIT And here you can go ahead and see grok with respect to grok API

84
00:04:58,000 --> 00:04:59,000
key.

85
00:04:59,000 --> 00:05:02,000
Here we are going to initialize the grok API key.

86
00:05:02,000 --> 00:05:02,000
Perfect.

87
00:05:03,000 --> 00:05:06,000
So this basically becomes my language large language model okay.

88
00:05:06,000 --> 00:05:10,000
Or I will just go ahead and write LLM LLM LLM over here.

89
00:05:10,000 --> 00:05:14,000
So we will be able to refer it anywhere we want okay.

90
00:05:14,000 --> 00:05:18,000
Now uh the next thing will be that we will start initializing our tools.

91
00:05:18,000 --> 00:05:22,000
So let's start initializing the tools over here.

92
00:05:22,000 --> 00:05:26,000
Now, first of all, the tool that I'm actually going to use is Wikipedia.

93
00:05:26,000 --> 00:05:32,000
So I'll go ahead and create my Wikipedia wrapper, which we have again discussed in the tools and agent

94
00:05:32,000 --> 00:05:33,000
types.

95
00:05:33,000 --> 00:05:36,000
So here I'm going to basically go ahead and call this Wikipedia wrapper.

96
00:05:36,000 --> 00:05:37,000
Whatever is the default value.

97
00:05:37,000 --> 00:05:42,000
The one result or two result, whatever things you really want to use it you can use it over here.

98
00:05:42,000 --> 00:05:48,000
Then I will go ahead and create my Wikipedia underscore two, which will be nothing, but this will

99
00:05:48,000 --> 00:05:51,000
be my tool over here, which I've initialized it.

100
00:05:51,000 --> 00:05:55,000
And then I'm going to go ahead and write name is equal to Wikipedia.

101
00:05:55,000 --> 00:05:55,000
Okay.

102
00:05:55,000 --> 00:06:01,000
So once I go ahead and create this then I will just go ahead and write my function.

103
00:06:01,000 --> 00:06:07,000
So my function will be equal to uh I'll just go and say Wikipedia dot run.

104
00:06:07,000 --> 00:06:07,000
Okay.

105
00:06:07,000 --> 00:06:08,000
Or dot search.

106
00:06:08,000 --> 00:06:12,000
I think it should be search dot run.

107
00:06:12,000 --> 00:06:12,000
Okay.

108
00:06:13,000 --> 00:06:15,000
So run is my function name.

109
00:06:15,000 --> 00:06:17,000
Uh, so there is a parameter with respect to that.

110
00:06:17,000 --> 00:06:22,000
If you really want to run this particular wrapper I can just go ahead and use this Wikipedia dot run.

111
00:06:22,000 --> 00:06:27,000
And I'll provide some description for this so that I'll be able to see some information while I'm doing

112
00:06:27,000 --> 00:06:27,000
the chat.

113
00:06:28,000 --> 00:06:39,000
Uh, tool for searching the internet and solving your math problem.

114
00:06:39,000 --> 00:06:40,000
Okay, something like this.

115
00:06:41,000 --> 00:06:43,000
So Wikipedia is, uh.

116
00:06:43,000 --> 00:06:45,000
No, just searching the internet should be the math.

117
00:06:45,000 --> 00:06:57,000
Solving the math problem and, uh, searching the internet to find the various info on the on the topics

118
00:06:57,000 --> 00:06:58,000
mentioned.

119
00:06:58,000 --> 00:07:01,000
So this should be my entire thing.

120
00:07:01,000 --> 00:07:06,000
Okay, so Wikipedia tool is there and I will just go ahead and initialize.

121
00:07:08,000 --> 00:07:12,000
Initialize the math tool okay.

122
00:07:12,000 --> 00:07:16,000
So let's go ahead and initialize the see Wikipedia is there.

123
00:07:16,000 --> 00:07:18,000
This is just used for search right.

124
00:07:18,000 --> 00:07:20,000
Now if I really want to solve the math problem.

125
00:07:20,000 --> 00:07:25,000
So there is a tool over here uh, even in long chain which is called as LM matching, which we have

126
00:07:25,000 --> 00:07:26,000
actually imported.

127
00:07:26,000 --> 00:07:33,000
So I'll just go ahead and write math underscore chain is equal to LM math LM math chain okay.

128
00:07:33,000 --> 00:07:40,000
And here uh, I'm just going to say from underscore LMS uh from underscore LMS okay.

129
00:07:40,000 --> 00:07:43,000
So this is an inbuilt method.

130
00:07:43,000 --> 00:07:46,000
And here I'm going to pass my LM model okay.

131
00:07:46,000 --> 00:07:49,000
So LM is equal to LM okay.

132
00:07:49,000 --> 00:07:54,000
So what it is going to do is that uh, this specific math chain is going to interact with our LM model,

133
00:07:54,000 --> 00:07:59,000
uh, with respect to the any kind of calculation or any kind of arithmetic operation that needs to be

134
00:07:59,000 --> 00:07:59,000
performed.

135
00:07:59,000 --> 00:08:02,000
Then I will go ahead and create a variable.

136
00:08:02,000 --> 00:08:03,000
Let's say I'll go ahead and write calculator.

137
00:08:03,000 --> 00:08:06,000
So I'll just name it as calculator.

138
00:08:06,000 --> 00:08:06,000
right.

139
00:08:06,000 --> 00:08:08,000
And I will initialize my tool.

140
00:08:09,000 --> 00:08:11,000
Uh I will give some name parameter over here.

141
00:08:11,000 --> 00:08:13,000
So this will be nothing but calculator.

142
00:08:14,000 --> 00:08:22,000
Um the function that we will be using is nothing but math underscore chain dot run again okay.

143
00:08:22,000 --> 00:08:25,000
Like how we used it for Wikipedia.

144
00:08:25,000 --> 00:08:33,000
And finally we will go ahead and give our description which will be nothing but a tool for answering

145
00:08:33,000 --> 00:08:36,000
math related questions.

146
00:08:36,000 --> 00:08:41,000
And here, uh, I will just make a note.

147
00:08:41,000 --> 00:08:46,000
We only need to provide only input, mathematical expression.

148
00:08:46,000 --> 00:08:47,000
Nothing else than this.

149
00:08:47,000 --> 00:08:49,000
Otherwise it will give us an error.

150
00:08:49,000 --> 00:08:50,000
Okay.

151
00:08:51,000 --> 00:08:52,000
Expression needs to be provided.

152
00:08:53,000 --> 00:08:56,000
Needs to be provided.

153
00:08:56,000 --> 00:08:56,000
Okay.

154
00:08:56,000 --> 00:08:59,000
So all this information is basically there.

155
00:08:59,000 --> 00:09:01,000
Uh, this is basically my calculator tool.

156
00:09:01,000 --> 00:09:06,000
Now it's time that, uh, we start, you know, solving this entire problem.

157
00:09:07,000 --> 00:09:13,000
Um, and first of all, I will just go ahead and define my prompt, my prompt, and I'll say, hey,

158
00:09:13,000 --> 00:09:16,000
um, let's go ahead and do this.

159
00:09:16,000 --> 00:09:18,000
Uh, let's create our prompt.

160
00:09:18,000 --> 00:09:32,000
So I'll say, hey, you are, uh, uh, agent tasked for solving, okay, users mathematical questions.

161
00:09:32,000 --> 00:09:34,000
Okay, I'll just go ahead and write like this.

162
00:09:34,000 --> 00:09:38,000
Mathematical, um, questions.

163
00:09:38,000 --> 00:09:38,000
Okay.

164
00:09:40,000 --> 00:09:40,000
Uh.

165
00:09:42,000 --> 00:09:44,000
Mathematical questions.

166
00:09:45,000 --> 00:09:46,000
Uh, logically.

167
00:09:48,000 --> 00:09:55,000
Arrive at the solution and provide a detailed explanation.

168
00:09:57,000 --> 00:10:00,000
Explanation.

169
00:10:00,000 --> 00:10:00,000
Okay.

170
00:10:01,000 --> 00:10:01,000
Um.

171
00:10:01,000 --> 00:10:06,000
And display it and display it.

172
00:10:09,000 --> 00:10:09,000
Point wise.

173
00:10:09,000 --> 00:10:10,000
Okay.

174
00:10:12,000 --> 00:10:13,000
Point wise.

175
00:10:13,000 --> 00:10:19,000
Okay, so I've just written some basic command prompt, and here, um, point wise.

176
00:10:19,000 --> 00:10:23,000
So for the for the question below okay.

177
00:10:23,000 --> 00:10:28,000
So here I will just go ahead and write my question and I'll give my input as question.

178
00:10:28,000 --> 00:10:28,000
Okay.

179
00:10:28,000 --> 00:10:30,000
So this is what I am actually going to do.

180
00:10:31,000 --> 00:10:35,000
And finally, I should be able to get my answer like this and just close my brackets.

181
00:10:35,000 --> 00:10:35,000
Okay.

182
00:10:35,000 --> 00:10:39,000
So this is basically my prompt, uh, which I'm actually going to use.

183
00:10:39,000 --> 00:10:43,000
And now let me just go ahead and define my prompt template.

184
00:10:43,000 --> 00:10:44,000
Okay.

185
00:10:44,000 --> 00:10:46,000
So I will go ahead and write prompt template is equal to.

186
00:10:46,000 --> 00:10:49,000
And here also we'll go ahead and initialize our prompt template.

187
00:10:50,000 --> 00:10:58,000
Uh the input variables that we are going to use over here is nothing but question, but I hope you are

188
00:10:58,000 --> 00:11:04,000
much more familiar by seeing all the tutorials before now everything looks like needs to be familiar,

189
00:11:04,000 --> 00:11:04,000
right?

190
00:11:04,000 --> 00:11:07,000
I, I think you will be definitely familiar with all these things.

191
00:11:07,000 --> 00:11:10,000
So template will nothing be it will be my prompt.

192
00:11:10,000 --> 00:11:18,000
Okay now let's uh create now the chain which will combine all the tools that we have created like Wikipedia

193
00:11:18,000 --> 00:11:18,000
and all.

194
00:11:18,000 --> 00:11:21,000
Okay, so first, quickly let me do one thing.

195
00:11:21,000 --> 00:11:28,000
Let me just go ahead and first I will say Matt problem tool okay.

196
00:11:28,000 --> 00:11:33,000
So with respect to the math problem tool, uh, you know, what is the tool that I'm actually using

197
00:11:33,000 --> 00:11:34,000
that is nothing but LM chain.

198
00:11:34,000 --> 00:11:39,000
So I will go ahead and initialize my LM chain and uh, okay.

199
00:11:39,000 --> 00:11:50,000
LM first of all, see when I really want to, I'll say combine all the tools into chain.

200
00:11:50,000 --> 00:11:51,000
Okay.

201
00:11:51,000 --> 00:11:54,000
Now, what I'll be doing is that I will be using this Wikipedia.

202
00:11:54,000 --> 00:11:58,000
I'll be using this map chain and I'll combine with the entire prompt template.

203
00:11:58,000 --> 00:11:59,000
Okay.

204
00:11:59,000 --> 00:12:01,000
But before combining them.

205
00:12:01,000 --> 00:12:01,000
Right.

206
00:12:01,000 --> 00:12:03,000
First of all I need to create my LM chain.

207
00:12:03,000 --> 00:12:05,000
Now LM chain usually has two important things.

208
00:12:05,000 --> 00:12:07,000
One is your LM model.

209
00:12:07,000 --> 00:12:08,000
So I'll go ahead and initialize it.

210
00:12:08,000 --> 00:12:10,000
And the second one is something called as prompt.

211
00:12:11,000 --> 00:12:12,000
Prompt template okay.

212
00:12:12,000 --> 00:12:17,000
So once we have this both the important things that basically means my chain is ready okay.

213
00:12:17,000 --> 00:12:19,000
So here I'll go ahead and create my chain.

214
00:12:19,000 --> 00:12:21,000
Let me do one thing.

215
00:12:21,000 --> 00:12:23,000
Instead of writing prompt template over here.

216
00:12:23,000 --> 00:12:27,000
Let me first of all give my prompt over here okay.

217
00:12:27,000 --> 00:12:33,000
Since this prompt should be equal to my entire prompt template that I have actually created over here.

218
00:12:33,000 --> 00:12:33,000
Okay.

219
00:12:33,000 --> 00:12:34,000
The same thing.

220
00:12:34,000 --> 00:12:37,000
So this is the first thing that I really need to create is my chain.

221
00:12:37,000 --> 00:12:40,000
And then uh, one more.

222
00:12:40,000 --> 00:12:45,000
Um, see, I also need to make sure that I add reasoning inside this.

223
00:12:45,000 --> 00:12:45,000
Okay.

224
00:12:45,000 --> 00:12:52,000
So for that I will create a reasoning tool and I'll say, hey, let's create this particular tool.

225
00:12:52,000 --> 00:12:57,000
And this tool name should be given as reasoning tool.

226
00:12:57,000 --> 00:12:58,000
Okay.

227
00:12:58,000 --> 00:13:05,000
I want to add this one more thing and my function will be nothing but whatever chain that I am actually

228
00:13:05,000 --> 00:13:07,000
creating this I will run this chain okay.

229
00:13:07,000 --> 00:13:10,000
So I'm running this entire chain from a specific tool.

230
00:13:11,000 --> 00:13:17,000
Uh, the reason why I have named it as reasoning because since they are, they are multiple things.

231
00:13:17,000 --> 00:13:19,000
That is probably going to happen in this specific chain.

232
00:13:19,000 --> 00:13:22,000
So, uh, we will also be running this in the form of a tool.

233
00:13:22,000 --> 00:13:23,000
Okay.

234
00:13:23,000 --> 00:13:25,000
And here I'll be writing my description.

235
00:13:25,000 --> 00:13:38,000
And let's say I'll say hey tool for answering logic based and reasoning reasoning questions okay.

236
00:13:40,000 --> 00:13:41,000
So this is done over here.

237
00:13:41,000 --> 00:13:44,000
So this basically becomes my description.

238
00:13:44,000 --> 00:13:46,000
Description okay.

239
00:13:48,000 --> 00:13:48,000
This is all good.

240
00:13:48,000 --> 00:13:52,000
Now now we are just going to go ahead and initialize our agents.

241
00:13:52,000 --> 00:13:57,000
So let's initialize the.

242
00:14:00,000 --> 00:14:01,000
The agents okay.

243
00:14:02,000 --> 00:14:06,000
Now in order to initialize the agent I will first of all go ahead and write assistant underscore agent

244
00:14:06,000 --> 00:14:10,000
is equal to initialize the agent.

245
00:14:10,000 --> 00:14:16,000
And here I will go ahead and say tools what all tools I want I will just go ahead and combine it over

246
00:14:16,000 --> 00:14:18,000
here like Wikipedia tool okay.

247
00:14:18,000 --> 00:14:22,000
The second tool will basically be my calculator tool or callback manager.

248
00:14:22,000 --> 00:14:25,000
My calculator okay.

249
00:14:25,000 --> 00:14:27,000
So this will be another one tool.

250
00:14:27,000 --> 00:14:31,000
And along with this we will go ahead and add one more which is called as reasoning tool, which will

251
00:14:31,000 --> 00:14:34,000
be responsible in running the entire chain.

252
00:14:34,000 --> 00:14:38,000
So in short, what we have done is that my LM chain, I have converted this into a tool.

253
00:14:38,000 --> 00:14:39,000
Okay.

254
00:14:39,000 --> 00:14:43,000
And I'm saying that, hey, this selenium chain should actually give you the entire answers.

255
00:14:43,000 --> 00:14:48,000
But I'm saying, hey, it is a reasoning tool because it has some sort of chain that may be going right

256
00:14:48,000 --> 00:14:50,000
because it is interacting with the LM model.

257
00:14:50,000 --> 00:14:54,000
Now finally I will go ahead and create my LM is equal to LM.

258
00:14:54,000 --> 00:14:57,000
And let me just go ahead and create my agent.

259
00:14:57,000 --> 00:15:02,000
So here I'll be using agent type dot zero short react description.

260
00:15:02,000 --> 00:15:05,000
And I have already discussed what exactly this is.

261
00:15:05,000 --> 00:15:11,000
I will also go ahead and write verbose is equal to true just to see my detailed, um, uh, detailed

262
00:15:11,000 --> 00:15:14,000
uh, uh, detail in uh, thought of chain process.

263
00:15:14,000 --> 00:15:18,000
But I'll keep it as false because this will get, uh, printed in the console itself.

264
00:15:18,000 --> 00:15:18,000
Right.

265
00:15:18,000 --> 00:15:18,000
Sorry.

266
00:15:18,000 --> 00:15:19,000
In the terminal.

267
00:15:19,000 --> 00:15:20,000
Right.

268
00:15:20,000 --> 00:15:28,000
So here, uh, I will also go ahead and write handle underscore parsing underscore error is equal to

269
00:15:28,000 --> 00:15:28,000
true.

270
00:15:28,000 --> 00:15:28,000
Okay.

271
00:15:28,000 --> 00:15:31,000
So I'm also going to keep this particular parameter over here.

272
00:15:31,000 --> 00:15:32,000
Right.

273
00:15:32,000 --> 00:15:35,000
So almost each and every thing is basically being used.

274
00:15:35,000 --> 00:15:37,000
And over here we have also used the initialized agent.

275
00:15:37,000 --> 00:15:40,000
So this is good to go now okay.

276
00:15:40,000 --> 00:15:45,000
But always remember we also need to make sure that we create our session state.

277
00:15:45,000 --> 00:15:47,000
So let me just go ahead and write if messages.

278
00:15:47,000 --> 00:15:57,000
So here I have written if messages are not in st dot session underscore st dot session underscore state

279
00:15:57,000 --> 00:16:03,000
so that I will create this particular state session underscore state okay.

280
00:16:03,000 --> 00:16:10,000
And here I am just going to write st dot session underscore state if for messages.

281
00:16:11,000 --> 00:16:11,000
Okay.

282
00:16:11,000 --> 00:16:16,000
Now inside this particular messages I am going to go ahead and add my role.

283
00:16:16,000 --> 00:16:21,000
So let's say by default uh the role that I'm adding is two roles.

284
00:16:21,000 --> 00:16:22,000
One is assistant.

285
00:16:22,000 --> 00:16:25,000
And uh this assistant will also be in string.

286
00:16:26,000 --> 00:16:31,000
And the second thing that I'm actually going to add is my content by default content I'll say hey,

287
00:16:31,000 --> 00:16:33,000
content colon.

288
00:16:33,000 --> 00:16:43,000
I'll say, hey, um, hi, I'm a math chat bot.

289
00:16:43,000 --> 00:16:45,000
Who can answer?

290
00:16:46,000 --> 00:16:52,000
Who can answer all your maths question?

291
00:16:52,000 --> 00:16:54,000
Okay, something like this.

292
00:16:55,000 --> 00:16:59,000
So yes, this was my role that I've actually added it over here.

293
00:16:59,000 --> 00:17:13,000
Now quickly I'll just go ahead and say for message in s t s t dot session underscore state dot messages.

294
00:17:13,000 --> 00:17:18,000
And here we are specifically going to use this s t dot chat underscore message okay.

295
00:17:18,000 --> 00:17:20,000
Chat underscore message.

296
00:17:20,000 --> 00:17:36,000
And here I'm going to use my, my uh my message my message of role okay comma dot right of message of

297
00:17:36,000 --> 00:17:37,000
content.

298
00:17:37,000 --> 00:17:42,000
So I'm just going to go ahead and write this entire content with respect to all the conversation inside

299
00:17:42,000 --> 00:17:44,000
this chat dot chat underscore message.

300
00:17:44,000 --> 00:17:45,000
Okay.

301
00:17:45,000 --> 00:17:48,000
Now finally I'm going to go ahead and create.

302
00:17:48,000 --> 00:17:53,000
And this is something that we do commonly whenever we want to use session state over in every project

303
00:17:53,000 --> 00:17:55,000
that you really want to do.

304
00:17:55,000 --> 00:18:05,000
Now I will say hey function to handle uh or to generate the response, I'll go ahead and create my own

305
00:18:05,000 --> 00:18:05,000
function.

306
00:18:06,000 --> 00:18:10,000
And for this I will write definition generate underscore.

307
00:18:10,000 --> 00:18:16,000
Response will be nothing, but it will be user underscore question okay.

308
00:18:16,000 --> 00:18:20,000
And here I'll go ahead and create my response.

309
00:18:20,000 --> 00:18:23,000
Assistant underscore agent.

310
00:18:23,000 --> 00:18:27,000
And here I'm just going to go ahead and invoke okay.

311
00:18:27,000 --> 00:18:31,000
Um so this assistant agent that you'll be seeing right.

312
00:18:31,000 --> 00:18:33,000
What it exactly it is this is it.

313
00:18:33,000 --> 00:18:33,000
Right.

314
00:18:33,000 --> 00:18:38,000
And I'm writing dot invoke over here and I'll be giving my input.

315
00:18:38,000 --> 00:18:38,000
Right.

316
00:18:38,000 --> 00:18:40,000
So this will specifically be my input.

317
00:18:40,000 --> 00:18:46,000
And here I'm going to give my whatever question that I have.

318
00:18:46,000 --> 00:18:49,000
Let me just go ahead and remove this and let me write it over here.

319
00:18:49,000 --> 00:18:51,000
So this will basically be my question.

320
00:18:51,000 --> 00:18:52,000
Okay.

321
00:18:52,000 --> 00:18:57,000
Um, now, uh, along with this, I will go ahead and write return response.

322
00:18:57,000 --> 00:18:57,000
Okay.

323
00:18:57,000 --> 00:19:01,000
And, uh, this are all my values.

324
00:19:01,000 --> 00:19:04,000
Remember one thing, guys, I forgot to tell you that when we initially imported.

325
00:19:04,000 --> 00:19:05,000
Right?

326
00:19:05,000 --> 00:19:09,000
I'm considering that all these things are have installed in your requirement dot txt.

327
00:19:09,000 --> 00:19:14,000
So from the starting session till now, whatever requirement dot txt we have actually created, I've

328
00:19:14,000 --> 00:19:18,000
just kept it everything in one place so that you can just go ahead and install it and you can start

329
00:19:18,000 --> 00:19:18,000
using it.

330
00:19:19,000 --> 00:19:20,000
Okay.

331
00:19:20,000 --> 00:19:21,000
So you can also go ahead and do that.

332
00:19:21,000 --> 00:19:24,000
Now this will basically give us the response.

333
00:19:24,000 --> 00:19:26,000
Now let's start the interaction.

334
00:19:26,000 --> 00:19:35,000
So I will say hey uh let's start the let's start the interaction okay.

335
00:19:36,000 --> 00:19:47,000
Now here what I'm actually going to do I'll write start button, uh, and I'll say uh, find my answer.

336
00:19:47,000 --> 00:19:49,000
Find my answer.

337
00:19:49,000 --> 00:19:55,000
But before this, uh, before I start clicking the specific button, I will also go ahead and create

338
00:19:55,000 --> 00:19:56,000
my question.

339
00:19:56,000 --> 00:20:00,000
And here I'll say t dot text area.

340
00:20:01,000 --> 00:20:04,000
And by default I will put one question over here.

341
00:20:04,000 --> 00:20:08,000
I'll say enter your question Okay.

342
00:20:08,000 --> 00:20:12,000
And here you'll be able to see that I will go ahead and write my question okay.

343
00:20:12,000 --> 00:20:18,000
Now one of the question that I have taken over here, I have to created over here is like this question,

344
00:20:18,000 --> 00:20:18,000
right?

345
00:20:18,000 --> 00:20:20,000
The same demo one which we saw.

346
00:20:20,000 --> 00:20:22,000
I have five bananas, seven grapes.

347
00:20:22,000 --> 00:20:24,000
I eat two bananas and gave away all these things.

348
00:20:24,000 --> 00:20:25,000
Right.

349
00:20:25,000 --> 00:20:28,000
So all this, uh, information will be given by default.

350
00:20:28,000 --> 00:20:30,000
And we can also use it if you want.

351
00:20:30,000 --> 00:20:30,000
Otherwise leave it.

352
00:20:30,000 --> 00:20:31,000
Okay.

353
00:20:31,000 --> 00:20:36,000
So here if I go ahead and write if question after cat, after clicking the button write get answer,

354
00:20:36,000 --> 00:20:40,000
I'll say hey, if there is a question, write.

355
00:20:40,000 --> 00:20:42,000
If there is a question then what do you do?

356
00:20:43,000 --> 00:20:52,000
Run a TT dot spinner okay, so these are some components in uh Streamlit.

357
00:20:52,000 --> 00:20:54,000
So here I will write with TT dot spinner.

358
00:20:55,000 --> 00:20:59,000
And let me say that there is some message that is basically getting generated.

359
00:20:59,000 --> 00:21:01,000
So I'll say generate response.

360
00:21:02,000 --> 00:21:04,000
And here I will go ahead and write like this.

361
00:21:04,000 --> 00:21:13,000
And then I will just go ahead and write TX dot session underscore state dot messages dot append okay.

362
00:21:13,000 --> 00:21:20,000
And here I'm going to basically write role colon user.

363
00:21:21,000 --> 00:21:22,000
Right.

364
00:21:22,000 --> 00:21:27,000
So this will basically be my role that I have to probably set it up before we start this conversation.

365
00:21:27,000 --> 00:21:31,000
And the content will be equal to this specific question that I'm passing.

366
00:21:31,000 --> 00:21:31,000
Okay.

367
00:21:32,000 --> 00:21:35,000
So this is what we want first of all appended.

368
00:21:35,000 --> 00:21:38,000
Then we will go ahead and start SD dot chat message.

369
00:21:38,000 --> 00:21:38,000
Okay.

370
00:21:38,000 --> 00:21:40,000
Chat message.

371
00:21:40,000 --> 00:21:43,000
And here I will set my user along with that.

372
00:21:43,000 --> 00:21:43,000
Uh.

373
00:21:43,000 --> 00:21:47,000
uh, sorry user and I will.

374
00:21:47,000 --> 00:21:49,000
Write the user question.

375
00:21:49,000 --> 00:21:52,000
So it should be able to it should be visible in that particular.

376
00:21:53,000 --> 00:21:54,000
Uh chat message.

377
00:21:55,000 --> 00:21:55,000
Right.

378
00:21:55,000 --> 00:21:57,000
So that is the reason I'm putting this entire information.

379
00:21:57,000 --> 00:21:59,000
So this will basically be my question.

380
00:21:59,000 --> 00:22:06,000
Now quickly let's go ahead and write s t dot CB where I will be creating my Streamlit callback handler.

381
00:22:07,000 --> 00:22:09,000
And inside this I will say TX dot container.

382
00:22:09,000 --> 00:22:15,000
I'll initialize the container, which will basically display the entire thoughts of action and I'll

383
00:22:15,000 --> 00:22:19,000
say hey, go ahead and make the tab false.

384
00:22:19,000 --> 00:22:21,000
It should not be visible in the initial stages.

385
00:22:21,000 --> 00:22:24,000
Later on I can click and I can probably expand it.

386
00:22:24,000 --> 00:22:26,000
Now I will go ahead and get my response.

387
00:22:26,000 --> 00:22:28,000
So for this I will say assistant.

388
00:22:28,000 --> 00:22:32,000
Uh, I can either see I can either call this function like generate response.

389
00:22:32,000 --> 00:22:33,000
Okay.

390
00:22:33,000 --> 00:22:36,000
It is up to you what you really want to use it.

391
00:22:36,000 --> 00:22:36,000
Okay.

392
00:22:36,000 --> 00:22:39,000
Or, uh, what you can do is that you can directly call assistant.

393
00:22:39,000 --> 00:22:45,000
So let me just remove this because again why to create this particular function I know it is not a best

394
00:22:45,000 --> 00:22:50,000
practice, but I will just go ahead and write it over here because I just need to call it from here

395
00:22:50,000 --> 00:22:50,000
itself.

396
00:22:50,000 --> 00:22:52,000
So assistant Dot run.

397
00:22:52,000 --> 00:22:57,000
But if you are probably developing um, bigger application where you have front end, back end, many

398
00:22:57,000 --> 00:23:00,000
things, as such, you have to probably go ahead and create a function.

399
00:23:00,000 --> 00:23:03,000
So here I will write SD dot session.

400
00:23:05,000 --> 00:23:09,000
Session underscore state dot messages okay.

401
00:23:10,000 --> 00:23:13,000
And here I'm going to also integrate with it callbacks.

402
00:23:13,000 --> 00:23:18,000
So callback will be s t comma cb okay so this is it.

403
00:23:18,000 --> 00:23:23,000
Uh and then finally I will just open my new braces.

404
00:23:23,000 --> 00:23:24,000
Uh, sorry.

405
00:23:24,000 --> 00:23:25,000
New line.

406
00:23:25,000 --> 00:23:29,000
I will say TX dot session underscore state dot messages.

407
00:23:29,000 --> 00:23:32,000
And I'm just going to append each and everything over here.

408
00:23:32,000 --> 00:23:34,000
I'll go ahead and write append.

409
00:23:34,000 --> 00:23:36,000
So it should be messages.

410
00:23:36,000 --> 00:23:38,000
Let's see messages over here.

411
00:23:38,000 --> 00:23:39,000
Messages over here.

412
00:23:40,000 --> 00:23:43,000
Uh messages also over here okay.

413
00:23:43,000 --> 00:23:45,000
So it should be matching each and everything.

414
00:23:46,000 --> 00:23:50,000
Okay so append and here I'm just going to go ahead and add my role.

415
00:23:50,000 --> 00:23:53,000
So the role will be with respect to assistant.

416
00:23:53,000 --> 00:23:58,000
Because once I get my information right what role we need to assign it needs to be assistant.

417
00:24:02,000 --> 00:24:03,000
It needs to be assistant.

418
00:24:03,000 --> 00:24:09,000
And then we will go ahead and add our content which will be response.

419
00:24:10,000 --> 00:24:11,000
Okay.

420
00:24:11,000 --> 00:24:14,000
So finally let's go ahead and print the response if you want.

421
00:24:14,000 --> 00:24:15,000
Okay.

422
00:24:16,000 --> 00:24:18,000
So I'll go ahead and say print the response.

423
00:24:18,000 --> 00:24:20,000
Uh just to print it in the terminal.

424
00:24:20,000 --> 00:24:24,000
Otherwise instead of writing this I'll just go ahead and say s t dot.

425
00:24:24,000 --> 00:24:24,000
Right.

426
00:24:25,000 --> 00:24:32,000
And let me add my response.

427
00:24:32,000 --> 00:24:33,000
colon.

428
00:24:34,000 --> 00:24:37,000
And here I'll say TX dot success.

429
00:24:37,000 --> 00:24:39,000
This will be my final response.

430
00:24:40,000 --> 00:24:43,000
Okay, uh, if the question is given, that is fine.

431
00:24:43,000 --> 00:24:45,000
Otherwise I'll say else.

432
00:24:46,000 --> 00:24:49,000
SD dot warning array by input --.

433
00:24:50,000 --> 00:24:51,000
Please enter your input.

434
00:24:51,000 --> 00:24:55,000
Please enter the question.

435
00:24:55,000 --> 00:24:55,000
Okay.

436
00:24:55,000 --> 00:24:56,000
That's it.

437
00:24:57,000 --> 00:24:58,000
So quickly.

438
00:24:58,000 --> 00:25:01,000
I think within 10 to 15 minutes, I was able to do the entire coding.

439
00:25:01,000 --> 00:25:04,000
And step by step, I've actually showed you over here.

440
00:25:04,000 --> 00:25:07,000
Uh, let me just go ahead first of all and show you what all things we did.

441
00:25:07,000 --> 00:25:12,000
We had one grok API key, uh, text input so that we can put it all the information.

442
00:25:12,000 --> 00:25:14,000
Then we have this.

443
00:25:14,000 --> 00:25:17,000
We initialized our, uh, LLM model.

444
00:25:17,000 --> 00:25:20,000
Then we created our tools like Wikipedia math.

445
00:25:20,000 --> 00:25:22,000
Then we had our prompt.

446
00:25:22,000 --> 00:25:24,000
Then we had our prompt template.

447
00:25:24,000 --> 00:25:28,000
Then finally we combined the prompt and the LM model using the LM chain.

448
00:25:28,000 --> 00:25:32,000
Then we converted this LM chain into a tool.

449
00:25:32,000 --> 00:25:32,000
Right.

450
00:25:32,000 --> 00:25:34,000
That is what we really did.

451
00:25:34,000 --> 00:25:40,000
And then we initialized the agent by combining all these tools uh with the LM model.

452
00:25:40,000 --> 00:25:41,000
And then type what we really need to do.

453
00:25:42,000 --> 00:25:44,000
Then we created the session state.

454
00:25:44,000 --> 00:25:49,000
And we are making sure that every time whatever input specifically comes, we append in this particular

455
00:25:49,000 --> 00:25:51,000
state session state.

456
00:25:51,000 --> 00:25:53,000
And now here I have my question.

457
00:25:53,000 --> 00:25:58,000
And once we click this particular question it should probably go ahead and interact with the agent and

458
00:25:58,000 --> 00:26:00,000
probably give you the output okay.

459
00:26:00,000 --> 00:26:03,000
So this was overall the entire thing.

460
00:26:03,000 --> 00:26:04,000
So let me do one thing.

461
00:26:04,000 --> 00:26:08,000
Let me just go ahead and write CD dot dot and I will go ahead to CD.

462
00:26:08,000 --> 00:26:13,000
If you see over here, this is my Mac GPT eighth lesson.

463
00:26:13,000 --> 00:26:21,000
So I will go ahead and write math CD eight Mac GPT.

464
00:26:21,000 --> 00:26:21,000
Okay.

465
00:26:21,000 --> 00:26:27,000
And now in order to run it Streamlit run app dot pi or app dot pi.

466
00:26:27,000 --> 00:26:34,000
Now before that I will go to my environment variable, take my grok API key and just run it.

467
00:26:34,000 --> 00:26:36,000
Let's press enter.

468
00:26:41,000 --> 00:26:43,000
So here you can see it.

469
00:26:43,000 --> 00:26:43,000
Let me close this.

470
00:26:43,000 --> 00:26:46,000
So here I have my API.

471
00:26:46,000 --> 00:26:49,000
So I'll go ahead and press enter over here.

472
00:26:49,000 --> 00:26:55,000
So here you can see one positional argument is missing in Wikipedia because of description.

473
00:26:55,000 --> 00:26:57,000
I know what is the error.

474
00:26:57,000 --> 00:26:59,000
I think there should be a spelling mistake.

475
00:27:04,000 --> 00:27:05,000
Okay.

476
00:27:05,000 --> 00:27:06,000
Uh, this is description.

477
00:27:07,000 --> 00:27:09,000
Wikipedia.

478
00:27:11,000 --> 00:27:12,000
That was a spelling mistakes.

479
00:27:12,000 --> 00:27:13,000
Okay.

480
00:27:13,000 --> 00:27:15,000
I will say always rerun.

481
00:27:15,000 --> 00:27:15,000
Okay.

482
00:27:15,000 --> 00:27:20,000
It is asking for installing num expression.

483
00:27:20,000 --> 00:27:22,000
So let's go ahead and do that so quickly.

484
00:27:22,000 --> 00:27:25,000
I will go ahead and open my another command prompt.

485
00:27:25,000 --> 00:27:27,000
And this will be one of the requirement.

486
00:27:27,000 --> 00:27:31,000
Uh, I will just go ahead and update in my requirement dot txt.

487
00:27:32,000 --> 00:27:36,000
Let me go ahead and paste it over here and let me press enter.

488
00:27:36,000 --> 00:27:38,000
So I'll say pip install.

489
00:27:41,000 --> 00:27:43,000
Minus our requirement dot txt.

490
00:27:43,000 --> 00:27:46,000
So let's go ahead and do this installation.

491
00:27:46,000 --> 00:27:50,000
We one of the dependency I think this is just for the numerical expression.

492
00:27:50,000 --> 00:27:54,000
You know how to probably use this numerical expression how to calculate it.

493
00:27:54,000 --> 00:27:57,000
So once it is successfully installed I'll go over here.

494
00:27:57,000 --> 00:28:00,000
Now let's reload this okay.

495
00:28:00,000 --> 00:28:02,000
Let's go back to my env.

496
00:28:02,000 --> 00:28:05,000
I will go ahead and copy my grok API key.

497
00:28:05,000 --> 00:28:09,000
So two errors we have faced till now I'll press enter.

498
00:28:09,000 --> 00:28:10,000
And here you have this.

499
00:28:10,000 --> 00:28:12,000
Hi, I'm a mad chat bot.

500
00:28:12,000 --> 00:28:15,000
Uh, who can answer all your mathematical questions or maths question?

501
00:28:15,000 --> 00:28:17,000
I'll just go ahead and click on Find answer.

502
00:28:17,000 --> 00:28:20,000
So here you can see thinking let's break down.

503
00:28:20,000 --> 00:28:22,000
Reasoning is basically happening right.

504
00:28:22,000 --> 00:28:27,000
And over here some must funny funny logos has also been used.

505
00:28:27,000 --> 00:28:27,000
Okay.

506
00:28:27,000 --> 00:28:30,000
So finally you can see 69 is my answer.

507
00:28:30,000 --> 00:28:36,000
Okay I'll say what is what is.

508
00:28:36,000 --> 00:28:51,000
Um, let's say, um, I have 20 apples, I divide, I divide, I, I have five friends, I have five

509
00:28:51,000 --> 00:28:57,000
friends, and I give each friend.

510
00:28:58,000 --> 00:29:11,000
two apples, are two apples and later takes one apple back from them.

511
00:29:11,000 --> 00:29:14,000
So this is most like a logical reasoning, right?

512
00:29:15,000 --> 00:29:20,000
Uh, so how many Apple do I have?

513
00:29:21,000 --> 00:29:21,000
Okay.

514
00:29:21,000 --> 00:29:22,000
I'm just trying to make.

515
00:29:23,000 --> 00:29:27,000
So okay so I'll go ahead and click on find my answer.

516
00:29:27,000 --> 00:29:28,000
So let's see.

517
00:29:28,000 --> 00:29:32,000
See over here all this question response will also be over here right.

518
00:29:32,000 --> 00:29:35,000
So here you can see I have got 69.

519
00:29:35,000 --> 00:29:40,000
Now the next question over here I'll go ahead and see this one -1010 plus one.

520
00:29:41,000 --> 00:29:41,000
Uh okay.

521
00:29:41,000 --> 00:29:45,000
You take one apple back one apple back from them.

522
00:29:45,000 --> 00:29:45,000
Okay.

523
00:29:45,000 --> 00:29:47,000
Did not understand from each of them okay.

524
00:29:47,000 --> 00:29:51,000
So they're saying okay I have 11 apples have left.

525
00:29:51,000 --> 00:29:57,000
If I write from each of them, I think I should be from each of them.

526
00:29:57,000 --> 00:29:57,000
Okay.

527
00:29:57,000 --> 00:29:59,000
Now I think it should be able to give the answer.

528
00:30:00,000 --> 00:30:00,000
Let's see.

529
00:30:01,000 --> 00:30:06,000
So it should be able to give you 15 right.

530
00:30:06,000 --> 00:30:08,000
So yes go ahead and try it out.

531
00:30:08,000 --> 00:30:11,000
This is another amazing project that we have actually developed.

532
00:30:11,000 --> 00:30:13,000
Uh, you can give any kind of complexity.

533
00:30:13,000 --> 00:30:19,000
Just try to give it in the form of sentence and uh, then try to see that whether you are able to get

534
00:30:19,000 --> 00:30:20,000
all the answers or not.

535
00:30:20,000 --> 00:30:22,000
So yes, this was it from my side.

536
00:30:22,000 --> 00:30:23,000
I hope you like this particular video.

537
00:30:23,000 --> 00:30:30,000
Uh, this is amazing text to maths problem solver using Google Gemini to, uh, sorry, Google Gamma

538
00:30:30,000 --> 00:30:30,000
to uh.

539
00:30:30,000 --> 00:30:32,000
I hope you like this particular video.

540
00:30:32,000 --> 00:30:33,000
I'll see you in the next video.

541
00:30:33,000 --> 00:30:33,000
Thank you.

542
00:30:33,000 --> 00:30:34,000
Have a great day.

543
00:30:34,000 --> 00:30:34,000
Bye bye.

