1
00:00:00,000 --> 00:00:01,000
Hello guys.

2
00:00:01,000 --> 00:00:04,000
We are going to continue our generative AI on AWS Cloud series.

3
00:00:04,000 --> 00:00:10,000
And in this specific video, we are going to develop an amazing end to end generative AI application,

4
00:00:11,000 --> 00:00:14,000
uh, using various services that are present in AWS cloud.

5
00:00:14,000 --> 00:00:18,000
I will give you a brief architecture, what we are going to implement.

6
00:00:18,000 --> 00:00:24,000
And then step by step, I will be showing you how you can use various services that are present in AWS

7
00:00:24,000 --> 00:00:27,000
and implement some amazing generative AI applications.

8
00:00:27,000 --> 00:00:32,000
So what we are going to probably do in this specific use case, uh, this use case, I'm just going

9
00:00:32,000 --> 00:00:34,000
to keep it as uh, block generation.

10
00:00:34,000 --> 00:00:36,000
So here you can probably see block generation.

11
00:00:36,000 --> 00:00:43,000
Is that uh, initially what we will do is that our main aim over here will be to create an API.

12
00:00:43,000 --> 00:00:43,000
Okay.

13
00:00:43,000 --> 00:00:45,000
So we will try to create an API.

14
00:00:45,000 --> 00:00:50,000
So we are going to use postman to hit this specific API with some specific body.

15
00:00:50,000 --> 00:00:53,000
Uh that body can include query.

16
00:00:53,000 --> 00:00:54,000
Okay.

17
00:00:54,000 --> 00:00:55,000
Query from the user.

18
00:00:55,000 --> 00:00:58,000
Like what blocks we need to probably generate.

19
00:00:58,000 --> 00:01:05,000
And as you know, in AWS, uh, in order to create APIs, we use Amazon API gateway.

20
00:01:05,000 --> 00:01:07,000
So we are going to also use this.

21
00:01:07,000 --> 00:01:11,000
As soon as we trigger this particular API, it is going to hit our Lambda function.

22
00:01:11,000 --> 00:01:14,000
What exactly is the Lambda function will also understand about that.

23
00:01:14,000 --> 00:01:19,000
This lambda function in turn will be interacting with Amazon bedrock.

24
00:01:19,000 --> 00:01:26,000
Okay, now if you don't know about Amazon bedrock, here are all the foundation models will be available.

25
00:01:26,000 --> 00:01:26,000
Right.

26
00:01:26,000 --> 00:01:29,000
Foundation models will be available.

27
00:01:29,000 --> 00:01:31,000
Foundational models will be available.

28
00:01:31,000 --> 00:01:38,000
Like uh, Amazon has lot of different different foundation models like uh la la la la la to you know,

29
00:01:38,000 --> 00:01:42,000
it also has paid from cloud anthropic specifically cloudy models and all are there.

30
00:01:42,000 --> 00:01:47,000
We'll go ahead and see what are all these kind of fine ocean models and how we can specifically use

31
00:01:47,000 --> 00:01:48,000
that.

32
00:01:48,000 --> 00:01:53,000
And this lambda function will be responsible taking up the query, hitting this particular foundation

33
00:01:53,000 --> 00:01:58,000
model and getting back the response once we get the response in this particular case will be our entire

34
00:01:58,000 --> 00:02:03,000
blog, the 200 words or 300 blog blogs that we are probably going to create.

35
00:02:03,000 --> 00:02:08,000
And finally, what we are going to do is that we are going to take that specific block and save it in

36
00:02:08,000 --> 00:02:12,000
AWS, S3 in the form of text file or any kind of files.

37
00:02:12,000 --> 00:02:12,000
Okay.

38
00:02:12,000 --> 00:02:17,000
We can also convert that into a PDF file and save it in Amazon S3 with the recent timestamp.

39
00:02:17,000 --> 00:02:17,000
Okay.

40
00:02:17,000 --> 00:02:22,000
So this is the entire thing that we are going to implement and understand.

41
00:02:22,000 --> 00:02:26,000
This kind of use cases is even available in AWS documentation.

42
00:02:27,000 --> 00:02:31,000
Uh, and many, many companies are implementing the generative AI application in this way.

43
00:02:31,000 --> 00:02:36,000
As we go ahead with respect to the series, in the future, we will also be developing some amazing

44
00:02:36,000 --> 00:02:38,000
applications that are related to Rag.

45
00:02:38,000 --> 00:02:43,000
You know, different document Q&A, how we can actually use vector databases.

46
00:02:43,000 --> 00:02:48,000
Uh, I will be showing you all those things, and we will try to use all the ecosystem that is provided

47
00:02:48,000 --> 00:02:49,000
by AWS cloud.

48
00:02:49,000 --> 00:02:54,000
One of the important, uh, you can probably consider that in most of the companies.

49
00:02:54,000 --> 00:02:56,000
They are specifically asking this in interviews.

50
00:02:56,000 --> 00:03:01,000
They definitely want you to say that how you can probably implement anything in AWS cloud with respect

51
00:03:01,000 --> 00:03:03,000
to the generative AI application.

52
00:03:03,000 --> 00:03:05,000
So, uh, so many different things.

53
00:03:05,000 --> 00:03:07,000
Uh, we are going to go ahead and see.

54
00:03:07,000 --> 00:03:10,000
So first of all, uh, let's go back to your AWS account.

55
00:03:10,000 --> 00:03:14,000
So initially you really need to have an AWS account and make sure that you have it.

56
00:03:14,000 --> 00:03:16,000
Then only you'll be able to use all those services.

57
00:03:16,000 --> 00:03:21,000
Now, first of all, what I'm actually going to do is that I'm going to go to AWS bedrock and just give

58
00:03:21,000 --> 00:03:26,000
you an idea like how does all the foundation model looks like and what our foundation model is specifically

59
00:03:26,000 --> 00:03:28,000
provided by Amazon bedrock.

60
00:03:28,000 --> 00:03:29,000
Okay.

61
00:03:29,000 --> 00:03:31,000
So first I will go ahead and click this.

62
00:03:31,000 --> 00:03:35,000
And here you can probably see that my Amazon Bedrock will get loaded.

63
00:03:35,000 --> 00:03:39,000
Once it is getting loaded you can probably go ahead and click on Get Started.

64
00:03:39,000 --> 00:03:43,000
Now with respect to this you can see over here foundation models are specifically over there.

65
00:03:43,000 --> 00:03:46,000
And you can actually do chat text image.

66
00:03:46,000 --> 00:03:49,000
So uh it supports multiple models itself.

67
00:03:49,000 --> 00:03:52,000
Now which all companies model is basically there in this foundation model.

68
00:03:52,000 --> 00:03:56,000
Here you have a 1 to 1 labs that's from Jurassic to series.

69
00:03:56,000 --> 00:04:01,000
Uh you have Titan by Amazon, you have cloud by anthropic, you have command by cohere, you have llama

70
00:04:01,000 --> 00:04:03,000
three, you have Mistral, you have stable diffusion.

71
00:04:03,000 --> 00:04:06,000
So you can actually work in images also.

72
00:04:06,000 --> 00:04:08,000
And you can generate your own image as you want, right.

73
00:04:08,000 --> 00:04:11,000
Let's say if I really want to use llama three.

74
00:04:11,000 --> 00:04:16,000
So I will go ahead and see this here we can probably see all these things are there like llama 213 B,

75
00:04:16,000 --> 00:04:19,000
llama two chat, 13 B, and even llama three is also there.

76
00:04:19,000 --> 00:04:24,000
I will also show you that you can also go ahead and check it out in the playground, chat with it and

77
00:04:24,000 --> 00:04:25,000
probably get it now.

78
00:04:25,000 --> 00:04:30,000
The first step, uh, before we start all these things right, our first step is specifically to make

79
00:04:30,000 --> 00:04:36,000
sure that we have to take the model access, understand with respect to different, different region.

80
00:04:36,000 --> 00:04:36,000
Yeah.

81
00:04:36,000 --> 00:04:38,000
You will be having the access of different different models.

82
00:04:38,000 --> 00:04:40,000
So you have to request for it okay.

83
00:04:40,000 --> 00:04:45,000
Here you can see that in my in my region that is I have selected us East one.

84
00:04:45,000 --> 00:04:48,000
You'll be able to see that I have granted access to all these models.

85
00:04:48,000 --> 00:04:53,000
Anthropic cloud three models are not given because for this you really need to provide some use case,

86
00:04:53,000 --> 00:04:54,000
uh, details.

87
00:04:54,000 --> 00:04:56,000
Uh, and then you have to submit it.

88
00:04:56,000 --> 00:05:00,000
Then the anthropic will give you the access itself, like what kind of use cases you are basically doing.

89
00:05:00,000 --> 00:05:05,000
But according to mine, I have already, you can probably see that I have got this access granted,

90
00:05:05,000 --> 00:05:10,000
in order to get this access, you just click on Manage Model Access, select which all model, which

91
00:05:10,000 --> 00:05:13,000
all models you specifically want as access.

92
00:05:13,000 --> 00:05:15,000
And just go ahead and click on Save Changes.

93
00:05:15,000 --> 00:05:17,000
Okay I've already done that.

94
00:05:17,000 --> 00:05:21,000
So here you can also see that the Save Changes button is over here.

95
00:05:21,000 --> 00:05:23,000
So here you can probably see save changes is there.

96
00:05:23,000 --> 00:05:27,000
You can go ahead and probably click on this whatever models you specifically want.

97
00:05:27,000 --> 00:05:28,000
Just go ahead and check it out.

98
00:05:28,000 --> 00:05:32,000
And then in some time you will be getting the excess model okay.

99
00:05:32,000 --> 00:05:34,000
The model excess will be granted.

100
00:05:34,000 --> 00:05:37,000
So this is the first step that you really need to do okay.

101
00:05:37,000 --> 00:05:43,000
Now once you specifically do it uh, then I will show you how you can go ahead and invoke all these

102
00:05:43,000 --> 00:05:45,000
counter foundation models and how you can go ahead.

103
00:05:45,000 --> 00:05:45,000
Okay.

104
00:05:45,000 --> 00:05:48,000
So this was one of the services that we are going to use.

105
00:05:48,000 --> 00:05:50,000
The next services is specifically lambda function.

106
00:05:50,000 --> 00:05:53,000
What exactly is lambda function will try to understand.

107
00:05:53,000 --> 00:05:57,000
So yeah here I will go ahead and search for AWS Lambda.

108
00:05:57,000 --> 00:06:01,000
So here you can see what is Lambda console in AWS.

109
00:06:01,000 --> 00:06:03,000
Uh quickly to test an event.

110
00:06:03,000 --> 00:06:06,000
It is a serverless to manage application in.

111
00:06:06,000 --> 00:06:10,000
Okay, I will just go ahead and search what is AWS Lambda?

112
00:06:10,000 --> 00:06:11,000
Okay.

113
00:06:11,000 --> 00:06:17,000
So if you probably go ahead and see the definition with respect to AWS Lambda, um, it's saying that

114
00:06:17,000 --> 00:06:19,000
run code without thinking about servers or clusters.

115
00:06:19,000 --> 00:06:27,000
See, instead of AWS Lambda, I can also use a EC2 instance in AWS and then probably set up all the

116
00:06:27,000 --> 00:06:32,000
things, install all my requirements over there, set up all the libraries, develop my entire application,

117
00:06:32,000 --> 00:06:36,000
and then probably with the help of API gateway, I can probably interact with that.

118
00:06:36,000 --> 00:06:41,000
And within that EC2 instance, I will try to invoke my AWS bedrock that also you can probably do.

119
00:06:41,000 --> 00:06:44,000
And in the going upcoming examples, I'll also show you that if you want.

120
00:06:44,000 --> 00:06:46,000
But right now we are going to use AWS Lambda.

121
00:06:46,000 --> 00:06:50,000
So the AWS Lambda is a compute service that runs your code in response to an event.

122
00:06:50,000 --> 00:06:55,000
So suppose if I hit an API this is going to get triggered And then it will go ahead and call the AWS

123
00:06:55,000 --> 00:06:56,000
bedrock.

124
00:06:56,000 --> 00:06:59,000
So the benefits of Lambda is that no need of managing servers.

125
00:06:59,000 --> 00:07:01,000
It is automatically scaling.

126
00:07:01,000 --> 00:07:05,000
And you have to probably pay as you go like based on the number of requests.

127
00:07:05,000 --> 00:07:09,000
And then performance optimization will also be taking place in the AWS Lambda itself.

128
00:07:10,000 --> 00:07:12,000
Uh, many, many companies specifically use that.

129
00:07:12,000 --> 00:07:15,000
If you have a smaller application, you can definitely develop this.

130
00:07:16,000 --> 00:07:21,000
Um, so let's go ahead and let's try to see that how we can go ahead and work with AWS Lambda.

131
00:07:21,000 --> 00:07:22,000
So here you can probably see AWS Lambda.

132
00:07:22,000 --> 00:07:25,000
As soon as I click on AWS Lambda this will get opened.

133
00:07:25,000 --> 00:07:27,000
Here you can create multiple functions.

134
00:07:27,000 --> 00:07:29,000
I have already created one function.

135
00:07:29,000 --> 00:07:31,000
I will show you, uh, how to create this.

136
00:07:31,000 --> 00:07:34,000
So let's go ahead and create the function over here.

137
00:07:34,000 --> 00:07:40,000
So as soon as I probably create the function here you can see I can select author from scratch.

138
00:07:40,000 --> 00:07:44,000
Use a blueprint container, image, whatever things you specifically want here.

139
00:07:44,000 --> 00:07:49,000
What I'm actually going to do is that I'm going to give my function name and my function name.

140
00:07:49,000 --> 00:07:57,000
What I can do over here is let's say I'll give my AWS app okay with bedrock.

141
00:07:57,000 --> 00:07:57,000
Okay.

142
00:07:57,000 --> 00:08:03,000
So this will basically be my AWS function, uh, function name, uh lambda function name, uh runtime

143
00:08:03,000 --> 00:08:09,000
I will go ahead and use Python 3.12, uh, just to make sure that I have the recent updated Python.

144
00:08:09,000 --> 00:08:12,000
And along with that, whatever by default is there.

145
00:08:12,000 --> 00:08:13,000
You can go ahead and select that.

146
00:08:13,000 --> 00:08:16,000
But here I'll just keep it since we are developing it for the first time.

147
00:08:16,000 --> 00:08:18,000
And I'll go ahead and click on create function.

148
00:08:18,000 --> 00:08:23,000
As soon as I probably create the function here, you'll be able to see that my AWS app bedrock uh,

149
00:08:23,000 --> 00:08:25,000
Lambda function will get created.

150
00:08:25,000 --> 00:08:32,000
And again, uh, this takes time, some amount of time based on the internet speed and the kind of application

151
00:08:32,000 --> 00:08:33,000
that you are developing.

152
00:08:33,000 --> 00:08:35,000
So here you can see that it has got created.

153
00:08:35,000 --> 00:08:36,000
It is bedrock.

154
00:08:36,000 --> 00:08:37,000
I will show you.

155
00:08:37,000 --> 00:08:41,000
Here are some options like layers add triggers, add destination.

156
00:08:41,000 --> 00:08:45,000
Now see, my main aim is that as soon as I probably create a API gateway, right?

157
00:08:45,000 --> 00:08:50,000
Because I need to hit the API, then only this, uh function should get triggered.

158
00:08:50,000 --> 00:08:56,000
Right inside this function, I will write my entire code how to invoke the bedrock AWS Bedrock Foundation

159
00:08:56,000 --> 00:08:56,000
models and.

160
00:08:56,000 --> 00:09:01,000
All right, so if you go down here, you will be also able to see some amazing things like code test

161
00:09:01,000 --> 00:09:04,000
monitor configuration analysis version.

162
00:09:04,000 --> 00:09:09,000
So if I go ahead and click on configuration here you can see there is some timeout configuration that

163
00:09:09,000 --> 00:09:10,000
you can probably give.

164
00:09:10,000 --> 00:09:11,000
There are some environment variables.

165
00:09:11,000 --> 00:09:12,000
If you want to probably give.

166
00:09:12,000 --> 00:09:14,000
You can also give it over here directly.

167
00:09:14,000 --> 00:09:18,000
Environment variables I hope I've shown you in VS code we create a dot env file.

168
00:09:18,000 --> 00:09:22,000
We create a key like open a I api key and all here.

169
00:09:22,000 --> 00:09:26,000
Also you can probably write it down and you can call that open API key in this particular code.

170
00:09:26,000 --> 00:09:28,000
So one general configuration.

171
00:09:28,000 --> 00:09:31,000
What I will do is that I'll keep this timeout to three minutes.

172
00:09:31,000 --> 00:09:38,000
Because just to keep it in the safer side so that it does not get, um, hampered over there.

173
00:09:38,000 --> 00:09:40,000
And here I'm going to write my entire code.

174
00:09:40,000 --> 00:09:40,000
Okay.

175
00:09:40,000 --> 00:09:45,000
Now before I write my entire code, uh, whatever code I'm going to write, I'll be writing over here.

176
00:09:45,000 --> 00:09:52,000
But again, this does not look very comfortable writing the code because here I will not be able to

177
00:09:52,000 --> 00:09:57,000
get much, uh, you know, suggestion with respect to the code, it is better that I write this entire

178
00:09:57,000 --> 00:10:02,000
code in the, uh, in my VS code, and then I'll copy and paste it over here.

179
00:10:02,000 --> 00:10:02,000
Okay.

180
00:10:03,000 --> 00:10:04,000
So what code?

181
00:10:04,000 --> 00:10:06,000
I'm going to write it down over here.

182
00:10:06,000 --> 00:10:09,000
I'll be showing you that specific code with respect to this okay.

183
00:10:09,000 --> 00:10:13,000
So let me just go ahead and open my VS code over here.

184
00:10:13,000 --> 00:10:18,000
And here is one of my I will just open my terminal okay.

185
00:10:19,000 --> 00:10:20,000
Oops.

186
00:10:20,000 --> 00:10:22,000
Let me just go ahead and open my terminal.

187
00:10:22,000 --> 00:10:25,000
And I'm here I'm going to write my code completely okay.

188
00:10:26,000 --> 00:10:27,000
Uh command prompt.

189
00:10:27,000 --> 00:10:30,000
So first of all I will just go ahead and create my environment.

190
00:10:30,000 --> 00:10:37,000
So let me just go ahead and write conda create minus p v and v environment Python.

191
00:10:37,000 --> 00:10:41,000
As you know I have taken 3.12 okay.

192
00:10:41,000 --> 00:10:44,000
So this is the environment that I'm going to create because I'm going to write my entire code over here

193
00:10:44,000 --> 00:10:46,000
with some requirement dot txt and all.

194
00:10:46,000 --> 00:10:49,000
So let me just create this.

195
00:10:49,000 --> 00:10:52,000
I'll create one file which is called as requirements dot txt.

196
00:10:52,000 --> 00:10:59,000
So whatever is required uh, for my project and that I have to actually put it in my lambda function

197
00:10:59,000 --> 00:11:00,000
all.

198
00:11:00,000 --> 00:11:01,000
I will be writing it over here.

199
00:11:01,000 --> 00:11:03,000
Okay so requirement dot txt.

200
00:11:03,000 --> 00:11:07,000
Let's wait till this entire is getting created.

201
00:11:07,000 --> 00:11:10,000
Uh, so here you can see a new version of this.

202
00:11:10,000 --> 00:11:12,000
This and I will go just go ahead and click on yes.

203
00:11:12,000 --> 00:11:15,000
And automatically my entire Conda environment will get created.

204
00:11:15,000 --> 00:11:17,000
So there are two important things that I'll do.

205
00:11:17,000 --> 00:11:20,000
First, let me go ahead and write the code for this.

206
00:11:20,000 --> 00:11:23,000
What all things I actually require I'll be writing it.

207
00:11:23,000 --> 00:11:30,000
Let me create a file also app.py okay and requirement dot txt.

208
00:11:30,000 --> 00:11:35,000
The first library I actually want is nothing but boto3, so I'll keep this boto3 like this.

209
00:11:35,000 --> 00:11:40,000
And whatever is the recent version of the Boto3 that is only supported by lambda function.

210
00:11:40,000 --> 00:11:47,000
Okay, not the previous one because the recent version of boto three has lot of lots of functionalities

211
00:11:47,000 --> 00:11:49,000
to invoke foundation models from AWS bedrock.

212
00:11:49,000 --> 00:11:51,000
Okay, so you should know all these things.

213
00:11:51,000 --> 00:11:55,000
Okay, so let me quickly go ahead and write my code now over here.

214
00:11:55,000 --> 00:11:58,000
So first of all I will go ahead and write import Boto three.

215
00:11:59,000 --> 00:12:06,000
And I'm just going to write import boto core dot config.

216
00:12:06,000 --> 00:12:10,000
Okay so this is two important libraries that we specifically use.

217
00:12:10,000 --> 00:12:15,000
Understand boto three is used to invoke the foundation model okay.

218
00:12:15,000 --> 00:12:20,000
So here I will just go ahead and do one thing okay.

219
00:12:20,000 --> 00:12:21,000
So let me just go ahead and see.

220
00:12:21,000 --> 00:12:25,000
This is my Venv I will just go ahead and activate.

221
00:12:25,000 --> 00:12:34,000
So conda activate V and V along with this what I'm going to do I'm going to just write pip install minus

222
00:12:34,000 --> 00:12:39,000
r requirements.txt so that my boto3 gets installed at any point of time.

223
00:12:39,000 --> 00:12:39,000
Okay.

224
00:12:39,000 --> 00:12:41,000
So this installation will take place.

225
00:12:41,000 --> 00:12:42,000
Let it take place.

226
00:12:42,000 --> 00:12:44,000
Till then I will go ahead and start writing my code.

227
00:12:44,000 --> 00:12:45,000
Okay.

228
00:12:45,000 --> 00:12:46,000
Now what I'm actually going to do.

229
00:12:46,000 --> 00:12:48,000
My main aim is to create a blog, right?

230
00:12:48,000 --> 00:12:50,000
I really need to write a blog.

231
00:12:50,000 --> 00:12:51,000
I need to create a blog.

232
00:12:51,000 --> 00:12:54,000
And for that, uh Uh, what?

233
00:12:54,000 --> 00:12:57,000
All things I will be doing, I'll be showing you step by step.

234
00:12:57,000 --> 00:13:00,000
Uh, let me just do one thing.

235
00:13:00,000 --> 00:13:02,000
I will keep my notepad over here.

236
00:13:02,000 --> 00:13:09,000
The reason why I'm keeping the notepad so that, uh, uh, step by step, uh, I have from the documentation,

237
00:13:09,000 --> 00:13:12,000
I've, I've taken all the steps, what is basically required.

238
00:13:12,000 --> 00:13:17,000
And, uh, when we have to create what, what services needs to be created and all, I will be writing

239
00:13:17,000 --> 00:13:18,000
all those things.

240
00:13:18,000 --> 00:13:18,000
right?

241
00:13:18,000 --> 00:13:26,000
So, uh, I will create a function which will basically be called as definition blog underscore generate

242
00:13:26,000 --> 00:13:29,000
using bedrock.

243
00:13:29,000 --> 00:13:29,000
Okay.

244
00:13:29,000 --> 00:13:31,000
So this will basically be my function name.

245
00:13:31,000 --> 00:13:40,000
And uh when I create this function I will also use this I will uh give my query or message or what blog

246
00:13:40,000 --> 00:13:41,000
topic.

247
00:13:41,000 --> 00:13:46,000
I can also basically say blog topic, blog topic and this will basically be a string.

248
00:13:46,000 --> 00:13:50,000
And uh, this will also return a string.

249
00:13:51,000 --> 00:13:51,000
Okay.

250
00:13:51,000 --> 00:13:53,000
This will also return a string.

251
00:13:53,000 --> 00:13:54,000
Right.

252
00:13:54,000 --> 00:13:58,000
So this will basically be my function which will generate a blog here.

253
00:13:58,000 --> 00:14:01,000
Uh, what kind of blog I'm going to use uh, that I will be discussing.

254
00:14:01,000 --> 00:14:04,000
Sorry, what kind of foundation model that I will be using.

255
00:14:04,000 --> 00:14:09,000
So first of all, let me just go ahead and create all my prompts since I'm going to create a multi line

256
00:14:09,000 --> 00:14:09,000
character.

257
00:14:09,000 --> 00:14:13,000
So I will go ahead and write this and create a blind blog okay.

258
00:14:13,000 --> 00:14:14,000
Over here okay.

259
00:14:14,000 --> 00:14:15,000
So sorry.

260
00:14:15,000 --> 00:14:17,000
My prompt I'll write my prompt.

261
00:14:17,000 --> 00:14:23,000
And before I write my prompt uh let's go and see which Amazon Bedrock uh model I will be specifically

262
00:14:23,000 --> 00:14:23,000
using.

263
00:14:23,000 --> 00:14:27,000
Llama two chat 13 b I can specifically go with this.

264
00:14:27,000 --> 00:14:30,000
And here you can probably see this is my model name okay.

265
00:14:30,000 --> 00:14:32,000
Model ID okay.

266
00:14:32,000 --> 00:14:36,000
You you you really need to remember this because these are all the things that I really need to give.

267
00:14:36,000 --> 00:14:40,000
The content type will be application, slash, JSON and body.

268
00:14:40,000 --> 00:14:41,000
This is the most important thing.

269
00:14:41,000 --> 00:14:44,000
What is the prompt that I am going to probably put over here?

270
00:14:44,000 --> 00:14:48,000
What are the other information that you basically provide with respect to the body?

271
00:14:48,000 --> 00:14:49,000
Right.

272
00:14:49,000 --> 00:14:52,000
So this all information definitely you really need to provide.

273
00:14:52,000 --> 00:15:00,000
Similarly if you go with llama two chat uh uh llama two chat uh, 70 billion parameters.

274
00:15:00,000 --> 00:15:04,000
So here you can see this is where your, uh, this is where you place your input text.

275
00:15:04,000 --> 00:15:05,000
Okay.

276
00:15:05,000 --> 00:15:10,000
And similarly if you go ahead and explore llama 213 billion, you can also see other information with

277
00:15:10,000 --> 00:15:11,000
respect to.

278
00:15:11,000 --> 00:15:14,000
So each and every model how the API request should be.

279
00:15:14,000 --> 00:15:18,000
You should be able to get it from the AWS bedrock itself.

280
00:15:18,000 --> 00:15:18,000
Okay.

281
00:15:18,000 --> 00:15:23,000
So all the information are specifically over here and you can basically check it out, right?

282
00:15:23,000 --> 00:15:25,000
So whatever model you want to use okay.

283
00:15:25,000 --> 00:15:29,000
You have to make sure that what body what API request is specifically there.

284
00:15:29,000 --> 00:15:31,000
Based on that only you have to probably create everything.

285
00:15:31,000 --> 00:15:32,000
Okay.

286
00:15:32,000 --> 00:15:38,000
Now what I'm actually going to do is that I'm going to create my prompt.

287
00:15:38,000 --> 00:15:39,000
Okay.

288
00:15:39,000 --> 00:15:42,000
Now in this specific prompt I'm going to basically write.

289
00:15:43,000 --> 00:15:47,000
an S character and let me just go ahead and provide like this s.

290
00:15:47,000 --> 00:15:51,000
So the first thing is that I will be using this keyword inst.

291
00:15:51,000 --> 00:15:56,000
As you all know, in llama two models we specifically use, I will go ahead and write human okay.

292
00:15:57,000 --> 00:16:07,000
And human is basically giving this particular query okay, I'll say write a 200 words blog on the topic

293
00:16:08,000 --> 00:16:15,000
on the topic, and the topic will specifically be my blog topic over here, which I will be giving from

294
00:16:15,000 --> 00:16:18,000
my input right whenever I hit that particular API.

295
00:16:18,000 --> 00:16:18,000
Okay.

296
00:16:19,000 --> 00:16:27,000
And uh, after this, uh, what I can actually do is that as soon as I give this particular instruction

297
00:16:27,000 --> 00:16:33,000
to, uh, as a human being over here, uh, the next thing is that I will have my assistant write,

298
00:16:33,000 --> 00:16:35,000
and now I will go ahead and write about assistant.

299
00:16:35,000 --> 00:16:38,000
And this will basically be closing the eye.

300
00:16:38,000 --> 00:16:42,000
And this is the keyword that we specifically use for most of the llama models.

301
00:16:42,000 --> 00:16:42,000
Right.

302
00:16:42,000 --> 00:16:43,000
So very simple.

303
00:16:43,000 --> 00:16:50,000
Write a 200 word, uh word blocks, uh, 200 word blogs on the topic blog topic.

304
00:16:50,000 --> 00:16:51,000
And this will basically be my assistant.

305
00:16:51,000 --> 00:16:54,000
Now as I said, I have to worry about the body.

306
00:16:54,000 --> 00:16:56,000
Now my body has what?

307
00:16:56,000 --> 00:16:57,000
All things right.

308
00:16:57,000 --> 00:17:00,000
You really need to go ahead and check it out from here.

309
00:17:00,000 --> 00:17:02,000
My body has a prompt message.

310
00:17:02,000 --> 00:17:05,000
It has a max gen message, max gen length message.

311
00:17:05,000 --> 00:17:08,000
It has a temperature message and it has a top underscore B.

312
00:17:08,000 --> 00:17:11,000
So these are all parameters I really need to set it up so quickly.

313
00:17:11,000 --> 00:17:13,000
I will go ahead and write it over here.

314
00:17:13,000 --> 00:17:15,000
So first parameter will be nothing but prompt.

315
00:17:15,000 --> 00:17:19,000
And this will basically be my prompt underscore text.

316
00:17:19,000 --> 00:17:19,000
Okay.

317
00:17:19,000 --> 00:17:20,000
So sorry.

318
00:17:20,000 --> 00:17:23,000
Uh, I've not created my prompt yet.

319
00:17:23,000 --> 00:17:23,000
Okay.

320
00:17:23,000 --> 00:17:25,000
This will basically be my prompt.

321
00:17:25,000 --> 00:17:26,000
Okay.

322
00:17:26,000 --> 00:17:31,000
Now after I probably define my prompt, the next parameter that I have already written is nothing but

323
00:17:31,000 --> 00:17:33,000
max underscore gen underscore length.

324
00:17:33,000 --> 00:17:34,000
Okay.

325
00:17:34,000 --> 00:17:38,000
And this will basically get assigned to five to L okay.

326
00:17:38,000 --> 00:17:44,000
And then you can probably see this will basically be my temperature variable, which will be my third

327
00:17:44,000 --> 00:17:47,000
parameter in my body that I will be sending.

328
00:17:47,000 --> 00:17:54,000
And another one will be top underscore p, which is another another parameter that is specifically required

329
00:17:54,000 --> 00:17:55,000
in my body.

330
00:17:55,000 --> 00:17:57,000
So this basically becomes my body.

331
00:17:57,000 --> 00:18:03,000
Now also what I am actually going to do is that, uh, with the help of Boto3, I'm going to call this

332
00:18:03,000 --> 00:18:04,000
foundation model.

333
00:18:04,000 --> 00:18:08,000
So that is my, uh, meta llama two uh, 13 billion chat model.

334
00:18:08,000 --> 00:18:11,000
And then for the things I will try to go ahead and do it.

335
00:18:11,000 --> 00:18:11,000
Okay.

336
00:18:11,000 --> 00:18:16,000
Now before I call that particular model, let me just go ahead and create a try catch block so that

337
00:18:17,000 --> 00:18:22,000
it is always good that we really need to have a try catch block so that whatever errors we specifically

338
00:18:22,000 --> 00:18:22,000
get.

339
00:18:22,000 --> 00:18:28,000
So I will go ahead and write bedrock and let me go ahead and write Boto three dot client.

340
00:18:29,000 --> 00:18:34,000
And here I'm going to basically call bedrock underscore runtime.

341
00:18:34,000 --> 00:18:39,000
And if you have already seen my bedrock videos I've already shown you how you can invoke the bedrock.

342
00:18:39,000 --> 00:18:45,000
Uh, we have to specifically create the runtime, the region, uh, of all the foundation models that

343
00:18:45,000 --> 00:18:50,000
I'm actually going to call will be nothing but US East one.

344
00:18:50,000 --> 00:18:54,000
Okay, so this is the region that we are specifically going to use.

345
00:18:54,000 --> 00:18:57,000
And the next thing that I am actually going to give is my config.

346
00:18:57,000 --> 00:19:01,000
So inside my config uh oh.

347
00:19:01,000 --> 00:19:03,000
Let me write it like this.

348
00:19:03,000 --> 00:19:05,000
So this will basically be my config.

349
00:19:06,000 --> 00:19:14,000
Uh inside my config I'm going to use my boto3 or sorry boto code dot config dot config.

350
00:19:14,000 --> 00:19:17,000
And here I have to set up some of the parameters.

351
00:19:17,000 --> 00:19:19,000
Right read timeout Okay.

352
00:19:19,000 --> 00:19:20,000
Read timeout.

353
00:19:20,000 --> 00:19:23,000
And here I'm going to probably take up 300 seconds.

354
00:19:23,000 --> 00:19:28,000
And I'm also going to give one more parameter which is nothing but retries okay.

355
00:19:28,000 --> 00:19:31,000
And this will basically be retries.

356
00:19:31,000 --> 00:19:36,000
And this will be set to a variable which is called as max attempt.

357
00:19:36,000 --> 00:19:40,000
Uh max underscore attempts will be nothing, but it will be three.

358
00:19:40,000 --> 00:19:41,000
Okay.

359
00:19:41,000 --> 00:19:43,000
So here I'm going to keep up all the values.

360
00:19:43,000 --> 00:19:50,000
So these are the basic configuration that I am specifically giving uh with respect to my number of tries.

361
00:19:50,000 --> 00:19:55,000
Uh, all the so in short, this variable will be used to call my foundation model.

362
00:19:55,000 --> 00:19:55,000
Okay.

363
00:19:55,000 --> 00:20:01,000
Now in order to call the foundation model I will write bedrock dot invoke underscore model.

364
00:20:01,000 --> 00:20:03,000
And here I'm going to give my body.

365
00:20:04,000 --> 00:20:09,000
The body is nothing but I'm just going to write JSON dot dumps okay.

366
00:20:10,000 --> 00:20:11,000
JSON dot dumps.

367
00:20:11,000 --> 00:20:12,000
And again I have not imported JSON.

368
00:20:12,000 --> 00:20:14,000
So let me just go ahead and do that.

369
00:20:14,000 --> 00:20:17,000
So I'm going to write import JSON okay.

370
00:20:17,000 --> 00:20:19,000
So once I probably write import JSON.

371
00:20:19,000 --> 00:20:22,000
So here a JSON dot dumps.

372
00:20:22,000 --> 00:20:26,000
And here I'm going to probably give my entire body.

373
00:20:26,000 --> 00:20:32,000
Or along with this I also need to call which model I'm basically calling.

374
00:20:32,000 --> 00:20:38,000
So for that I have to mention my model ID and this time the model ID is nothing but it.

375
00:20:38,000 --> 00:20:39,000
You have to refer it from here.

376
00:20:39,000 --> 00:20:43,000
So this is nothing but meta 70 billion.

377
00:20:43,000 --> 00:20:49,000
Now let's go with 30 billion because the request again I have to pay based on the number of requests.

378
00:20:49,000 --> 00:20:50,000
That is probably going right.

379
00:20:50,000 --> 00:20:57,000
So model ID here I'm going to just paste it and I'm going calling the 13 billion chat v1 model okay.

380
00:20:57,000 --> 00:21:04,000
So once you do this then what we can do we will get our response underscore content.

381
00:21:04,000 --> 00:21:08,000
And let me just go ahead and write response dot get body.

382
00:21:09,000 --> 00:21:15,000
So for that response underscore content uh response dot get.

383
00:21:15,000 --> 00:21:22,000
And here we are going to basically write body dot read okay.

384
00:21:23,000 --> 00:21:24,000
Dot read.

385
00:21:24,000 --> 00:21:27,000
So we are specifically going to read this specific response.

386
00:21:27,000 --> 00:21:31,000
Uh, and one more thing uh that you can do write and understand.

387
00:21:31,000 --> 00:21:32,000
One more thing guys.

388
00:21:32,000 --> 00:21:33,000
Very simple.

389
00:21:33,000 --> 00:21:38,000
Whatever response you are probably getting, I will just go ahead and import the response also because

390
00:21:38,000 --> 00:21:40,000
I will be using this.

391
00:21:42,000 --> 00:21:43,000
Okay.

392
00:21:44,000 --> 00:21:47,000
So uh response dot get body dot read.

393
00:21:47,000 --> 00:21:54,000
Once I read that particular data, what it will happen is that I will just go ahead and load this with

394
00:21:54,000 --> 00:21:55,000
respect to my response.

395
00:21:55,000 --> 00:21:56,000
Underscore content.

396
00:21:56,000 --> 00:21:57,000
Okay.

397
00:21:57,000 --> 00:22:04,000
Now here you should understand, right, that when I invoke this particular module and when I give my

398
00:22:04,000 --> 00:22:08,000
body over here, I'm basically calling this particular model over here itself.

399
00:22:08,000 --> 00:22:12,000
That is my llama 213 B uh, 13 million Chad B one.

400
00:22:12,000 --> 00:22:16,000
And then with respect to this particular body, whatever body you are specifically getting will read

401
00:22:16,000 --> 00:22:17,000
that particular response.

402
00:22:17,000 --> 00:22:19,000
And let me do one thing.

403
00:22:19,000 --> 00:22:21,000
Let me just make this particular spelling correctly.

404
00:22:21,000 --> 00:22:27,000
And as soon as I load this particular response content, let me go ahead and store it in my variable.

405
00:22:29,000 --> 00:22:32,000
Response Underscore data.

406
00:22:32,000 --> 00:22:33,000
Okay.

407
00:22:33,000 --> 00:22:37,000
Now, once I load this, uh, let me just go ahead and print it.

408
00:22:37,000 --> 00:22:39,000
If I really want to see my response.

409
00:22:39,000 --> 00:22:42,000
Underscore data response underscore data.

410
00:22:42,000 --> 00:22:42,000
Okay.

411
00:22:42,000 --> 00:22:49,000
If you want to probably see it, um, this response will be having a variable understand one thing that,

412
00:22:49,000 --> 00:22:55,000
uh, whatever response we are basically calling it is giving the response from our entire model, the

413
00:22:55,000 --> 00:22:57,000
model that we are using, the foundation model.

414
00:22:57,000 --> 00:22:59,000
And now here I will go ahead and write.

415
00:22:59,000 --> 00:23:03,000
This will basically be my blog details okay.

416
00:23:04,000 --> 00:23:14,000
Blog details and this blog details, uh, blog details will be available inside response underscore

417
00:23:14,000 --> 00:23:19,000
data with respect to my, uh, key variable, which is called as generation.

418
00:23:19,000 --> 00:23:24,000
So this model, whatever response it is basically giving you, it will be saved in this particular key

419
00:23:24,000 --> 00:23:28,000
variable within your response data which has been converted into JSON.

420
00:23:28,000 --> 00:23:31,000
And when you write response dot get body dot read.

421
00:23:31,000 --> 00:23:33,000
In short, you're basically getting the response from this.

422
00:23:33,000 --> 00:23:34,000
Okay.

423
00:23:34,000 --> 00:23:38,000
And finally I'm going to return the blog underscore details.

424
00:23:38,000 --> 00:23:40,000
So this function here you can see.

425
00:23:40,000 --> 00:23:43,000
And let me just go ahead and write my accept block also.

426
00:23:43,000 --> 00:23:46,000
Also accept okay.

427
00:23:47,000 --> 00:23:55,000
Accept exception I'm just going to create my exception exception as E.

428
00:23:56,000 --> 00:24:01,000
And we are just going to print the errors and understand one thing guys whatever printing that we are

429
00:24:01,000 --> 00:24:08,000
specifically doing AWS lambdas make sure that all the logs will be logged in the CloudWatch logs, right?

430
00:24:08,000 --> 00:24:12,000
So that is also very good advantages for you so that you'll be able to see that.

431
00:24:12,000 --> 00:24:17,000
So error generating the code uh okay.

432
00:24:18,000 --> 00:24:20,000
Error generating the blog.

433
00:24:20,000 --> 00:24:24,000
And I can probably display this particular error, which is basically over here.

434
00:24:24,000 --> 00:24:28,000
And uh let me return it with a blank screen.

435
00:24:28,000 --> 00:24:29,000
Okay.

436
00:24:29,000 --> 00:24:33,000
So here we have basically done almost each and everything we have displayed the data.

437
00:24:33,000 --> 00:24:35,000
This is the blog details that we are specifically getting.

438
00:24:35,000 --> 00:24:39,000
And this is the function that is responsible in generating the blog.

439
00:24:39,000 --> 00:24:39,000
Okay.

440
00:24:40,000 --> 00:24:43,000
Now let me quickly go ahead and do one more thing.

441
00:24:43,000 --> 00:24:50,000
Let me go ahead and uh, see, by default, if I go inside my lambda function, uh, it has a function

442
00:24:50,000 --> 00:24:52,000
which is called as lambda handler.

443
00:24:52,000 --> 00:24:53,000
Okay.

444
00:24:53,000 --> 00:24:55,000
So let me just go ahead and define this lambda handler.

445
00:24:55,000 --> 00:25:02,000
Because my API gateway, whenever it's say sends any Post event, uh, it will be captured from this

446
00:25:02,000 --> 00:25:05,000
particular trigger and it will hit this particular function first.

447
00:25:05,000 --> 00:25:09,000
So we have to capture this event along with the context.

448
00:25:09,000 --> 00:25:16,000
And then we can probably, uh, retrieve whatever query we are specifically giving.

449
00:25:16,000 --> 00:25:18,000
See here we are giving the blog topic right.

450
00:25:18,000 --> 00:25:22,000
That blog top topic will be captured in this specific event.

451
00:25:22,000 --> 00:25:24,000
Okay, that is what is my plan.

452
00:25:24,000 --> 00:25:28,000
Okay, so here what I'm actually going to do, I'll just go ahead and create my event.

453
00:25:28,000 --> 00:25:35,000
So event Jason Dot loads and I will take this event and let me do one thing.

454
00:25:35,000 --> 00:25:40,000
Let me create a variable right which is basically called as body because whatever Post request we are

455
00:25:40,000 --> 00:25:44,000
sending this will be available in the body key itself.

456
00:25:44,000 --> 00:25:44,000
Okay?

457
00:25:44,000 --> 00:25:46,000
You'll be able to understand it.

458
00:25:46,000 --> 00:25:49,000
And then this will basically be my blog topic.

459
00:25:49,000 --> 00:25:51,000
So I will let me go ahead and write my blog topic.

460
00:25:51,000 --> 00:25:56,000
My blog topic will be nothing, but I will just go ahead and write event of.

461
00:25:57,000 --> 00:26:02,000
I can keep a variable called as message, or I can also keep a key called as blog.

462
00:26:02,000 --> 00:26:04,000
So you'll be able to understand.

463
00:26:04,000 --> 00:26:11,000
Inside this body I will be giving in a JSON format where my blog topic will be in this particular variable

464
00:26:11,000 --> 00:26:11,000
name.

465
00:26:11,000 --> 00:26:13,000
Okay, so blog underscore topic.

466
00:26:13,000 --> 00:26:17,000
Let's say here I go ahead and write blog underscore topic is equal to machine learning.

467
00:26:17,000 --> 00:26:18,000
Then I should be able to get this.

468
00:26:18,000 --> 00:26:19,000
Okay.

469
00:26:19,000 --> 00:26:26,000
Um, then uh, once I probably get the blog topic, then I will go ahead and write generate underscore

470
00:26:26,000 --> 00:26:26,000
blog.

471
00:26:26,000 --> 00:26:33,000
And now I will go ahead and call my, uh, generate blog using bedrock.

472
00:26:33,000 --> 00:26:35,000
Okay, so this will basically be my function.

473
00:26:35,000 --> 00:26:41,000
And here I'm going to probably give my blog topic name, which will be nothing, but it will be your

474
00:26:41,000 --> 00:26:43,000
blog topic that I've actually created.

475
00:26:43,000 --> 00:26:48,000
So in short, uh, this function, when I'm calling it, it will be responsible in giving me the entire

476
00:26:48,000 --> 00:26:52,000
blog by calling this particular, uh, model that is llama two.

477
00:26:52,000 --> 00:26:59,000
Okay, so once I probably get this generate blog, block, now I'm going to go ahead and write if if

478
00:27:00,000 --> 00:27:02,000
generate underscore block.

479
00:27:02,000 --> 00:27:03,000
Okay.

480
00:27:03,000 --> 00:27:08,000
Now as you know that I'm going to save this particular block in my S3 bucket okay.

481
00:27:09,000 --> 00:27:10,000
Uh S3 bucket.

482
00:27:10,000 --> 00:27:13,000
The reason why I'm saving it, I'll try to save it in a.

483
00:27:13,000 --> 00:27:16,000
TXT file so that I will be able to access it whenever I really want.

484
00:27:16,000 --> 00:27:19,000
So let me do one thing.

485
00:27:19,000 --> 00:27:23,000
Let me go ahead and import from date time.

486
00:27:23,000 --> 00:27:26,000
I'm going to import date time.

487
00:27:26,000 --> 00:27:27,000
Okay.

488
00:27:27,000 --> 00:27:34,000
So the reason why I'm importing this date time because I really want to create all the txt file in a

489
00:27:34,000 --> 00:27:36,000
way where I consider the current time.

490
00:27:36,000 --> 00:27:36,000
Okay.

491
00:27:36,000 --> 00:27:48,000
So current underscore time is equal to date time dot now and here I'm going to use dot strf time in

492
00:27:48,000 --> 00:27:55,000
the form of hours months and sorry hours minutes and seconds.

493
00:27:55,000 --> 00:27:55,000
Okay.

494
00:27:56,000 --> 00:28:03,000
And then I will go ahead and create my x three key key name okay S3 bucket key name.

495
00:28:03,000 --> 00:28:08,000
So S3 underscore key how my file needs to be saved okay.

496
00:28:08,000 --> 00:28:11,000
So I'm going to create an f string.

497
00:28:11,000 --> 00:28:16,000
And let me just go ahead and go ahead and create something like this blog output folder.

498
00:28:16,000 --> 00:28:19,000
So this will basically be my blog output folder.

499
00:28:19,000 --> 00:28:24,000
And inside this I will go ahead and write current underscore time dot txt file.

500
00:28:24,000 --> 00:28:25,000
Okay.

501
00:28:25,000 --> 00:28:28,000
So this will basically be my txt file which will be saved in that particular S3 bucket.

502
00:28:28,000 --> 00:28:31,000
Now let me give my S3 bucket name.

503
00:28:31,000 --> 00:28:34,000
So S3 underscore bucket name.

504
00:28:34,000 --> 00:28:43,000
And let me go ahead and write AWS bedrock Bedrock course one okay.

505
00:28:43,000 --> 00:28:46,000
So let me create this particular bedrock name okay.

506
00:28:46,000 --> 00:28:48,000
And now I've given all the information.

507
00:28:48,000 --> 00:28:51,000
Now I can call a function okay.

508
00:28:51,000 --> 00:28:54,000
And let's say uh first of all let me just close this if clause.

509
00:28:54,000 --> 00:28:56,000
So here I'll say print.

510
00:28:57,000 --> 00:28:59,000
No block was generated.

511
00:28:59,000 --> 00:29:00,000
Right.

512
00:29:00,000 --> 00:29:02,000
No block was generated.

513
00:29:02,000 --> 00:29:02,000
Perfect.

514
00:29:03,000 --> 00:29:09,000
Now the next step, what I'm actually going to do, uh, over here, is that once I get my key and bucket,

515
00:29:09,000 --> 00:29:11,000
I should be able to call another function.

516
00:29:11,000 --> 00:29:15,000
I'll create another function and let me go ahead and write this particular function.

517
00:29:15,000 --> 00:29:21,000
And him go here I'm going to write slave uh, save block details okay.

518
00:29:21,000 --> 00:29:22,000
In S3 okay.

519
00:29:22,000 --> 00:29:24,000
So this will basically be my function.

520
00:29:24,000 --> 00:29:28,000
And uh, with respect to three I require two information.

521
00:29:28,000 --> 00:29:31,000
One is my S3 key S3 key.

522
00:29:31,000 --> 00:29:34,000
And the second information is my S3 bucket.

523
00:29:34,000 --> 00:29:34,000
Okay.

524
00:29:34,000 --> 00:29:37,000
So in short, I'm taking up all this particular information.

525
00:29:37,000 --> 00:29:42,000
And uh, here you can actually see that I'm, I'm saving it in the S3 bucket.

526
00:29:42,000 --> 00:29:46,000
Now the further code I can probably write it over here again over here.

527
00:29:46,000 --> 00:29:51,000
What I will do, I will go ahead and write Boto three dot client.

528
00:29:51,000 --> 00:29:52,000
Okay.

529
00:29:52,000 --> 00:29:54,000
So this will basically be my boto3.

530
00:29:54,000 --> 00:29:55,000
Let me see.

531
00:29:55,000 --> 00:29:56,000
I've imported boto three or not.

532
00:29:56,000 --> 00:29:59,000
So this client will be nothing but my S3 bucket.

533
00:29:59,000 --> 00:29:59,000
Okay.

534
00:29:59,000 --> 00:30:03,000
And again here I will go ahead and create my try catch block.

535
00:30:03,000 --> 00:30:09,000
And I will say that hey go ahead and create S3 three dot put, uh, object is nothing.

536
00:30:09,000 --> 00:30:15,000
But with respect to my S3 bucket, uh, S3 key, uh, body, uh, body.

537
00:30:15,000 --> 00:30:19,000
Also, I need to save it and the body will be nothing.

538
00:30:19,000 --> 00:30:21,000
But, uh, let me just see over here.

539
00:30:21,000 --> 00:30:22,000
Okay.

540
00:30:22,000 --> 00:30:25,000
Uh, body will be nothing, but, uh, whatever is one generate block that I'm actually getting.

541
00:30:25,000 --> 00:30:31,000
Okay, so here I will go ahead and give my generate block which will be assigned to this.

542
00:30:31,000 --> 00:30:32,000
Okay.

543
00:30:32,000 --> 00:30:37,000
So in short, I am putting I'm taking my entire information block that is generated in this particular

544
00:30:37,000 --> 00:30:39,000
bucket with this particular file name.

545
00:30:39,000 --> 00:30:42,000
So here I'm going to probably call my this function.

546
00:30:42,000 --> 00:30:45,000
That is nothing but save block details.

547
00:30:45,000 --> 00:30:50,000
And with respect to this particular save block details, as I said I require S3 underscore key.

548
00:30:50,000 --> 00:30:55,000
The second parameter that I require S3 underscore bucket okay.

549
00:30:55,000 --> 00:31:01,000
And the third parameter I require is nothing but my generated blog, which will be in the specific name.

550
00:31:01,000 --> 00:31:01,000
Okay.

551
00:31:01,000 --> 00:31:02,000
So done.

552
00:31:02,000 --> 00:31:03,000
This is good enough.

553
00:31:03,000 --> 00:31:05,000
Everything is probably given over here.

554
00:31:06,000 --> 00:31:11,000
But again understand with respect to Lambda handler, uh, I should be returning something because once

555
00:31:11,000 --> 00:31:18,000
the execution is done just for my verification, I will be returning something like a status code if

556
00:31:18,000 --> 00:31:19,000
there is no error.

557
00:31:19,000 --> 00:31:29,000
So I will set up a status code which will be nothing, but it will be equal to 200 and body will be

558
00:31:29,000 --> 00:31:33,000
equal to JSON dot dumps.

559
00:31:36,000 --> 00:31:41,000
And I'll say blog generation is completed.

560
00:31:41,000 --> 00:31:41,000
Okay.

561
00:31:41,000 --> 00:31:44,000
Just to get me a message okay.

562
00:31:44,000 --> 00:31:44,000
Okay.

563
00:31:44,000 --> 00:31:44,000
So done.

564
00:31:44,000 --> 00:31:46,000
This is good enough.

565
00:31:46,000 --> 00:31:49,000
Uh, I've got each and every thing over here.

566
00:31:49,000 --> 00:31:52,000
Uh, it looks absolutely fine with respect to the functionalities.

567
00:31:52,000 --> 00:31:53,000
Whatever is required.

568
00:31:53,000 --> 00:31:59,000
I have actually given it over here, and this looks absolutely fine with respect to whatever information

569
00:31:59,000 --> 00:32:00,000
I see over here.

570
00:32:00,000 --> 00:32:00,000
Right.

571
00:32:00,000 --> 00:32:04,000
And uh, again, uh, understand, uh, okay.

572
00:32:04,000 --> 00:32:07,000
This response variable, I will save it over here.

573
00:32:07,000 --> 00:32:07,000
Okay.

574
00:32:07,000 --> 00:32:11,000
So so since I'm hitting this particular bedrock and this response, I can remove it.

575
00:32:11,000 --> 00:32:12,000
Okay.

576
00:32:12,000 --> 00:32:13,000
So that is those variables.

577
00:32:13,000 --> 00:32:16,000
So let me quickly copy this and let me do one thing.

578
00:32:16,000 --> 00:32:19,000
Let me paste it completely over here.

579
00:32:19,000 --> 00:32:20,000
Right.

580
00:32:20,000 --> 00:32:22,000
So here I'm just going to paste it.

581
00:32:22,000 --> 00:32:28,000
And this will basically be my entire lambda function with respect to all the details and whatever things

582
00:32:28,000 --> 00:32:29,000
I specifically require.

583
00:32:29,000 --> 00:32:32,000
Again, to write it over here, it would have been difficult.

584
00:32:32,000 --> 00:32:35,000
But now there you could see that how easy it is right now.

585
00:32:35,000 --> 00:32:38,000
We'll go ahead and click on deploy okay.

586
00:32:38,000 --> 00:32:42,000
So once this is probably deployed I can go ahead and create my API gateway and all.

587
00:32:42,000 --> 00:32:42,000
Okay.

588
00:32:42,000 --> 00:32:44,000
One more important thing.

589
00:32:44,000 --> 00:32:49,000
Understand that, uh, this Lambda function requires a recent version of Boto3.

590
00:32:49,000 --> 00:32:55,000
And if you probably go ahead and see what default Boto3 version is basically present in this lambda

591
00:32:55,000 --> 00:32:56,000
is the older one.

592
00:32:56,000 --> 00:33:03,000
Now, in order to do, create or have a new Boto3 library installed, what you really need to do.

593
00:33:03,000 --> 00:33:07,000
Okay, so here you can see I'll be showing you one very important thing.

594
00:33:07,000 --> 00:33:09,000
I have actually created a zip file.

595
00:33:09,000 --> 00:33:10,000
Okay.

596
00:33:10,000 --> 00:33:13,000
So you have to probably follow this step okay.

597
00:33:13,000 --> 00:33:18,000
And this will basically be helpful for you okay.

598
00:33:18,000 --> 00:33:19,000
Let me do one thing.

599
00:33:19,000 --> 00:33:21,000
Let me just remove this.

600
00:33:23,000 --> 00:33:29,000
Okay, so here you can probably see, uh, I have created a folder which is called as boto three underscore

601
00:33:29,000 --> 00:33:30,000
layer.

602
00:33:30,000 --> 00:33:30,000
Okay.

603
00:33:30,000 --> 00:33:32,000
Now understand one thing.

604
00:33:32,000 --> 00:33:36,000
What I am actually doing over here, this is important for you all to understand.

605
00:33:36,000 --> 00:33:37,000
Okay.

606
00:33:37,000 --> 00:33:39,000
Unless and until you don't understand this.

607
00:33:40,000 --> 00:33:48,000
So I will go ahead and activate my V and V environment or okay V and V environment is not there.

608
00:33:48,000 --> 00:33:48,000
Okay.

609
00:33:48,000 --> 00:33:50,000
What I'm actually going to do.

610
00:33:50,000 --> 00:33:51,000
See over here okay.

611
00:33:51,000 --> 00:33:57,000
Conda conda deactivate okay.

612
00:33:58,000 --> 00:33:59,000
Now understand one thing.

613
00:33:59,000 --> 00:34:06,000
As I said, my lambda function requires a new version of the boto three installed.

614
00:34:06,000 --> 00:34:13,000
See, whenever we open a Lambda function by default, the older version of Boto three is there now in

615
00:34:13,000 --> 00:34:18,000
the older version of boto three, because at that point of time, uh, you did not had a Amazon bedrock.

616
00:34:18,000 --> 00:34:20,000
All the foundation models, right?

617
00:34:20,000 --> 00:34:26,000
So what we need to do is that we need to update the packages with respect to the Boto three.

618
00:34:26,000 --> 00:34:27,000
Now how do you do that?

619
00:34:27,000 --> 00:34:27,000
Okay.

620
00:34:27,000 --> 00:34:28,000
How do you do that.

621
00:34:28,000 --> 00:34:32,000
And this I would definitely explain you in a better way.

622
00:34:32,000 --> 00:34:36,000
See, what I have done is that I've created a folder which is called as Python.

623
00:34:36,000 --> 00:34:37,000
Okay.

624
00:34:37,000 --> 00:34:42,000
Now inside this Python, what I have actually done, see it is very much important.

625
00:34:42,000 --> 00:34:48,000
Now inside this python I have installed, I have installed a library which is called as Boto3.

626
00:34:48,000 --> 00:34:54,000
So if you probably go ahead and see this right here, you'll be able to see Boto3 boto core.

627
00:34:54,000 --> 00:34:58,000
All the information is specifically there right now.

628
00:34:58,000 --> 00:35:00,000
This will be a task for you.

629
00:35:00,000 --> 00:35:04,000
Just tell me, how can you install a library inside a folder?

630
00:35:04,000 --> 00:35:10,000
Okay, just to give you pip install boto three minus t.

631
00:35:10,000 --> 00:35:10,000
Right.

632
00:35:10,000 --> 00:35:16,000
And if you go ahead and write this right, what it is basically going to do is that the entire Boto

633
00:35:16,000 --> 00:35:19,000
three library will get installed inside this particular folder.

634
00:35:19,000 --> 00:35:25,000
And once this folder is created, what I can do, I can make sure that I will go to this particular

635
00:35:25,000 --> 00:35:29,000
folder and I will make a zip file.

636
00:35:29,000 --> 00:35:33,000
You can compress this particular file and you make a zip file and you can name anything here I have

637
00:35:33,000 --> 00:35:36,000
given boto3 underscore layer dot zip okay.

638
00:35:37,000 --> 00:35:42,000
If you want to install any packages in Lambda, first of all you really need to create a Python folder.

639
00:35:42,000 --> 00:35:44,000
Install all the packages that you want.

640
00:35:44,000 --> 00:35:50,000
Let's say by default over here, if I go ahead and write import pandas, pandas may not be installed

641
00:35:50,000 --> 00:35:50,000
in lambda.

642
00:35:50,000 --> 00:35:56,000
So if you really want to install pandas, what you really need to do inside this Python folder, you

643
00:35:56,000 --> 00:36:01,000
will go ahead and write pip install pandas minus t python folder slash automatically.

644
00:36:01,000 --> 00:36:04,000
The installation will take place and then you convert it into a zip file.

645
00:36:05,000 --> 00:36:09,000
The zip file name can be anything, but inside the zip file there should be a python folder with all

646
00:36:09,000 --> 00:36:09,000
the packages.

647
00:36:10,000 --> 00:36:12,000
Okay, so I'm going to specifically use this okay.

648
00:36:12,000 --> 00:36:17,000
So I've created over here boto three dot layer dot --.

649
00:36:17,000 --> 00:36:21,000
Now I'm going to go down and let me do one thing.

650
00:36:21,000 --> 00:36:24,000
Uh over here you'll be able to see layers okay.

651
00:36:24,000 --> 00:36:27,000
So I'm going to click on layer add a layer.

652
00:36:27,000 --> 00:36:32,000
Now inside this particular layer this basically says that if you really want to add any kind of packages

653
00:36:32,000 --> 00:36:34,000
you can add it in the form of layer.

654
00:36:34,000 --> 00:36:34,000
Okay.

655
00:36:34,000 --> 00:36:39,000
So here you can see this layer, choose Layer Custom Layers and all specify a layer.

656
00:36:39,000 --> 00:36:43,000
So what I'm actually going to do I'll just go ahead and select my custom layer.

657
00:36:43,000 --> 00:36:49,000
See over here you can also create your own layers also right.

658
00:36:49,000 --> 00:36:51,000
You can create your own layer information.

659
00:36:51,000 --> 00:36:57,000
So one of the layer you can probably see over here it is written as uh boto three underscore bedrock.

660
00:36:57,000 --> 00:36:59,000
And this is the layer that I have already created okay.

661
00:37:00,000 --> 00:37:04,000
Now in order to create the layers I can go ahead and click on this particular layer.

662
00:37:04,000 --> 00:37:08,000
I'll go back I will click on Create Layer see what I have done.

663
00:37:08,000 --> 00:37:10,000
So okay this is my lambda function.

664
00:37:11,000 --> 00:37:13,000
Understand this thing okay.

665
00:37:13,000 --> 00:37:16,000
Uh, if I probably show you my functions this is my function.

666
00:37:16,000 --> 00:37:17,000
Okay.

667
00:37:17,000 --> 00:37:19,000
Now I've already written the code.

668
00:37:19,000 --> 00:37:21,000
I've deployed that particular code.

669
00:37:21,000 --> 00:37:27,000
Now, what I need to do is that I need to create a layer right, so that I update all the packages.

670
00:37:27,000 --> 00:37:27,000
Okay.

671
00:37:27,000 --> 00:37:30,000
So in order to create the layer I will just go ahead and click on add a layer.

672
00:37:31,000 --> 00:37:36,000
And over here what you do just go back to this particular layers and click on create a Layer.

673
00:37:36,000 --> 00:37:42,000
And here I will go ahead and write Boto three updated layer okay.

674
00:37:42,000 --> 00:37:45,000
And description I don't want I'll upload a zip file.

675
00:37:46,000 --> 00:37:48,000
I hope everybody knows where the zip file is.

676
00:37:48,000 --> 00:37:50,000
So this is my zip file.

677
00:37:50,000 --> 00:37:52,000
So I will go ahead and click on upload okay.

678
00:37:53,000 --> 00:38:00,000
And I will take this path over here and I'll paste it okay I will go ahead and write boto three underscore

679
00:38:00,000 --> 00:38:02,000
layer dot zip okay.

680
00:38:02,000 --> 00:38:08,000
And then uh there is also like which all version you really want to be compatible with.

681
00:38:08,000 --> 00:38:13,000
So I will go ahead and write Python 3.12, Python 3.1, Python 3.10.

682
00:38:13,000 --> 00:38:14,000
Okay, so this is all layers.

683
00:38:14,000 --> 00:38:16,000
I really want to put that okay.

684
00:38:16,000 --> 00:38:17,000
It is compatible with.

685
00:38:17,000 --> 00:38:21,000
And now let's go ahead and click on create the layer okay.

686
00:38:21,000 --> 00:38:26,000
So once this particular layer is basically added uh created then we can add this particular layer to

687
00:38:26,000 --> 00:38:28,000
my lambda function.

688
00:38:28,000 --> 00:38:32,000
And this is just to make sure that all your packages are up to date.

689
00:38:32,000 --> 00:38:35,000
That is the main, main reason why we are specifically doing it.

690
00:38:35,000 --> 00:38:39,000
So it is going to take some amount of time again based on your internet speed.

691
00:38:39,000 --> 00:38:43,000
And based on that we will try to see that what all things we can actually do.

692
00:38:43,000 --> 00:38:48,000
Okay, so let this thing get created and let me have a look with respect to this once it is getting

693
00:38:48,000 --> 00:38:49,000
created okay.

694
00:38:49,000 --> 00:38:50,000
Now this looks that it is created.

695
00:38:50,000 --> 00:38:53,000
Now I'll go to my lambda function okay.

696
00:38:53,000 --> 00:38:55,000
Uh, create a function.

697
00:38:55,000 --> 00:38:56,000
Let me go back to my function.

698
00:38:56,000 --> 00:38:58,000
This is my AWS bedrock.

699
00:38:58,000 --> 00:39:02,000
And let me go ahead and now add a layer which I have already created it okay.

700
00:39:02,000 --> 00:39:04,000
So now it should be my custom layer.

701
00:39:04,000 --> 00:39:09,000
I will go ahead and select this boto three updated layer version.

702
00:39:09,000 --> 00:39:12,000
I can probably give it as one and click on add.

703
00:39:12,000 --> 00:39:20,000
Okay, so as I as soon as I probably give as add, you will be able to see that over here my layer will

704
00:39:20,000 --> 00:39:21,000
get automatically added.

705
00:39:21,000 --> 00:39:23,000
So one layer has got added.

706
00:39:23,000 --> 00:39:24,000
So my code is ready.

707
00:39:24,000 --> 00:39:25,000
My layer is ready.

708
00:39:25,000 --> 00:39:31,000
Now all I have to do is that I have to probably go ahead and create my API gateway so that it will get

709
00:39:31,000 --> 00:39:37,000
triggered or integrated with AWS or with my Lambda function, and I will be able to trigger things.

710
00:39:37,000 --> 00:39:41,000
Okay, so now I will go ahead and call my API gateway.

711
00:39:41,000 --> 00:39:42,000
So API gateway is over here.

712
00:39:42,000 --> 00:39:44,000
This is how my API gateway looks like.

713
00:39:44,000 --> 00:39:46,000
Now let me do one thing.

714
00:39:46,000 --> 00:39:51,000
Let me quickly go ahead and integrate this API gateway with my Lambda function.

715
00:39:51,000 --> 00:39:54,000
Okay, so now my API gateway is opened over here.

716
00:39:54,000 --> 00:39:56,000
Now quickly let's see this.

717
00:39:56,000 --> 00:40:01,000
Uh, as soon as I probably get this particular API gateway, I will go ahead and integrate it.

718
00:40:01,000 --> 00:40:05,000
And then whenever I trigger this particular API, it should be hitting my lambda function, which is

719
00:40:05,000 --> 00:40:07,000
in turn interacting it.

720
00:40:07,000 --> 00:40:08,000
So I will go ahead and create my API.

721
00:40:09,000 --> 00:40:12,000
And here you can see I will be using an http API.

722
00:40:13,000 --> 00:40:19,000
Um, over here you will be able to see can should we add an integration, my API name and all are there.

723
00:40:19,000 --> 00:40:21,000
Uh, let me just give my API name.

724
00:40:21,000 --> 00:40:28,000
So here bedrock demo API I'm just going to write it down review and create.

725
00:40:28,000 --> 00:40:31,000
Okay I will just go ahead and create it okay.

726
00:40:31,000 --> 00:40:35,000
Now once I create it after that I will start adding routes.

727
00:40:35,000 --> 00:40:38,000
So here you can probably see I'm getting routes over here.

728
00:40:38,000 --> 00:40:40,000
So let me just go ahead and create some of the routes.

729
00:40:40,000 --> 00:40:43,000
So here I will go ahead and write post request.

730
00:40:43,000 --> 00:40:45,000
And here I can go ahead and write.

731
00:40:45,000 --> 00:40:48,000
Blog generation will be my API.

732
00:40:48,000 --> 00:40:51,000
And let me just go ahead and create over here.

733
00:40:51,000 --> 00:40:54,000
Let me select this post here.

734
00:40:54,000 --> 00:40:58,000
There are two option one authorizes protect your API against unauthorised requests.

735
00:40:58,000 --> 00:41:03,000
So if I really want to keep some kind of key for authorisation purpose, I can do it.

736
00:41:03,000 --> 00:41:04,000
I can basically attach it over here.

737
00:41:04,000 --> 00:41:08,000
But right now I really want to show you that how the post request will basically get handled.

738
00:41:08,000 --> 00:41:11,000
So here I'm going to basically attach integration right now.

739
00:41:11,000 --> 00:41:14,000
So attach integration I will go ahead and click on.

740
00:41:14,000 --> 00:41:20,000
And uh with respect to this attach integration I am going to attach to my lambda function.

741
00:41:20,000 --> 00:41:24,000
Now inside my lambda function I will go ahead and choose my lambda function.

742
00:41:24,000 --> 00:41:27,000
So here you can see AWS app bedrock.

743
00:41:27,000 --> 00:41:29,000
This is the Lambda function that I have actually created.

744
00:41:29,000 --> 00:41:32,000
And I let me just go ahead and click on create.

745
00:41:33,000 --> 00:41:39,000
So once I probably create this here you'll be able to see that my lambda function is done.

746
00:41:39,000 --> 00:41:39,000
Okay.

747
00:41:40,000 --> 00:41:43,000
Now the most important thing okay.

748
00:41:43,000 --> 00:41:43,000
Okay.

749
00:41:45,000 --> 00:41:51,000
One thing is that here, this particular API, I can also deploy to multiple cloud platforms.

750
00:41:51,000 --> 00:41:58,000
And sorry, in uh, C whenever we do a bigger project there is dev environment, there is Q environment,

751
00:41:58,000 --> 00:42:01,000
there is UI environment, there is production environment.

752
00:42:01,000 --> 00:42:03,000
So similar kind of environments also you can create.

753
00:42:03,000 --> 00:42:06,000
So for that just go to the stages okay.

754
00:42:06,000 --> 00:42:11,000
And by default this is basically the default stage.

755
00:42:11,000 --> 00:42:14,000
But I will just go ahead and create my stage name.

756
00:42:14,000 --> 00:42:16,000
So I'll write dev environment.

757
00:42:16,000 --> 00:42:20,000
And uh I don't need to add the stage variable and all.

758
00:42:20,000 --> 00:42:22,000
So I'll just go ahead and create okay.

759
00:42:22,000 --> 00:42:27,000
Now inside this particular dev environment, uh, you'll be able to see that, um, here.

760
00:42:27,000 --> 00:42:28,000
Right.

761
00:42:28,000 --> 00:42:29,000
Uh, okay.

762
00:42:29,000 --> 00:42:29,000
Let's see this.

763
00:42:29,000 --> 00:42:31,000
So this will basically be my URL.

764
00:42:31,000 --> 00:42:36,000
And along with this URL if I really want to call my API.

765
00:42:36,000 --> 00:42:38,000
So this will basically be my URL.

766
00:42:38,000 --> 00:42:39,000
So I'll just go ahead and deploy it.

767
00:42:39,000 --> 00:42:41,000
So no stages found.

768
00:42:41,000 --> 00:42:42,000
Let's see okay dev is there.

769
00:42:42,000 --> 00:42:44,000
So I will just go ahead and deploy it okay.

770
00:42:44,000 --> 00:42:47,000
So I'm deploying this entire URL.

771
00:42:47,000 --> 00:42:51,000
And this is the API that I have to specifically use for interacting with my lambda function.

772
00:42:51,000 --> 00:42:52,000
Okay.

773
00:42:52,000 --> 00:42:56,000
This slash whatever will be my root name I can actually use it.

774
00:42:56,000 --> 00:42:59,000
So this if I go ahead and I'll copy this also.

775
00:42:59,000 --> 00:42:59,000
Okay.

776
00:42:59,000 --> 00:42:59,000
Just a second.

777
00:42:59,000 --> 00:43:01,000
I'll just copy this.

778
00:43:01,000 --> 00:43:03,000
Um, okay.

779
00:43:03,000 --> 00:43:04,000
It has gone to this okay.

780
00:43:04,000 --> 00:43:05,000
No worries.

781
00:43:05,000 --> 00:43:07,000
I'll go back to my API gateway.

782
00:43:07,000 --> 00:43:11,000
And here now you'll be able to see all the API gateways that I have specifically created.

783
00:43:11,000 --> 00:43:15,000
I have also integrated with the Lambda function that is available over there okay.

784
00:43:15,000 --> 00:43:18,000
And this is how the entire interaction will take place.

785
00:43:18,000 --> 00:43:22,000
See, it's more about writing a code, understanding about each and every services.

786
00:43:22,000 --> 00:43:25,000
And that is why all these things are amazing, right?

787
00:43:25,000 --> 00:43:27,000
So recent date is ninth.

788
00:43:27,000 --> 00:43:30,000
So let me just click on this okay post over here.

789
00:43:30,000 --> 00:43:32,000
I've already deployed this.

790
00:43:32,000 --> 00:43:33,000
So let me do one thing.

791
00:43:33,000 --> 00:43:35,000
So this is the slash blog generation.

792
00:43:36,000 --> 00:43:40,000
If I probably go ahead and see with respect to stages, if I go ahead and click on dev.

793
00:43:40,000 --> 00:43:44,000
So this will be my okay okay done.

794
00:43:44,000 --> 00:43:45,000
Each and everything is done.

795
00:43:45,000 --> 00:43:49,000
This is the integrated uh, this is in turn integrated to my lambda.

796
00:43:49,000 --> 00:43:53,000
Now, one thing that I have to do is that I also have to create my S3 bucket.

797
00:43:53,000 --> 00:43:58,000
Still, I have not created my S3 bucket because with respect to the code that I've actually given in

798
00:43:58,000 --> 00:44:06,000
my AWS bedrock, my S3 bucket name should be, uh, let's see, what is the S3 bucket name that I have

799
00:44:06,000 --> 00:44:06,000
to write?

800
00:44:06,000 --> 00:44:08,000
So it should be AWS Bedrock course one.

801
00:44:08,000 --> 00:44:14,000
So let me quickly go ahead and create my AWS bedrock A.W., AWS Bedrock Course one.

802
00:44:14,000 --> 00:44:21,000
So I will just go ahead and create my bucket, and let me just go ahead and write my bucket name, okay.

803
00:44:21,000 --> 00:44:23,000
And just let me go ahead and create the bucket okay.

804
00:44:23,000 --> 00:44:26,000
So this is the new and understand one more thing guys.

805
00:44:27,000 --> 00:44:31,000
This uh, AWS bedrock course, one that I'm basically writing.

806
00:44:31,000 --> 00:44:34,000
Uh, it should the name should be unique.

807
00:44:34,000 --> 00:44:34,000
Okay.

808
00:44:34,000 --> 00:44:38,000
So this is the name that I'm actually selecting a AWS bedrock course one.

809
00:44:38,000 --> 00:44:39,000
Okay.

810
00:44:39,000 --> 00:44:44,000
And let me just go ahead and create the bucket because throughout the region it will be it has to be

811
00:44:44,000 --> 00:44:44,000
unique.

812
00:44:44,000 --> 00:44:45,000
Okay.

813
00:44:45,000 --> 00:44:53,000
Now let me just go ahead and update in my name over here in my S3 bucket name with respect to this.

814
00:44:53,000 --> 00:44:54,000
Okay.

815
00:44:54,000 --> 00:44:56,000
Now I'll just go ahead and deploy it.

816
00:44:56,000 --> 00:44:58,000
So my AWS S3 bucket is also created.

817
00:44:58,000 --> 00:45:03,000
The code is written where we really need to save all the files and all everything is ready.

818
00:45:03,000 --> 00:45:09,000
Now, uh, let's quickly go ahead and test it and I hope everything will work fine.

819
00:45:09,000 --> 00:45:11,000
So I'll just go and open my postman.

820
00:45:11,000 --> 00:45:12,000
Okay.

821
00:45:12,000 --> 00:45:13,000
Create my new file.

822
00:45:13,000 --> 00:45:15,000
It should be a Post request.

823
00:45:15,000 --> 00:45:16,000
Let's see.

824
00:45:16,000 --> 00:45:17,000
I don't know whether it should work.

825
00:45:17,000 --> 00:45:19,000
Everything should work or not.

826
00:45:19,000 --> 00:45:22,000
If I'm getting any errors, definitely, I'll let you know.

827
00:45:22,000 --> 00:45:23,000
So let me do one more thing.

828
00:45:23,000 --> 00:45:25,000
Uh, let me just go back to this.

829
00:45:26,000 --> 00:45:30,000
Um, so this is the URL I've already seen.

830
00:45:30,000 --> 00:45:31,000
I've already deployed it in it.

831
00:45:32,000 --> 00:45:36,000
Uh, let me do APIs, block demo APIs.

832
00:45:36,000 --> 00:45:40,000
So this should be slash block generation okay.

833
00:45:40,000 --> 00:45:41,000
So this will be my URL.

834
00:45:41,000 --> 00:45:43,000
I'll go back to my postman.

835
00:45:44,000 --> 00:45:45,000
And you have to be patient.

836
00:45:45,000 --> 00:45:49,000
Guys understand you have to be really be patient because there are multiple things that you will be

837
00:45:49,000 --> 00:45:50,000
able to see.

838
00:45:51,000 --> 00:45:53,000
Now let me just go ahead and set up my body.

839
00:45:53,000 --> 00:45:56,000
My raw body will be with respect to one key.

840
00:45:57,000 --> 00:46:01,000
And if you probably see the lambda function, what is the key name that I've actually created?

841
00:46:01,000 --> 00:46:03,000
Let me go ahead and see it.

842
00:46:03,000 --> 00:46:05,000
I'll open the lambda function.

843
00:46:05,000 --> 00:46:11,000
And uh, once I open the lambda function with respect to my function name is bedrock.

844
00:46:12,000 --> 00:46:13,000
Okay.

845
00:46:13,000 --> 00:46:16,000
And here down, if you probably go ahead.

846
00:46:17,000 --> 00:46:19,000
Come on, load it quicker.

847
00:46:19,000 --> 00:46:19,000
Come on.

848
00:46:20,000 --> 00:46:21,000
It's taking time to load.

849
00:46:21,000 --> 00:46:22,000
I don't know why.

850
00:46:24,000 --> 00:46:26,000
So code is getting loaded.

851
00:46:26,000 --> 00:46:28,000
I've already deployed this code also.

852
00:46:28,000 --> 00:46:30,000
You also have to deploy the code in order to use it.

853
00:46:30,000 --> 00:46:30,000
Okay.

854
00:46:30,000 --> 00:46:32,000
So Lambda function is getting loaded.

855
00:46:32,000 --> 00:46:34,000
Let me see.

856
00:46:34,000 --> 00:46:34,000
This is there.

857
00:46:34,000 --> 00:46:35,000
This is there.

858
00:46:35,000 --> 00:46:36,000
Okay.

859
00:46:36,000 --> 00:46:40,000
Over here you can see this will basically be my blog topic in the body.

860
00:46:40,000 --> 00:46:44,000
So let me just go ahead and write blog topic blog topic.

861
00:46:44,000 --> 00:46:46,000
And let me just go ahead and write.

862
00:46:47,000 --> 00:46:55,000
The blog topic will be machine learning uh, and generative AI okay.

863
00:46:56,000 --> 00:46:56,000
Okay.

864
00:46:56,000 --> 00:46:59,000
So this will basically be my key name.

865
00:46:59,000 --> 00:47:01,000
Uh, inside my this this entire thing will be a event.

866
00:47:01,000 --> 00:47:03,000
It'll be in the event itself.

867
00:47:03,000 --> 00:47:05,000
Inside that event, there will be a body variable.

868
00:47:05,000 --> 00:47:08,000
And then we will be able to explore this blog underscore topic.

869
00:47:08,000 --> 00:47:08,000
Okay.

870
00:47:08,000 --> 00:47:11,000
So let me just go ahead and click on send Hope.

871
00:47:11,000 --> 00:47:12,000
So it works fine.

872
00:47:13,000 --> 00:47:18,000
So it is hitting hitting hitting till then uh message not found.

873
00:47:18,000 --> 00:47:21,000
Uh why it is saying message not found because blog generation is there.

874
00:47:21,000 --> 00:47:22,000
Let me see.

875
00:47:23,000 --> 00:47:25,000
Uh, such a dirt block.

876
00:47:25,000 --> 00:47:26,000
Block generation.

877
00:47:26,000 --> 00:47:27,000
Block generation.

878
00:47:27,000 --> 00:47:28,000
Let me see it.

879
00:47:28,000 --> 00:47:30,000
Block generation.

880
00:47:30,000 --> 00:47:33,000
Let me go back to my API gateway.

881
00:47:34,000 --> 00:47:40,000
And for this also, what I can actually do is that go to my configuration, um, sorry, go to my monitor.

882
00:47:40,000 --> 00:47:44,000
And inside that I can also see the logs and it will be available in the CloudWatch.

883
00:47:44,000 --> 00:47:47,000
So here you can click on view CloudWatch logs.

884
00:47:48,000 --> 00:47:52,000
And here is my entire CloudWatch logs that you will be able to see.

885
00:47:52,000 --> 00:47:52,000
Okay.

886
00:47:53,000 --> 00:47:54,000
But right now it is not working.

887
00:47:54,000 --> 00:47:56,000
Let's see why it is not working.

888
00:47:56,000 --> 00:48:01,000
Uh, we'll have the complete details that will be available over here.

889
00:48:01,000 --> 00:48:07,000
Now it goes to my log groups inside that groups specifically where we are actually working with.

890
00:48:07,000 --> 00:48:11,000
Again, I'm not going to delete this entire part of the video because I really also want you all to

891
00:48:11,000 --> 00:48:12,000
see the logs.

892
00:48:12,000 --> 00:48:13,000
Okay.

893
00:48:13,000 --> 00:48:16,000
To specify log does not exist in this particular account.

894
00:48:16,000 --> 00:48:17,000
Why?

895
00:48:17,000 --> 00:48:17,000
Okay.

896
00:48:17,000 --> 00:48:19,000
The logs has been not created.

897
00:48:19,000 --> 00:48:21,000
Let me just hit it once again.

898
00:48:22,000 --> 00:48:26,000
Blog underscore topic message not found status 404I think.

899
00:48:26,000 --> 00:48:33,000
So there is some problem with my API gateway stages slash blog generation.

900
00:48:33,000 --> 00:48:34,000
Is it correct?

901
00:48:34,000 --> 00:48:36,000
Slash blog generation?

902
00:48:36,000 --> 00:48:38,000
This looks fine.

903
00:48:38,000 --> 00:48:41,000
My post request is this one.

904
00:48:41,000 --> 00:48:45,000
Uh, the integration in the background is saved or request.

905
00:48:45,000 --> 00:48:47,000
Let me just go ahead and see my stages.

906
00:48:47,000 --> 00:48:53,000
My dev stage is this 1FPH.

907
00:48:53,000 --> 00:48:56,000
Let me see whether I've deployed that or not.

908
00:48:57,000 --> 00:49:01,000
Deploy successfully created deployment.

909
00:49:01,000 --> 00:49:03,000
The deployment is active for dev.

910
00:49:03,000 --> 00:49:05,000
This looks absolutely fine.

911
00:49:05,000 --> 00:49:09,000
Now let me just go ahead and hit it for this one.

912
00:49:10,000 --> 00:49:11,000
Message not found.

913
00:49:11,000 --> 00:49:11,000
Still.

914
00:49:11,000 --> 00:49:12,000
Message not found.

915
00:49:12,000 --> 00:49:13,000
Let me see that.

916
00:49:13,000 --> 00:49:14,000
What is the problem in this?

917
00:49:14,000 --> 00:49:20,000
So guys one simple mistake that I've actually done over here is that, see, when I pasted this entire

918
00:49:20,000 --> 00:49:23,000
thing right, there was an extra space that was added.

919
00:49:23,000 --> 00:49:28,000
And postman does not resolve this particular space, and it it keeps the space like that.

920
00:49:28,000 --> 00:49:29,000
So I'll just remove this space.

921
00:49:29,000 --> 00:49:32,000
Now I'm going to search for the topic on generative AI.

922
00:49:32,000 --> 00:49:35,000
So I will go ahead and write this 200 words block.

923
00:49:35,000 --> 00:49:37,000
Now let me just go ahead and click on send.

924
00:49:37,000 --> 00:49:40,000
And here you can probably see block generation is completed.

925
00:49:40,000 --> 00:49:43,000
Let's see whether everything has worked fine or not.

926
00:49:43,000 --> 00:49:49,000
I'm just going to reload this log groups and obviously you know how to go to this particular log groups

927
00:49:49,000 --> 00:49:51,000
go to configuration okay.

928
00:49:51,000 --> 00:49:51,000
Sorry.

929
00:49:51,000 --> 00:49:57,000
Go to monitor and just click on view CloudWatch logs so that you'll be able to see the logs itself.

930
00:49:57,000 --> 00:50:02,000
Right now let's see whether the logs uh will be able to see the buckets also or not.

931
00:50:02,000 --> 00:50:04,000
I'll also go ahead and check the buckets.

932
00:50:04,000 --> 00:50:07,000
So AWS bedrock.

933
00:50:07,000 --> 00:50:09,000
So right now nothing has got created.

934
00:50:09,000 --> 00:50:12,000
So I think there should be some kind of error over there.

935
00:50:12,000 --> 00:50:16,000
But we'll have a look, uh, whether there is an error and we'll try to fix it.

936
00:50:16,000 --> 00:50:17,000
Okay.

937
00:50:17,000 --> 00:50:19,000
Uh, so all the things usually happens over here.

938
00:50:19,000 --> 00:50:24,000
So here you can see AWS app bedrock and there is one log.

939
00:50:25,000 --> 00:50:34,000
Uh, so with respect to this particular log let's see AWS bedrock some no block was generated.

940
00:50:35,000 --> 00:50:36,000
Uh generating the blog.

941
00:50:36,000 --> 00:50:43,000
An error occurred while when calling the invoke model uh is authorized to provoke invoke model and resource.

942
00:50:43,000 --> 00:50:48,000
This because no identity based policies allows the bedrock invoke model action.

943
00:50:48,000 --> 00:50:53,000
So guys from the error that you probably see over here, it is not provided, uh, it is basically not

944
00:50:53,000 --> 00:50:54,000
providing you the access.

945
00:50:54,000 --> 00:50:58,000
So definitely the role that we have actually created for a lambda Lambda function.

946
00:50:58,000 --> 00:50:59,000
Right.

947
00:50:59,000 --> 00:51:00,000
We really need to change over here.

948
00:51:00,000 --> 00:51:00,000
Right.

949
00:51:00,000 --> 00:51:03,000
So what we can do see initially it was in code.

950
00:51:03,000 --> 00:51:06,000
Right now let's go back to the configuration and select the role name.

951
00:51:06,000 --> 00:51:13,000
So if you select the role name over here okay let me just go ahead and select this.

952
00:51:13,000 --> 00:51:19,000
And now within this particular role name we can provide further access to it okay.

953
00:51:19,000 --> 00:51:24,000
So let's say over here only the a AWS Lambda function is basically there.

954
00:51:24,000 --> 00:51:30,000
So what I can actually do is that I can provide more access, more, more permission policies, so that

955
00:51:30,000 --> 00:51:33,000
I will also be able to access the AWS bedrock.

956
00:51:33,000 --> 00:51:39,000
So to just to see like what kind of policies we can probably provide it, you know, and over here right

957
00:51:39,000 --> 00:51:41,000
now what is basically provided only AWS Lambda.

958
00:51:41,000 --> 00:51:45,000
So let's see that how we can still add more permissions.

959
00:51:45,000 --> 00:51:49,000
So here what I'm going to basically write I'm going to basically select add uh attach policy.

960
00:51:49,000 --> 00:51:54,000
And again based on like how your IAM console basically runs.

961
00:51:54,000 --> 00:51:54,000
Right.

962
00:51:54,000 --> 00:51:57,000
Uh I will basically provide it to administrator access.

963
00:51:57,000 --> 00:51:58,000
Again.

964
00:51:58,000 --> 00:52:01,000
If you are specifically working in the company, you can provide different, different access based

965
00:52:01,000 --> 00:52:03,000
on the services that you are using.

966
00:52:03,000 --> 00:52:05,000
But just to give a brief idea about it.

967
00:52:05,000 --> 00:52:10,000
So what I'm actually going to do is that I'm going to add this particular administrator access so that

968
00:52:10,000 --> 00:52:13,000
you'll be able to see that particular access over here.

969
00:52:13,000 --> 00:52:18,000
Now, once that is added, uh, let me just go back over here and let's see whether it is updated or

970
00:52:18,000 --> 00:52:18,000
not.

971
00:52:18,000 --> 00:52:23,000
Uh, so I'm roll this is there.

972
00:52:23,000 --> 00:52:23,000
Okay.

973
00:52:23,000 --> 00:52:23,000
Perfect.

974
00:52:23,000 --> 00:52:25,000
Everything works fine.

975
00:52:25,000 --> 00:52:26,000
So let me just reload this.

976
00:52:26,000 --> 00:52:31,000
And now I think we should be able to work out and see that.

977
00:52:31,000 --> 00:52:32,000
Yes.

978
00:52:32,000 --> 00:52:33,000
Now we'll be able to get the access.

979
00:52:33,000 --> 00:52:36,000
So here you can see all access is basically given.

980
00:52:36,000 --> 00:52:39,000
Now I'll go back to my postman and again hit the same request.

981
00:52:39,000 --> 00:52:41,000
Now let's see.

982
00:52:41,000 --> 00:52:42,000
See if it is taking more time.

983
00:52:42,000 --> 00:52:42,000
Right.

984
00:52:42,000 --> 00:52:48,000
That basically means my entire application is working fine and it sees we are able to see that yes,

985
00:52:48,000 --> 00:52:53,000
it is taking more amount of time now I think our blog will be generated 200 words, blog will be generated

986
00:52:53,000 --> 00:52:58,000
and we should be able to get or we should be able to be storing that entire.

987
00:52:58,000 --> 00:52:59,000
TXT file in S3 bucket.

988
00:52:59,000 --> 00:53:02,000
So let's see I will go again back over here.

989
00:53:02,000 --> 00:53:05,000
Again reload my CloudWatch.

990
00:53:05,000 --> 00:53:09,000
So let's see whether my CloudWatch has basically created or not.

991
00:53:09,000 --> 00:53:11,000
Yes new cloud new log has been created.

992
00:53:11,000 --> 00:53:16,000
So here is my entire block that has got generated generative AI the Future of Creativity and Innovation.

993
00:53:16,000 --> 00:53:19,000
Here you can see everything is working fine.

994
00:53:19,000 --> 00:53:20,000
Code save to S3 bucket.

995
00:53:20,000 --> 00:53:22,000
I can also see in the logs.

996
00:53:22,000 --> 00:53:23,000
Now it's time that.

997
00:53:23,000 --> 00:53:28,000
Let's go into my S3 bucket and see whether I will be able to find it out or not.

998
00:53:28,000 --> 00:53:31,000
So I will go back to my S3 bucket.

999
00:53:31,000 --> 00:53:39,000
Let's go ahead and hit this, and then I will be able to see this AWS Bedrock course one.

1000
00:53:39,000 --> 00:53:41,000
And here is my blog output.

1001
00:53:41,000 --> 00:53:43,000
And here is my text file right.

1002
00:53:43,000 --> 00:53:47,000
If you want to probably see this particular txt file I'll just download it.

1003
00:53:48,000 --> 00:53:51,000
But usually when we are working with AWS services we can probably see that.

1004
00:53:51,000 --> 00:53:53,000
And here let me open this.

1005
00:53:53,000 --> 00:53:56,000
And here is my entire blog right.

1006
00:53:56,000 --> 00:54:04,000
And this specifically we are using the meta uh llama llama 213 million parameters generator I is a revolutionary.

1007
00:54:04,000 --> 00:54:05,000
All the blogs has been generated.

1008
00:54:06,000 --> 00:54:10,000
Again, the main aim over here was to just to make you understand the entire flow.

1009
00:54:10,000 --> 00:54:15,000
because in the upcoming videos, the kind of projects that we are going to deal with will be quite advanced,

1010
00:54:15,000 --> 00:54:20,000
will be quite better because there we are also going to use more things like vector databases and all.

1011
00:54:20,000 --> 00:54:26,000
But all in all, this is an amazing project and this all services are specifically used step by step.

1012
00:54:26,000 --> 00:54:29,000
If you are also following it, you will also be able to do it.

1013
00:54:29,000 --> 00:54:31,000
So I hope you like this particular video.

1014
00:54:31,000 --> 00:54:32,000
This was it for my side.

1015
00:54:32,000 --> 00:54:33,000
I'll see you in the next video.

1016
00:54:33,000 --> 00:54:33,000
Have a great day!

1017
00:54:33,000 --> 00:54:34,000
Thank you and take care.

1018
00:54:34,000 --> 00:54:35,000
Bye bye.

