1
00:00:00,000 --> 00:00:05,000
So guys, finally, I'm excited to implement this amazing end to end project related to text summarization.

2
00:00:05,000 --> 00:00:08,000
So I will take the same folder inside this.

3
00:00:08,000 --> 00:00:11,000
I will go ahead and create a API key.

4
00:00:11,000 --> 00:00:14,000
So let me just go ahead and create this.

5
00:00:14,000 --> 00:00:16,000
Sorry not API app.py file.

6
00:00:16,000 --> 00:00:17,000
Okay.

7
00:00:17,000 --> 00:00:20,000
And this is where I'm actually going to write the entire coding.

8
00:00:20,000 --> 00:00:23,000
See the reason why I am creating this kind of folder structure.

9
00:00:23,000 --> 00:00:28,000
You know, because you understand like how every project is basically getting created.

10
00:00:28,000 --> 00:00:35,000
And I'm just putting all the common libraries that may, we may be using in creating an end to end projects.

11
00:00:35,000 --> 00:00:36,000
Right.

12
00:00:36,000 --> 00:00:38,000
And that will be all at one place.

13
00:00:38,000 --> 00:00:42,000
So that is the reason, uh, I'm basically creating all the projects in this same way.

14
00:00:42,000 --> 00:00:43,000
Okay.

15
00:00:43,000 --> 00:00:46,000
So now, uh, let's go ahead and start our coding over here.

16
00:00:46,000 --> 00:00:52,000
So first of all, what we are going to do is that, uh, here we are also going to use some new libraries.

17
00:00:52,000 --> 00:00:52,000
Okay.

18
00:00:52,000 --> 00:00:56,000
So first of all, the library that I really want to use is something called as validators.

19
00:00:56,000 --> 00:00:59,000
Now what exactly is this validator.

20
00:00:59,000 --> 00:01:06,000
Since we are going to use or work with Earl over here, this validator basically is an inbuilt library

21
00:01:06,000 --> 00:01:12,000
which is not an inbuilt library, but it is an external library which actually helps you to validate

22
00:01:12,000 --> 00:01:12,000
the URL.

23
00:01:12,000 --> 00:01:13,000
Okay.

24
00:01:13,000 --> 00:01:19,000
So I will be using one of this particular, uh, version that is 0.281.1.

25
00:01:19,000 --> 00:01:21,000
I think this is the recent version that is going on.

26
00:01:21,000 --> 00:01:26,000
Along with this, I will also be using YouTube transcript.

27
00:01:26,000 --> 00:01:29,000
Transcript underscore API.

28
00:01:29,000 --> 00:01:36,000
Now, with the help of this, whenever we give any YouTube URL okay, we will be able to read the entire

29
00:01:36,000 --> 00:01:38,000
transcript for that particular video.

30
00:01:38,000 --> 00:01:38,000
Okay.

31
00:01:38,000 --> 00:01:42,000
So this is another one library that we are basically going to use.

32
00:01:42,000 --> 00:01:47,000
Uh, let's see whether when we are doing the coding like any more libraries will be required or not.

33
00:01:47,000 --> 00:01:50,000
So now I will go over here, I will open my command prompt.

34
00:01:50,000 --> 00:01:55,000
First of all, I will go ahead and make sure that I do the installation of the requirement dot txt.

35
00:01:55,000 --> 00:02:00,000
So first thing that you really need to validate is that are we in our environment right.

36
00:02:00,000 --> 00:02:01,000
That is V and V.

37
00:02:01,000 --> 00:02:03,000
Yes it shows over here.

38
00:02:03,000 --> 00:02:07,000
We will go ahead and write pip install minus r requirement dot txt.

39
00:02:07,000 --> 00:02:11,000
So once I go ahead and execute it here you can see remaining all the libraries.

40
00:02:11,000 --> 00:02:13,000
It shows requirement already satisfied.

41
00:02:13,000 --> 00:02:17,000
But now YouTube YouTube transcript underscore API validators.

42
00:02:17,000 --> 00:02:19,000
You can see it has got successfully installed.

43
00:02:19,000 --> 00:02:24,000
So now let me just go ahead and close this and let me start writing my code.

44
00:02:24,000 --> 00:02:29,000
Uh, the first thing first, what I really need to do is that I have to import this validators.

45
00:02:29,000 --> 00:02:32,000
So I'll go ahead and write import validators.

46
00:02:33,000 --> 00:02:37,000
And then I'm going to also import Streamlit as st.

47
00:02:38,000 --> 00:02:39,000
Okay.

48
00:02:39,000 --> 00:02:46,000
Uh I'm going to use this then uh from lang chain dot prompts.

49
00:02:46,000 --> 00:02:51,000
Okay I'm going to import my prompt template which I'm going to specifically use.

50
00:02:51,000 --> 00:02:52,000
Okay.

51
00:02:52,000 --> 00:03:00,000
Then uh again from lang chain underscore grok, we are going to import chat grok, which I'm actually

52
00:03:00,000 --> 00:03:03,000
going to use to communicate with my LLM models.

53
00:03:03,000 --> 00:03:08,000
Then from lang chin dot chains dot summarize.

54
00:03:08,000 --> 00:03:13,000
Because we are going to use the summarize for using any of the summarize techniques that we have already

55
00:03:13,000 --> 00:03:14,000
learned.

56
00:03:14,000 --> 00:03:18,000
So here we will be importing this load summarize chain.

57
00:03:18,000 --> 00:03:19,000
Then again uh.

58
00:03:19,000 --> 00:03:27,000
Uh, one more library that I am going to specifically use with respect to YouTube and uh, any other

59
00:03:27,000 --> 00:03:27,000
websites.

60
00:03:27,000 --> 00:03:27,000
Right.

61
00:03:27,000 --> 00:03:30,000
We also require some kind of document loaders.

62
00:03:30,000 --> 00:03:34,000
So if you remember in the initial stages we discussed about document loaders.

63
00:03:34,000 --> 00:03:34,000
Right.

64
00:03:34,000 --> 00:03:41,000
So Langston underscore community dot document loaders I'm going to import one is YouTube loader.

65
00:03:41,000 --> 00:03:44,000
So for this I will be using this YouTube loader.

66
00:03:44,000 --> 00:03:47,000
You can also take the audio if you are really interested.

67
00:03:47,000 --> 00:03:48,000
Okay.

68
00:03:48,000 --> 00:03:58,000
And then we will also go ahead and take a unstructured and structured or unstructured URL road.

69
00:03:58,000 --> 00:03:58,000
Right.

70
00:03:58,000 --> 00:04:04,000
And there are so many like see unstructured HTML is there, CSV is there, email is there, pub is there.

71
00:04:04,000 --> 00:04:07,000
But here we are just going to use a URL.

72
00:04:07,000 --> 00:04:07,000
Let's see.

73
00:04:08,000 --> 00:04:11,000
We'll go ahead and write unstructured URL road.

74
00:04:11,000 --> 00:04:12,000
Okay.

75
00:04:12,000 --> 00:04:16,000
That basically means directly from the URL we will be able to load the content here.

76
00:04:16,000 --> 00:04:17,000
You can also use CSV.

77
00:04:17,000 --> 00:04:21,000
You can also use any other things like let's say you want to upload go ahead and upload CSV.

78
00:04:21,000 --> 00:04:25,000
You can also do that okay as I said guys it is vast.

79
00:04:25,000 --> 00:04:26,000
Lang chain is really really vast.

80
00:04:26,000 --> 00:04:27,000
Okay.

81
00:04:27,000 --> 00:04:29,000
So finally let's go ahead and create our Streamlit app.

82
00:04:29,000 --> 00:04:31,000
Now initially to create the Streamlit app.

83
00:04:31,000 --> 00:04:38,000
What I will do I will go ahead and set up my page config and uh h3 dot title next dot subheader.

84
00:04:38,000 --> 00:04:47,000
Okay, um, then I will quickly go ahead and get the grok API key that I really want to use.

85
00:04:48,000 --> 00:04:56,000
Uh, and I will also create an URL field, the URL field to uh, which URL we really need to summarize,

86
00:04:56,000 --> 00:04:56,000
right.

87
00:04:56,000 --> 00:04:58,000
To be summarized, I will right over here.

88
00:04:59,000 --> 00:05:00,000
Okay.

89
00:05:00,000 --> 00:05:03,000
Um, and, uh, the Earl field.

90
00:05:03,000 --> 00:05:05,000
I'll not say Earl to be summarized.

91
00:05:05,000 --> 00:05:06,000
Whatever.

92
00:05:06,000 --> 00:05:09,000
Earl, we really want to summarize, it can be.

93
00:05:09,000 --> 00:05:13,000
I'll write over here as it can be white or website.

94
00:05:13,000 --> 00:05:13,000
Okay.

95
00:05:13,000 --> 00:05:21,000
So once this is done, then I will go ahead and write with s t dot s sidebar.

96
00:05:22,000 --> 00:05:22,000
Okay.

97
00:05:22,000 --> 00:05:26,000
And here I will go ahead and create the sidebar itself.

98
00:05:26,000 --> 00:05:31,000
Here I will go ahead and first of all get my API key right.

99
00:05:31,000 --> 00:05:34,000
So for this I will go ahead and write TX dot text input.

100
00:05:34,000 --> 00:05:41,000
So I'm just creating a field on the sidebar like text input where I will be giving my grok API key.

101
00:05:41,000 --> 00:05:46,000
So let me just go ahead and write grok grok API key.

102
00:05:47,000 --> 00:05:47,000
Okay.

103
00:05:47,000 --> 00:05:52,000
And here we are basically going to take the value as blank right.

104
00:05:52,000 --> 00:05:56,000
Initially it will be and type will be password.

105
00:05:56,000 --> 00:05:56,000
Okay.

106
00:05:56,000 --> 00:05:57,000
Perfect.

107
00:05:57,000 --> 00:05:58,000
Till here we have done it.

108
00:05:58,000 --> 00:06:00,000
Then let's go ahead and create our URL.

109
00:06:00,000 --> 00:06:04,000
It'll be nothing but PT dot text underscore input.

110
00:06:04,000 --> 00:06:08,000
And here I'm going to basically give my URL.

111
00:06:09,000 --> 00:06:09,000
Okay.

112
00:06:09,000 --> 00:06:13,000
And over here I will keep my initial label.

113
00:06:13,000 --> 00:06:15,000
Visibility is equal to false or collapsed.

114
00:06:16,000 --> 00:06:16,000
Okay.

115
00:06:16,000 --> 00:06:21,000
The reason over here why I'm writing it as collapsed because it should not be highlighted unless until

116
00:06:21,000 --> 00:06:22,000
we go ahead and click it.

117
00:06:22,000 --> 00:06:24,000
Okay, so this will be collapsed.

118
00:06:25,000 --> 00:06:26,000
Uh, this is perfect.

119
00:06:26,000 --> 00:06:26,000
Till here.

120
00:06:26,000 --> 00:06:28,000
We have done this.

121
00:06:28,000 --> 00:06:28,000
Okay.

122
00:06:29,000 --> 00:06:33,000
Um, next, uh, what I will do, I'll go ahead and create my button.

123
00:06:33,000 --> 00:06:33,000
Okay.

124
00:06:33,000 --> 00:06:42,000
So for that, I will go ahead and write if s t dot button, I will go ahead and create my summarize

125
00:06:43,000 --> 00:06:49,000
the content from y t or website.

126
00:06:49,000 --> 00:06:50,000
Okay.

127
00:06:50,000 --> 00:06:52,000
So this will basically have the information in the button.

128
00:06:52,000 --> 00:06:53,000
Okay.

129
00:06:53,000 --> 00:07:00,000
Uh now let's go ahead and first of all validate all the inputs Right.

130
00:07:00,000 --> 00:07:02,000
So we're validating I will go ahead and write.

131
00:07:02,000 --> 00:07:03,000
If not okay.

132
00:07:04,000 --> 00:07:05,000
Grok API key.

133
00:07:05,000 --> 00:07:09,000
If the grok API key is not given okay I will also do a tag dot strip.

134
00:07:09,000 --> 00:07:14,000
Or I'll also go ahead and check for not URL dot strip.

135
00:07:14,000 --> 00:07:18,000
So we will also put a condition with respect to the URL.

136
00:07:18,000 --> 00:07:24,000
I'll say that hey, if the URL is not given okay, dot strip strip basically means removes the empty

137
00:07:24,000 --> 00:07:25,000
characters.

138
00:07:25,000 --> 00:07:30,000
I will just go ahead and give an error saying that SD dot error and I'll guide.

139
00:07:30,000 --> 00:07:35,000
Please provide the information.

140
00:07:36,000 --> 00:07:41,000
Please provide the information okay a generic information like that right.

141
00:07:41,000 --> 00:07:47,000
Otherwise I'll also give an else if condition where I'll say whether my URL that I've actually given

142
00:07:47,000 --> 00:07:49,000
uh we need to validate also that.

143
00:07:49,000 --> 00:07:49,000
Right.

144
00:07:49,000 --> 00:07:55,000
So here I will say if not validators dot URL.

145
00:07:55,000 --> 00:07:58,000
And here I'm going to basically go ahead and give my URL.

146
00:07:58,000 --> 00:08:02,000
So this URL can be your website URL.

147
00:08:02,000 --> 00:08:03,000
It can be a YouTube URL.

148
00:08:03,000 --> 00:08:07,000
So I'll go ahead and just write a generic URL over here.

149
00:08:07,000 --> 00:08:10,000
And here will be my API key.

150
00:08:10,000 --> 00:08:13,000
Here will be my generic URL itself.

151
00:08:13,000 --> 00:08:13,000
Right?

152
00:08:13,000 --> 00:08:16,000
So all this information is over here.

153
00:08:16,000 --> 00:08:18,000
I will also go ahead and make this particular check okay.

154
00:08:18,000 --> 00:08:24,000
So I'll say hey please provide the information to get started okay.

155
00:08:24,000 --> 00:08:26,000
Something like this some errors.

156
00:08:26,000 --> 00:08:28,000
We will try to put it over here.

157
00:08:28,000 --> 00:08:31,000
So now we are checking whether this URL URL is a validator.

158
00:08:31,000 --> 00:08:33,000
You validating your URL or not.

159
00:08:33,000 --> 00:08:34,000
It is a valid URL or not.

160
00:08:34,000 --> 00:08:35,000
So here.

161
00:08:35,000 --> 00:08:38,000
If it is not a valid URL, I will just go ahead and write SD dot error.

162
00:08:38,000 --> 00:08:45,000
Please enter a valid URL okay.

163
00:08:45,000 --> 00:08:47,000
And here I will also go ahead and write.

164
00:08:47,000 --> 00:08:52,000
It can maybe a just go ahead and write this error message.

165
00:08:52,000 --> 00:09:00,000
It can maybe a witty video URL or website URL.

166
00:09:01,000 --> 00:09:05,000
Okay so I'm giving some validation also so that you'll be able to check it out.

167
00:09:05,000 --> 00:09:11,000
Then finally in the else block, uh, what I will do is that if all these conditions are satisfied and

168
00:09:11,000 --> 00:09:16,000
this is where we have to start our coding and whatever happens in the back end.

169
00:09:16,000 --> 00:09:19,000
So I'll say, hey, go ahead and create a try block okay.

170
00:09:19,000 --> 00:09:22,000
And we will also handle the exception with respect to this.

171
00:09:22,000 --> 00:09:27,000
And I'll say hey width width street dot spinner.

172
00:09:27,000 --> 00:09:28,000
Okay.

173
00:09:28,000 --> 00:09:31,000
And I'll say waiting.

174
00:09:31,000 --> 00:09:32,000
Okay.

175
00:09:32,000 --> 00:09:35,000
Waiting till this entire information is basically coming up.

176
00:09:35,000 --> 00:09:41,000
You know, we will first of all load the we will load the URL itself right.

177
00:09:41,000 --> 00:09:42,000
URL data.

178
00:09:42,000 --> 00:09:48,000
So the first step over here is that loading the uh website data okay.

179
00:09:48,000 --> 00:09:55,000
Website or YouTube video data or y t video data.

180
00:09:55,000 --> 00:09:58,000
Okay, so once this is done, we go to the next step.

181
00:09:58,000 --> 00:10:04,000
I'll give a condition in my URL whether youtube.com is present or not.

182
00:10:04,000 --> 00:10:11,000
So if youtube.com is present in this generic URL, then what I'm actually going to do, I'm going to

183
00:10:11,000 --> 00:10:12,000
create a loader.

184
00:10:12,000 --> 00:10:16,000
And inside this I will be using this YouTube loader which I have actually initialized.

185
00:10:16,000 --> 00:10:18,000
As soon as we use the YouTube loader.

186
00:10:18,000 --> 00:10:27,000
All uh, there is an inbuilt function over here, like from YouTube URL where we can give the generic

187
00:10:27,000 --> 00:10:28,000
URL.

188
00:10:28,000 --> 00:10:28,000
Okay.

189
00:10:28,000 --> 00:10:34,000
And uh, we can also say, uh, whether I want to add the video information or not.

190
00:10:34,000 --> 00:10:42,000
So here there will be one more parameter which is called as add ad underscore video underscore info

191
00:10:42,000 --> 00:10:43,000
is equal to true.

192
00:10:43,000 --> 00:10:45,000
I'll keep it as true okay.

193
00:10:45,000 --> 00:10:49,000
So these are the basic information with respect to.

194
00:10:49,000 --> 00:10:53,000
Whenever we upload a YouTube URL I should be able to load this okay.

195
00:10:53,000 --> 00:11:00,000
Otherwise in the else condition I know that if I'm giving a if the generic URL is in the form of website,

196
00:11:00,000 --> 00:11:07,000
I will be using this loader and we can go ahead and use this unstructured unstructured URL road.

197
00:11:07,000 --> 00:11:07,000
Right?

198
00:11:07,000 --> 00:11:09,000
This is also one kind of loader over here.

199
00:11:09,000 --> 00:11:11,000
And here we will just give our URL.

200
00:11:11,000 --> 00:11:15,000
The URLs will be nothing, but it will be a list of.

201
00:11:15,000 --> 00:11:17,000
I can also give multiple URL if I want.

202
00:11:17,000 --> 00:11:17,000
Okay.

203
00:11:17,000 --> 00:11:19,000
So here I will be having this multiple URL.

204
00:11:19,000 --> 00:11:25,000
One more thing, I will also go ahead and make some checks saying that hey uh, whether it should be

205
00:11:25,000 --> 00:11:28,000
SSL verified, you can probably keep it as true or false right now.

206
00:11:28,000 --> 00:11:30,000
I'll just keep it as false just to take any URL.

207
00:11:30,000 --> 00:11:33,000
If I'm given, I will probably go ahead and do this here.

208
00:11:33,000 --> 00:11:35,000
It should be generic underscore URL.

209
00:11:35,000 --> 00:11:36,000
Okay.

210
00:11:36,000 --> 00:11:40,000
And one more information along with this will be that, uh, the kind of header.

211
00:11:40,000 --> 00:11:48,000
See, whenever you work with any um, whenever you work with any kind of let's say you're serving from

212
00:11:48,000 --> 00:11:51,000
any, uh, browser, right.

213
00:11:51,000 --> 00:11:56,000
So in that browser, you basically set up some kind of headers by default so that just to validate your

214
00:11:56,000 --> 00:11:58,000
browsing from the right, uh, right.

215
00:11:58,000 --> 00:11:59,000
Browser itself.

216
00:11:59,000 --> 00:11:59,000
Right.

217
00:11:59,000 --> 00:12:03,000
So I will be keeping this specific information over here.

218
00:12:03,000 --> 00:12:07,000
And uh, this headers you will be giving it over here.

219
00:12:07,000 --> 00:12:07,000
Right.

220
00:12:07,000 --> 00:12:17,000
So headers like user agent Mozilla 5.0 Macintosh, Intel Mac OS, uh Apple WebKit uh like gecko, Chrome,

221
00:12:17,000 --> 00:12:17,000
Safari.

222
00:12:17,000 --> 00:12:20,000
So all these browsers are basically supportable.

223
00:12:20,000 --> 00:12:25,000
So that is the reason we are providing this entire information over here, uh, saying that if that

224
00:12:25,000 --> 00:12:31,000
information if this header is basically there in the website, we should be able to, uh, probably

225
00:12:31,000 --> 00:12:32,000
go ahead and use this.

226
00:12:32,000 --> 00:12:33,000
Okay.

227
00:12:33,000 --> 00:12:38,000
So this is the header that we are setting and unstructured URL loader will be making sure that it's

228
00:12:38,000 --> 00:12:41,000
just like how we browse in the browser.

229
00:12:41,000 --> 00:12:42,000
right?

230
00:12:42,000 --> 00:12:46,000
We are able to browse different, different pages and when we are browser, they're also headers will

231
00:12:46,000 --> 00:12:48,000
be set up with respect to every request.

232
00:12:48,000 --> 00:12:51,000
Now here also when we are using this unstructured URL.

233
00:12:51,000 --> 00:12:53,000
In short this is hitting this particular URL.

234
00:12:53,000 --> 00:12:59,000
So whenever we are hitting this particular URL, the web server will also be demanding the kind of headers

235
00:12:59,000 --> 00:13:04,000
you are putting on top of it with respect to user agent, from which browser it's just like from which

236
00:13:04,000 --> 00:13:06,000
browser you are trying to execute it.

237
00:13:06,000 --> 00:13:09,000
That information, you are able to put it over here.

238
00:13:09,000 --> 00:13:16,000
Okay, now once you are able to do this, the next, the next step, let me just show over here.

239
00:13:16,000 --> 00:13:22,000
So the next step over here will be that, uh, I will get this particular data.

240
00:13:22,000 --> 00:13:22,000
Okay.

241
00:13:23,000 --> 00:13:30,000
And uh, once we get this data so I will say, hey, one, once I have set up the loader, I'll say

242
00:13:30,000 --> 00:13:33,000
loader dot load and I will be getting the data itself.

243
00:13:33,000 --> 00:13:35,000
Okay, so this is done.

244
00:13:35,000 --> 00:13:38,000
This is enough over here with respect to the try block.

245
00:13:38,000 --> 00:13:40,000
Now we are going to initialize.

246
00:13:41,000 --> 00:13:49,000
It is always a good idea that we initialize the grok model outside our, uh, you know, our, our entire,

247
00:13:50,000 --> 00:13:52,000
our, uh, application.

248
00:13:52,000 --> 00:13:54,000
So here I will only initialize it over here.

249
00:13:54,000 --> 00:13:58,000
I'll say, hey, LM is equal to chat grok with all this information.

250
00:13:58,000 --> 00:14:00,000
And let's pick up the grok API.

251
00:14:00,000 --> 00:14:03,000
So grok API is basically coming from here.

252
00:14:03,000 --> 00:14:05,000
Um I will go and set it over here.

253
00:14:05,000 --> 00:14:05,000
Right.

254
00:14:05,000 --> 00:14:08,000
So this is where we are basically setting it up.

255
00:14:08,000 --> 00:14:09,000
I'm not just putting it inside.

256
00:14:09,000 --> 00:14:15,000
I could have loaded my, uh, grok over here, but here will be my grok API.

257
00:14:15,000 --> 00:14:15,000
Okay.

258
00:14:15,000 --> 00:14:21,000
And with respect to this grok, this will be my gamma model that I'm using.

259
00:14:22,000 --> 00:14:24,000
Uh, using grok API right.

260
00:14:24,000 --> 00:14:25,000
Grok API.

261
00:14:25,000 --> 00:14:30,000
Once this is done, uh, we will also go ahead and set up our prompt template.

262
00:14:30,000 --> 00:14:30,000
Okay.

263
00:14:30,000 --> 00:14:33,000
So here I'm just going to go ahead and write my prompt.

264
00:14:33,000 --> 00:14:36,000
Template prompt template.

265
00:14:36,000 --> 00:14:42,000
And for this prompt template I'm going to specifically use a simple prompt template.

266
00:14:42,000 --> 00:14:44,000
Say I will just use this.

267
00:14:46,000 --> 00:14:46,000
Okay.

268
00:14:46,000 --> 00:14:47,000
I'll write.

269
00:14:47,000 --> 00:14:47,000
Hey.

270
00:14:50,000 --> 00:14:55,000
Go ahead and right away provide a summary.

271
00:14:57,000 --> 00:15:07,000
Of the following content of the following content in 300 words.

272
00:15:07,000 --> 00:15:10,000
Okay, so this is what I'm actually going to give over here.

273
00:15:10,000 --> 00:15:15,000
And this will basically be my text, the text info that I'm actually going to put over here.

274
00:15:15,000 --> 00:15:16,000
Right.

275
00:15:17,000 --> 00:15:22,000
So so I'll just go ahead and say this is this and this is my content okay.

276
00:15:22,000 --> 00:15:26,000
The content is equal to text okay.

277
00:15:26,000 --> 00:15:30,000
And then after this what we do, we basically go ahead and define a prompt.

278
00:15:30,000 --> 00:15:33,000
So with respect to the prompt I will go ahead and use my prompt template.

279
00:15:33,000 --> 00:15:38,000
The template will be equal to my prompt template.

280
00:15:38,000 --> 00:15:47,000
And finally my input variables will be nothing but it will be equal to text right.

281
00:15:47,000 --> 00:15:50,000
So I have to basically give it as text.

282
00:15:50,000 --> 00:15:54,000
So perfect I think everything is working fine till here.

283
00:15:54,000 --> 00:16:02,000
So what I did is that instead of writing my prompt over here, I have defined the prompt template and

284
00:16:02,000 --> 00:16:03,000
lm outside.

285
00:16:03,000 --> 00:16:14,000
Okay, now it's time we go ahead and create our chain some chain for summarization okay, so for this

286
00:16:14,000 --> 00:16:16,000
you know what you we really need to use it.

287
00:16:16,000 --> 00:16:19,000
So I'll go ahead and say chain is equal to load summarize chain.

288
00:16:19,000 --> 00:16:23,000
And here I'm going to use my LM chain underscore type.

289
00:16:23,000 --> 00:16:27,000
Let's go ahead and use stuff initially okay.

290
00:16:27,000 --> 00:16:30,000
Because the content may be small or may be bigger.

291
00:16:30,000 --> 00:16:31,000
It is up to you.

292
00:16:31,000 --> 00:16:31,000
Right.

293
00:16:31,000 --> 00:16:35,000
So you can use stuff or map reduce or anything that you want.

294
00:16:35,000 --> 00:16:38,000
Uh, along with this I will just go ahead and define my prompt.

295
00:16:38,000 --> 00:16:39,000
Okay.

296
00:16:39,000 --> 00:16:40,000
So let's go ahead and write.

297
00:16:40,000 --> 00:16:42,000
My prompt is equal to prompt okay.

298
00:16:42,000 --> 00:16:47,000
And here we will go ahead and run the summary dot chain.

299
00:16:47,000 --> 00:16:48,000
Okay.

300
00:16:48,000 --> 00:16:56,000
So once I write uh sorry it should be summary is equal to or I'll just write output underscore summary

301
00:16:56,000 --> 00:17:00,000
is equal to chain dot run.

302
00:17:00,000 --> 00:17:03,000
And here I'm going to give my data okay.

303
00:17:03,000 --> 00:17:07,000
Or the data whatever data we are specifically getting uh over here instead of data.

304
00:17:07,000 --> 00:17:13,000
We will just go ahead and write docs because documents is what we usually get, right.

305
00:17:13,000 --> 00:17:16,000
So here also I will be giving my documents.

306
00:17:16,000 --> 00:17:16,000
Okay.

307
00:17:17,000 --> 00:17:17,000
Perfect.

308
00:17:17,000 --> 00:17:19,000
Till here everything looks good.

309
00:17:19,000 --> 00:17:22,000
And finally I will say TX dot success.

310
00:17:23,000 --> 00:17:24,000
Success right?

311
00:17:24,000 --> 00:17:28,000
And that is the reason you get green color in the demo, right?

312
00:17:28,000 --> 00:17:33,000
Uh, I will just go ahead and display my output summary.

313
00:17:33,000 --> 00:17:34,000
Perfect.

314
00:17:37,000 --> 00:17:37,000
Done.

315
00:17:38,000 --> 00:17:39,000
This is good enough.

316
00:17:39,000 --> 00:17:44,000
Now, in the accept block, we can probably go ahead and write our exception.

317
00:17:45,000 --> 00:17:50,000
So I will go ahead and write accept exception as E.

318
00:17:51,000 --> 00:17:54,000
And then we are just going to write TX dot exception.

319
00:17:57,000 --> 00:18:00,000
As exception.

320
00:18:01,000 --> 00:18:02,000
Colon e.

321
00:18:02,000 --> 00:18:03,000
Right.

322
00:18:03,000 --> 00:18:04,000
Perfect.

323
00:18:04,000 --> 00:18:05,000
So till here.

324
00:18:05,000 --> 00:18:06,000
Everything looks good.

325
00:18:07,000 --> 00:18:09,000
I think, uh, it should run.

326
00:18:09,000 --> 00:18:10,000
It should run.

327
00:18:10,000 --> 00:18:13,000
Okay, let's go ahead and execute it.

328
00:18:13,000 --> 00:18:15,000
So here I'm in my venv environment.

329
00:18:15,000 --> 00:18:19,000
Let's go back to my folder that is seventh text summarization.

330
00:18:19,000 --> 00:18:22,000
So I will go ahead and write seven text summarization.

331
00:18:22,000 --> 00:18:30,000
Here I will go ahead and write Streamlit run Streamlit run app.py.

332
00:18:30,000 --> 00:18:32,000
So let's go ahead and write App.py.

333
00:18:32,000 --> 00:18:35,000
Now I think everything should work fine.

334
00:18:35,000 --> 00:18:38,000
So this is my page.

335
00:18:38,000 --> 00:18:39,000
It looks fine.

336
00:18:39,000 --> 00:18:42,000
Grok API summarize the content from the YouTube website.

337
00:18:42,000 --> 00:18:44,000
Let me go back to my code.

338
00:18:44,000 --> 00:18:46,000
Let me open my env file.

339
00:18:46,000 --> 00:18:47,000
Right.

340
00:18:47,000 --> 00:18:51,000
And let me just pick up this grok API key.

341
00:18:51,000 --> 00:18:52,000
Right.

342
00:18:52,000 --> 00:18:53,000
All the API keys.

343
00:18:53,000 --> 00:18:55,000
You can specifically use it okay.

344
00:18:55,000 --> 00:18:57,000
Just to practice.

345
00:18:57,000 --> 00:19:00,000
So I'll press enter okay.

346
00:19:00,000 --> 00:19:02,000
Now let me do one thing.

347
00:19:02,000 --> 00:19:09,000
Let me use any website docs, Len Smith, whatever website you want I will go ahead and copy this.

348
00:19:09,000 --> 00:19:11,000
Put it over here.

349
00:19:12,000 --> 00:19:15,000
Um, module has no attribute exception.

350
00:19:15,000 --> 00:19:17,000
The reason exception.

351
00:19:17,000 --> 00:19:26,000
Okay, let's see this s t dot exception I think it should be in small letter okay.

352
00:19:26,000 --> 00:19:27,000
Now it should work.

353
00:19:29,000 --> 00:19:31,000
Always run I will summarize.

354
00:19:31,000 --> 00:19:36,000
So it is saying me to install this unstructured because we have used this unstructured over here.

355
00:19:36,000 --> 00:19:38,000
So let's go ahead and install this.

356
00:19:38,000 --> 00:19:42,000
And these are some of the errors that you may get if you missed any requirement.

357
00:19:42,000 --> 00:19:43,000
Dot txt right.

358
00:19:43,000 --> 00:19:46,000
And I want to show you all these errors okay.

359
00:19:46,000 --> 00:19:51,000
So quickly I will go ahead and open my another command prompt okay.

360
00:19:51,000 --> 00:19:57,000
So I'll say hey pip install please make sure that you do the installation in your v env environment

361
00:19:57,000 --> 00:20:01,000
right requirement dot txt once I do this.

362
00:20:03,000 --> 00:20:06,000
So here you'll be able to see this I think one more error.

363
00:20:06,000 --> 00:20:10,000
We may get it but let's see whether we'll get that error or not okay.

364
00:20:10,000 --> 00:20:16,000
So once this unstructured is basically getting installed YouTube transcript API I've already done it.

365
00:20:16,000 --> 00:20:18,000
Validators I have already done it.

366
00:20:18,000 --> 00:20:21,000
I think I do not have to probably get any kind of errors other than this.

367
00:20:21,000 --> 00:20:27,000
So now if I go ahead and summarize it, let's see.

368
00:20:27,000 --> 00:20:29,000
I think it should work.

369
00:20:29,000 --> 00:20:33,000
One more error can come again for the library.

370
00:20:33,000 --> 00:20:36,000
But I think other than that it should work okay.

371
00:20:38,000 --> 00:20:40,000
Why it is taking so much time.

372
00:20:41,000 --> 00:20:42,000
So it's better okay.

373
00:20:42,000 --> 00:20:43,000
Yeah.

374
00:20:43,000 --> 00:20:43,000
Perfect.

375
00:20:43,000 --> 00:20:45,000
So it shows you the output, right.

376
00:20:46,000 --> 00:20:48,000
Uh, let's try some other, uh, URL.

377
00:20:48,000 --> 00:20:49,000
Okay.

378
00:20:49,000 --> 00:20:56,000
So what I will do is that I will quickly go ahead and take some more URLs if I want.

379
00:20:56,000 --> 00:20:57,000
Okay.

380
00:20:57,000 --> 00:20:58,000
I can go and search for this.

381
00:20:58,000 --> 00:21:01,000
So let's take this entire URL.

382
00:21:02,000 --> 00:21:02,000
Okay.

383
00:21:02,000 --> 00:21:05,000
My entire page URL over here.

384
00:21:06,000 --> 00:21:10,000
And with respect to this particular URL, I will just go ahead and open this.

385
00:21:10,000 --> 00:21:14,000
And if you can try it with any YouTube channel video.

386
00:21:14,000 --> 00:21:16,000
Okay, so this is one of the URL.

387
00:21:16,000 --> 00:21:18,000
So it is necessary to properly test each and everything.

388
00:21:18,000 --> 00:21:20,000
So here I have given my YouTube video.

389
00:21:20,000 --> 00:21:23,000
I have to probably go ahead and install Pi tube okay.

390
00:21:23,000 --> 00:21:26,000
And this is one of the requirements I guess with transcript API.

391
00:21:26,000 --> 00:21:29,000
So I will quickly go ahead and copy and paste it over here.

392
00:21:29,000 --> 00:21:31,000
Let's go ahead and do the installation now.

393
00:21:31,000 --> 00:21:33,000
I think it should work okay.

394
00:21:34,000 --> 00:21:35,000
So basic basic requirements.

395
00:21:35,000 --> 00:21:39,000
And that is the reason you have to probably create an another environment for this.

396
00:21:39,000 --> 00:21:39,000
Right.

397
00:21:39,000 --> 00:21:43,000
So this is the version that you are having okay.

398
00:21:43,000 --> 00:21:45,000
So let's summarize.

399
00:21:47,000 --> 00:21:51,000
And now we should be able to get the output.

400
00:21:51,000 --> 00:21:52,000
Here you go.

401
00:21:52,000 --> 00:21:54,000
Right generative I explain.

402
00:21:54,000 --> 00:21:57,000
So yes uh this was it for my side.

403
00:21:57,000 --> 00:22:00,000
I hope you like this particular video and I hope you are liking the entire course.

404
00:22:00,000 --> 00:22:03,000
Uh, so yes, I will see you all in the next video.

405
00:22:03,000 --> 00:22:03,000
Thank you.

406
00:22:03,000 --> 00:22:04,000
Take care.

