1
00:00:00,000 --> 00:00:00,000
Hello guys.

2
00:00:00,000 --> 00:00:03,000
So we are going to continue the discussion with respect to tools and agents.

3
00:00:04,000 --> 00:00:09,000
Now, uh, already in our previous video, we have seen that how we have created tools, uh, even we

4
00:00:09,000 --> 00:00:11,000
have also created our custom tools.

5
00:00:11,000 --> 00:00:11,000
Right.

6
00:00:11,000 --> 00:00:21,000
Now it's time that we combine this tools along with our LM model, along with if I really want to execute

7
00:00:21,000 --> 00:00:25,000
this, I will be using something called as agent executor.

8
00:00:25,000 --> 00:00:27,000
And that is where we are going to learn about agents.

9
00:00:27,000 --> 00:00:30,000
So first of all, let's go ahead and use, uh, some LM models.

10
00:00:30,000 --> 00:00:36,000
And again for this I will be using the grok API which we have specifically used over here.

11
00:00:36,000 --> 00:00:40,000
So in order to use grok I will just go ahead and open this quickly.

12
00:00:40,000 --> 00:00:44,000
I will go ahead and search for this dot env.

13
00:00:44,000 --> 00:00:46,000
And I also require my opening API key.

14
00:00:46,000 --> 00:00:47,000
Right.

15
00:00:47,000 --> 00:00:49,000
Let's go ahead and use this LM model.

16
00:00:49,000 --> 00:00:52,000
So here uh is my entire code right.

17
00:00:52,000 --> 00:00:55,000
And for this I will.

18
00:00:55,000 --> 00:00:55,000
Okay.

19
00:00:55,000 --> 00:00:56,000
TX dot secrets.

20
00:00:56,000 --> 00:01:00,000
Okay, I have to go ahead and just write import OS.

21
00:01:00,000 --> 00:01:08,000
And finally, you'll also be able to see that I will go ahead and write OS dot os dot get env.

22
00:01:10,000 --> 00:01:16,000
Will be with respect to my and similarly OS dot.

23
00:01:18,000 --> 00:01:23,000
OS dot get env will be my open API key, right?

24
00:01:23,000 --> 00:01:29,000
And uh, for this again I will go ahead and import open AI because I will require this.

25
00:01:30,000 --> 00:01:32,000
And since I'm using Chat Grok API.

26
00:01:32,000 --> 00:01:35,000
So obviously you know how to probably import this.

27
00:01:35,000 --> 00:01:40,000
So for chat grok I will be using Lang chat underscore grok okay.

28
00:01:40,000 --> 00:01:42,000
And I will go ahead and import it over here.

29
00:01:43,000 --> 00:01:43,000
Right.

30
00:01:43,000 --> 00:01:45,000
So I'm actually going to use this llama three model.

31
00:01:45,000 --> 00:01:49,000
And already I've actually shown you how things are basically done you know.

32
00:01:49,000 --> 00:01:53,000
So OpenAI API key is basically set to the API key.

33
00:01:53,000 --> 00:01:56,000
The reason why I'm using OpenAI API key because for the OpenAI embeddings.

34
00:01:56,000 --> 00:01:57,000
Right.

35
00:01:57,000 --> 00:02:02,000
So here are the kind of embeddings that I'm trying to apply for this particular documents.

36
00:02:02,000 --> 00:02:04,000
It will be from OpenAI embeddings itself.

37
00:02:04,000 --> 00:02:05,000
Right.

38
00:02:05,000 --> 00:02:07,000
So uh, I will be doing that.

39
00:02:07,000 --> 00:02:12,000
And here, uh, I will go ahead and use this with respect to the get environment variable.

40
00:02:12,000 --> 00:02:12,000
Okay.

41
00:02:13,000 --> 00:02:15,000
Now this is my LM model.

42
00:02:15,000 --> 00:02:15,000
Right.

43
00:02:15,000 --> 00:02:18,000
Uh, and I'm using llama three specifically LM models.

44
00:02:18,000 --> 00:02:18,000
Okay.

45
00:02:18,000 --> 00:02:21,000
So this is the first step that we really need to do.

46
00:02:21,000 --> 00:02:26,000
I'll go ahead and execute this I'm getting an error saying that okay.

47
00:02:26,000 --> 00:02:27,000
Uh, Chad grok okay.

48
00:02:27,000 --> 00:02:29,000
This OS dot get env okay.

49
00:02:29,000 --> 00:02:31,000
This is the problem.

50
00:02:31,000 --> 00:02:34,000
I will just go ahead and use my brackets brackets.

51
00:02:34,000 --> 00:02:36,000
Okay, now it should work.

52
00:02:37,000 --> 00:02:38,000
It's okay.

53
00:02:38,000 --> 00:02:40,000
Uh, I am not deleting this error.

54
00:02:40,000 --> 00:02:46,000
Whatever error we basically face, okay, whenever you get an error, never hesitate to solve it.

55
00:02:46,000 --> 00:02:46,000
Okay?

56
00:02:46,000 --> 00:02:48,000
And don't be afraid.

57
00:02:48,000 --> 00:02:51,000
Errors are something which are simple, common mistakes that we do.

58
00:02:51,000 --> 00:02:53,000
And it is fixable.

59
00:02:53,000 --> 00:02:57,000
Okay, now we will go ahead and create our prompt template.

60
00:02:57,000 --> 00:03:04,000
Now see guys, one example of creating the prompt template I've already shown you um in long chain.

61
00:03:04,000 --> 00:03:05,000
There is also something called as hub.

62
00:03:05,000 --> 00:03:13,000
You know some some different different types of uh, if I probably consider with respect to, uh, a

63
00:03:13,000 --> 00:03:16,000
prompt, you know, is already created and uploaded in the hub.

64
00:03:16,000 --> 00:03:17,000
Okay.

65
00:03:17,000 --> 00:03:19,000
So today in this video I will talk about one way.

66
00:03:19,000 --> 00:03:23,000
So I'll write hey from Lang Chen okay.

67
00:03:23,000 --> 00:03:27,000
Lang Chen I'll say import hub okay.

68
00:03:27,000 --> 00:03:31,000
And from this particular hub you know I will just go ahead and write.

69
00:03:31,000 --> 00:03:40,000
Prompt is equal to hub dot pull okay I will say pull one of the type of prompt that is already been

70
00:03:40,000 --> 00:03:41,000
created.

71
00:03:41,000 --> 00:03:44,000
And when I was searching in the hub itself.

72
00:03:44,000 --> 00:03:44,000
Right.

73
00:03:44,000 --> 00:03:47,000
You'll be able to see something like OpenAI function agent.

74
00:03:47,000 --> 00:03:48,000
So let's talk about this.

75
00:03:48,000 --> 00:03:49,000
Okay.

76
00:03:49,000 --> 00:03:54,000
So here, uh, what I'm actually going to do is that I will just go ahead and search about this OpenAI

77
00:03:54,000 --> 00:03:56,000
function agent prompt.

78
00:03:56,000 --> 00:03:56,000
Okay.

79
00:03:56,000 --> 00:04:02,000
So in the OpenAI function agent prompt, if I go ahead and see it right, see to it.

80
00:04:02,000 --> 00:04:05,000
So it uh, this is the prompt that is basically there.

81
00:04:05,000 --> 00:04:09,000
And this prompt is basically getting displayed right here.

82
00:04:09,000 --> 00:04:11,000
You have a system prompt message template.

83
00:04:11,000 --> 00:04:14,000
You have message placeholder for the chat history.

84
00:04:14,000 --> 00:04:17,000
Then you have human message prompt template.

85
00:04:17,000 --> 00:04:19,000
Then you have this message placeholder.

86
00:04:19,000 --> 00:04:21,000
So this kind of prompt is basically getting created.

87
00:04:21,000 --> 00:04:25,000
And over here it says hey you are just a helpful assistant right?

88
00:04:25,000 --> 00:04:31,000
But again, my uh, best practice will be that use always chat prompt template uh and then try to create

89
00:04:31,000 --> 00:04:32,000
a prompt.

90
00:04:32,000 --> 00:04:35,000
But here I wanted to show you a variety of ways.

91
00:04:35,000 --> 00:04:38,000
So that is the reason I'm actually going ahead and showing you okay.

92
00:04:38,000 --> 00:04:43,000
And here you can go ahead and write prompt dot messages okay.

93
00:04:44,000 --> 00:04:50,000
So once I execute this here you'll be able to see this entire prompt is basically getting displayed.

94
00:04:50,000 --> 00:04:55,000
Now I'm going to combine this prompt along with this LM and all the tools that I've actually created.

95
00:04:55,000 --> 00:04:56,000
Right.

96
00:04:56,000 --> 00:04:59,000
So if I want to execute all together in the form of chain.

97
00:04:59,000 --> 00:05:02,000
So I have to specifically use agents.

98
00:05:02,000 --> 00:05:03,000
Okay.

99
00:05:04,000 --> 00:05:11,000
So what I will do, I will write from line chain dot agents okay I'm going to go ahead and write import

100
00:05:11,000 --> 00:05:12,000
create.

101
00:05:13,000 --> 00:05:20,000
Uh, one of the easiest way of creating agent is by using this open AI tools underscore agent.

102
00:05:20,000 --> 00:05:22,000
Then you also have open API agents.

103
00:05:22,000 --> 00:05:26,000
But I'm just going to use this open AI function agent is also there.

104
00:05:26,000 --> 00:05:26,000
See.

105
00:05:27,000 --> 00:05:29,000
So all these agents right.

106
00:05:29,000 --> 00:05:33,000
So if I go ahead and show you in the documentation right.

107
00:05:33,000 --> 00:05:37,000
And it's always necessary that see this is one tool and all are there.

108
00:05:37,000 --> 00:05:38,000
Right.

109
00:05:38,000 --> 00:05:41,000
Uh types of agents tool callings.

110
00:05:41,000 --> 00:05:42,000
This is open AI tool.

111
00:05:42,000 --> 00:05:43,000
Right.

112
00:05:43,000 --> 00:05:48,000
So here you'll be able to see newer open AI models has been fine tuned to detect with one or more functions.

113
00:05:48,000 --> 00:05:49,000
Right.

114
00:05:49,000 --> 00:05:52,000
The goal of the OpenAI tools API is to be more reliable return.

115
00:05:52,000 --> 00:05:55,000
You can basically go ahead and check out this documentation.

116
00:05:55,000 --> 00:05:55,000
What is this?

117
00:05:55,000 --> 00:05:57,000
OpenAI functions?

118
00:05:57,000 --> 00:06:00,000
Uh, you saw one example over there, right?

119
00:06:00,000 --> 00:06:06,000
And here it says that certain OpenAI models like GPT 3.5 turbo have been fine tuned to detect and not

120
00:06:06,000 --> 00:06:06,000
see.

121
00:06:06,000 --> 00:06:08,000
I'm using grok right now.

122
00:06:08,000 --> 00:06:13,000
I don't know whether it is going to work or not, but let's see, you know, so there are multiple ways

123
00:06:13,000 --> 00:06:15,000
of calling different, different tools also.

124
00:06:15,000 --> 00:06:18,000
So here you also have with Google, you have with Mistral.

125
00:06:18,000 --> 00:06:23,000
I don't know whether it will work with grok or not, but I'll just give her my best try.

126
00:06:23,000 --> 00:06:25,000
If it works with grok, it is well and good.

127
00:06:25,000 --> 00:06:28,000
Otherwise I'll just go ahead and change this entire model.

128
00:06:28,000 --> 00:06:30,000
Okay, that is what I'm actually going to do.

129
00:06:30,000 --> 00:06:40,000
So from Lang chain, uh, dot agents I'm just going to use one called as Create table open AI tools

130
00:06:40,000 --> 00:06:40,000
agent.

131
00:06:40,000 --> 00:06:41,000
So I'll go ahead in with this.

132
00:06:41,000 --> 00:06:42,000
Again.

133
00:06:42,000 --> 00:06:44,000
Please make sure that you watch these documentations.

134
00:06:44,000 --> 00:06:45,000
Right.

135
00:06:45,000 --> 00:06:50,000
Go ahead and check the documentation agent is equal to I will go ahead and write create open AI tool

136
00:06:50,000 --> 00:06:50,000
agents.

137
00:06:50,000 --> 00:06:56,000
And here I'm just going to specifically use my LLM model my tools and my prompt okay.

138
00:06:57,000 --> 00:06:58,000
So I'll use this three.

139
00:06:58,000 --> 00:07:02,000
And over here uh this specifically becomes my agent.

140
00:07:02,000 --> 00:07:04,000
I will go ahead and execute it.

141
00:07:05,000 --> 00:07:06,000
Go and execute it.

142
00:07:06,000 --> 00:07:10,000
So here is the entire chain that is basically getting created.

143
00:07:10,000 --> 00:07:11,000
And I'm using Chat Grok.

144
00:07:11,000 --> 00:07:13,000
I think this should also work.

145
00:07:13,000 --> 00:07:14,000
That is what I feel.

146
00:07:15,000 --> 00:07:16,000
Uh but let's see.

147
00:07:16,000 --> 00:07:16,000
Okay.

148
00:07:16,000 --> 00:07:19,000
Once I have created my agent, I need to run this agent.

149
00:07:19,000 --> 00:07:19,000
Right.

150
00:07:19,000 --> 00:07:25,000
So for running this agent, we basically go ahead and create our agent.

151
00:07:25,000 --> 00:07:26,000
executor.

152
00:07:26,000 --> 00:07:27,000
Okay.

153
00:07:27,000 --> 00:07:35,000
So I will go ahead and write from line chain, dot agents, import agent executor.

154
00:07:35,000 --> 00:07:43,000
And from this agent underscore executor I will go ahead and write agent executor.

155
00:07:43,000 --> 00:07:45,000
And here first of all I need to give my agent.

156
00:07:45,000 --> 00:07:51,000
The agent is a combination of all these things which will be in the form of chain link tools and prompt.

157
00:07:51,000 --> 00:07:57,000
Then along with this, I will also go ahead and give my tool section, which will be equal to this tools.

158
00:07:57,000 --> 00:07:59,000
And I'll go and write.

159
00:07:59,000 --> 00:08:03,000
My verbose is equal to true, so that I will be able to see the interaction how it happens.

160
00:08:03,000 --> 00:08:03,000
Right?

161
00:08:04,000 --> 00:08:09,000
So once I go ahead and execute this so this basically becomes my agent executor.

162
00:08:09,000 --> 00:08:12,000
So here you can see chat prompt template is also included.

163
00:08:12,000 --> 00:08:15,000
Input type chat history language and core message.

164
00:08:15,000 --> 00:08:19,000
And all right just to give you an idea I've used a hub over here.

165
00:08:19,000 --> 00:08:23,000
So that is the reason you'll be able to see the variable name will be chat history over here.

166
00:08:23,000 --> 00:08:24,000
Right.

167
00:08:24,000 --> 00:08:27,000
All the information the default variable name is input.

168
00:08:27,000 --> 00:08:31,000
You can also go ahead and create this I think uh it will hardly take two minutes okay.

169
00:08:32,000 --> 00:08:37,000
So now let's go ahead and finally execute our agent executor okay.

170
00:08:37,000 --> 00:08:40,000
So I will go ahead and write agent executor.

171
00:08:41,000 --> 00:08:41,000
Okay.

172
00:08:41,000 --> 00:08:43,000
Dot invoke.

173
00:08:43,000 --> 00:08:47,000
And here I'm just going to go ahead and write my input.

174
00:08:48,000 --> 00:08:50,000
Because this is the key that we really want to know.

175
00:08:50,000 --> 00:08:52,000
And let's say I go ahead and ask a question.

176
00:08:52,000 --> 00:08:55,000
Tell me about Lang Smith okay.

177
00:08:55,000 --> 00:08:59,000
So Lang Smith obviously it should go ahead and interact with our tool.

178
00:08:59,000 --> 00:09:00,000
Right.

179
00:09:00,000 --> 00:09:02,000
Let's see what happens.

180
00:09:02,000 --> 00:09:06,000
So okay invoke let's go ahead and execute this.

181
00:09:06,000 --> 00:09:09,000
So here you can see entering new executor chain.

182
00:09:09,000 --> 00:09:12,000
And suddenly this language search has been opened up.

183
00:09:12,000 --> 00:09:15,000
And this is what you are able to get the answer right.

184
00:09:15,000 --> 00:09:16,000
Tell me about Langschmidt.

185
00:09:16,000 --> 00:09:21,000
The result of the tool call ID is a web page about Lange Smith, a platform for building production

186
00:09:21,000 --> 00:09:22,000
grade application.

187
00:09:22,000 --> 00:09:22,000
Perfect.

188
00:09:23,000 --> 00:09:24,000
Um, let's execute more.

189
00:09:24,000 --> 00:09:26,000
Okay, I will go ahead and say hey.

190
00:09:27,000 --> 00:09:29,000
um, let's see.

191
00:09:29,000 --> 00:09:32,000
I'll go ahead and ask, hey, what is machine learning?

192
00:09:32,000 --> 00:09:34,000
Let's see from where it will go ahead and pick it.

193
00:09:36,000 --> 00:09:40,000
Whether it is just going to use the LM model center.

194
00:09:40,000 --> 00:09:40,000
New executor.

195
00:09:40,000 --> 00:09:42,000
Oh, it's meant to Wikipedia, right.

196
00:09:42,000 --> 00:09:44,000
See, automatically.

197
00:09:44,000 --> 00:09:44,000
Amazing.

198
00:09:45,000 --> 00:09:46,000
Machine learning is a field of this.

199
00:09:46,000 --> 00:09:47,000
There's this.

200
00:09:47,000 --> 00:09:48,000
All the information is over here.

201
00:09:49,000 --> 00:09:51,000
Uh, it is also going into the Lang Smith.

202
00:09:51,000 --> 00:09:52,000
See?

203
00:09:52,000 --> 00:09:54,000
But finally, you can see get started with Langschmidt.

204
00:09:54,000 --> 00:09:56,000
It was not able.

205
00:09:56,000 --> 00:10:01,000
I hope this response provides a good overview of machine learning and okay, it is also using the previous

206
00:10:01,000 --> 00:10:01,000
history.

207
00:10:01,000 --> 00:10:03,000
So this is the amazing thing right?

208
00:10:04,000 --> 00:10:11,000
Uh, the the main reason of using this hub was making sure that this, this this one open agent function.

209
00:10:11,000 --> 00:10:15,000
So here it is also recording the entire information about the chat history.

210
00:10:15,000 --> 00:10:15,000
Right.

211
00:10:15,000 --> 00:10:18,000
So here you can see that I'm able to get the answer.

212
00:10:18,000 --> 00:10:18,000
Okay.

213
00:10:18,000 --> 00:10:20,000
Let me just go ahead and ask one more question.

214
00:10:20,000 --> 00:10:25,000
I'm just going to go ahead and ask about, uh, let's see what is in our save.

215
00:10:25,000 --> 00:10:28,000
You know, if I go ahead and search for attention is all you need.

216
00:10:28,000 --> 00:10:31,000
This is one of the famous research paper.

217
00:10:31,000 --> 00:10:32,000
I'll just go and search for this number.

218
00:10:32,000 --> 00:10:33,000
Okay.

219
00:10:33,000 --> 00:10:36,000
Let's see where I'll get that number over here.

220
00:10:36,000 --> 00:10:38,000
So this will basically be my number.

221
00:10:38,000 --> 00:10:39,000
Okay.

222
00:10:39,000 --> 00:10:44,000
And, uh, I will just go ahead and ask it over here.

223
00:10:44,000 --> 00:10:44,000
Okay.

224
00:10:44,000 --> 00:10:54,000
So I'll say, hey, uh, agent Dot executor, and I'll say, hey, just let me know, what is this research

225
00:10:54,000 --> 00:10:56,000
paper all about?

226
00:10:57,000 --> 00:10:58,000
Okay.

227
00:11:02,000 --> 00:11:03,000
So let's see.

228
00:11:03,000 --> 00:11:05,000
It should probably go to our chef.

229
00:11:05,000 --> 00:11:06,000
See.

230
00:11:06,000 --> 00:11:07,000
Beautiful.

231
00:11:07,000 --> 00:11:08,000
Right.

232
00:11:08,000 --> 00:11:10,000
And then we are searching about Wikipedia.

233
00:11:10,000 --> 00:11:12,000
See how beautifully it is combined.

234
00:11:12,000 --> 00:11:19,000
And here you can see all the response that is probably getting right now a part of the entire search

235
00:11:19,000 --> 00:11:20,000
engine is actually completed over here.

236
00:11:20,000 --> 00:11:27,000
But now in our next video, uh, I'm going to combine everything of this and probably, uh, you know,

237
00:11:27,000 --> 00:11:27,000
implement it.

238
00:11:27,000 --> 00:11:31,000
But at the end of the day, please make sure that you watch the documentation page.

239
00:11:31,000 --> 00:11:36,000
You really need to understand how Agent Executor is here, what all options are specifically there.

240
00:11:36,000 --> 00:11:41,000
You know, uh, how to probably combine this, how many number of tools you have to create, how to

241
00:11:41,000 --> 00:11:42,000
create a common tools and all.

242
00:11:42,000 --> 00:11:47,000
But later on, the maximum thing will be with respect to more about exploration, right?

243
00:11:47,000 --> 00:11:52,000
So yes, in our next video, uh, I'm going to create our end to end search engine project.

244
00:11:52,000 --> 00:11:53,000
So I hope you like this particular video.

245
00:11:53,000 --> 00:11:54,000
I'll see you all in the next video.

246
00:11:54,000 --> 00:11:54,000
Thank you.

247
00:11:54,000 --> 00:11:55,000
Take care.

248
00:11:55,000 --> 00:11:55,000
Bye bye.

