1
00:00:00,000 --> 00:00:01,000
Hello guys!

2
00:00:01,000 --> 00:00:06,000
In this video and in the upcoming series of video, we are going to discuss about a new module in long

3
00:00:06,000 --> 00:00:08,000
chain, which is called as lang graph.

4
00:00:08,000 --> 00:00:16,000
Now Lang graph is quite amazing because it actually helps you to build stateful multi actor application

5
00:00:16,000 --> 00:00:17,000
with Llms.

6
00:00:17,000 --> 00:00:21,000
It is used to create agent and multi agent workflow.

7
00:00:21,000 --> 00:00:22,000
So this is really important.

8
00:00:22,000 --> 00:00:28,000
Now there are lot of libraries a lot of open source libraries that are available which actually helps

9
00:00:28,000 --> 00:00:31,000
you to create multi agent workflow.

10
00:00:31,000 --> 00:00:35,000
But if I probably consider lang graph it's quite amazing.

11
00:00:35,000 --> 00:00:41,000
Uh so in this entire video and in the upcoming series of video, I will be discussing many things about

12
00:00:41,000 --> 00:00:42,000
land graph.

13
00:00:42,000 --> 00:00:46,000
First of all, the agenda of this particular video will be that we will try to discuss what exactly

14
00:00:46,000 --> 00:00:49,000
is lang graph, why lang graph, and we'll see.

15
00:00:49,000 --> 00:00:55,000
Or we'll try to create a chatbot wherein we will get just started with Lang graph, where I will be

16
00:00:55,000 --> 00:00:57,000
showing you with respect to all the coding things.

17
00:00:57,000 --> 00:00:57,000
Right.

18
00:00:57,000 --> 00:00:59,000
So all these things we will be covering.

19
00:00:59,000 --> 00:01:05,000
And when we discuss about why Landgraaf at that point of time, you will understand the importance of

20
00:01:05,000 --> 00:01:06,000
landgraaf.

21
00:01:06,000 --> 00:01:12,000
And through this, you know you will also be able to cover or you'll be able to just compare with all

22
00:01:12,000 --> 00:01:17,000
the libraries, open source libraries that are available to create multi agents workflows.

23
00:01:17,000 --> 00:01:18,000
Right.

24
00:01:18,000 --> 00:01:20,000
And I feel right now Landgraaf is quite amazing.

25
00:01:20,000 --> 00:01:27,000
And as you all know, Lang what Lang is also doing is that Lang is coming up with this own cloud platform

26
00:01:27,000 --> 00:01:33,000
through which you will be able to build your own, uh, agent multi agent workflow, uh, using Lang

27
00:01:33,000 --> 00:01:33,000
graph.

28
00:01:33,000 --> 00:01:36,000
And it, you can do it completely in a visualization way.

29
00:01:36,000 --> 00:01:37,000
Right.

30
00:01:37,000 --> 00:01:39,000
And right now it just supports for the Mac machine.

31
00:01:39,000 --> 00:01:43,000
So we'll be discussing all about that as we go ahead.

32
00:01:43,000 --> 00:01:47,000
But right now let's go ahead and focus on first of all we'll go ahead and see the definition of Lang

33
00:01:47,000 --> 00:01:48,000
graph.

34
00:01:48,000 --> 00:01:50,000
So if I talk about what is lang graph.

35
00:01:50,000 --> 00:01:56,000
Lang graph is a library for building stateful multi actor application with Llms used to create agent

36
00:01:56,000 --> 00:01:59,000
and multi multi-agent workflows.

37
00:01:59,000 --> 00:02:04,000
Compared to other LLM frameworks, it offers this core benefit cycles.

38
00:02:04,000 --> 00:02:05,000
So this is really important.

39
00:02:05,000 --> 00:02:08,000
Controllability and persistence okay.

40
00:02:09,000 --> 00:02:16,000
Line graphs allows you to define the flows that involves cycle essential for most agentic architecture

41
00:02:16,000 --> 00:02:19,000
differentiating it from Dag based solutions.

42
00:02:19,000 --> 00:02:26,000
Now if you have seen already my previous video, I hope everybody knows about graph DB.

43
00:02:26,000 --> 00:02:30,000
Okay, so what exactly is graph DB?

44
00:02:30,000 --> 00:02:36,000
It probably helps you to create, you know, if I probably just talk about creating a drag application

45
00:02:36,000 --> 00:02:38,000
using graph knowledge, right.

46
00:02:38,000 --> 00:02:41,000
So here specifically you have nodes.

47
00:02:41,000 --> 00:02:43,000
You have relationship between the nodes.

48
00:02:43,000 --> 00:02:44,000
Uh, like this.

49
00:02:44,000 --> 00:02:51,000
You know, and with the help of this kind of relationships you can actually build this graph knowledge

50
00:02:51,000 --> 00:02:51,000
okay.

51
00:02:51,000 --> 00:02:57,000
And graph knowledge is specifically built right now even in Google search engine you'll be able to see

52
00:02:57,000 --> 00:03:03,000
graph knowledge and with the help of this graph knowledge, you'll be able to develop some amazing application.

53
00:03:03,000 --> 00:03:08,000
Because the efficiency with respect to the graph knowledge search is quite amazing, you know?

54
00:03:08,000 --> 00:03:13,000
So graph knowledge has the combination of all the kind of search, the hybrid search, the graph knowledge

55
00:03:13,000 --> 00:03:19,000
search, you know, so whenever you have any information which is, uh, displayed or which is probably

56
00:03:19,000 --> 00:03:27,000
converted into a graph knowledge information, then your conversation with this kind of data store,

57
00:03:27,000 --> 00:03:28,000
right, can be quite amazing.

58
00:03:28,000 --> 00:03:33,000
So already I have discussed about this in our previous video, but in this video we will try to talk

59
00:03:33,000 --> 00:03:34,000
about line graph.

60
00:03:34,000 --> 00:03:39,000
And the main thing will be that how we have actually created this graph DB structure, right in the

61
00:03:39,000 --> 00:03:40,000
form of graph knowledge.

62
00:03:40,000 --> 00:03:44,000
Similarly line graph is also offers those kind of functionality.

63
00:03:44,000 --> 00:03:49,000
We can create the entire multi agent workflow using this graph knowledge itself.

64
00:03:49,000 --> 00:03:50,000
Right.

65
00:03:50,000 --> 00:03:52,000
So like how we have nodes relationship and all.

66
00:03:52,000 --> 00:03:54,000
Similarly in the line graph.

67
00:03:54,000 --> 00:03:55,000
Also we'll be able to do that.

68
00:03:55,000 --> 00:03:56,000
Okay.

69
00:03:56,000 --> 00:03:59,000
So till now we have just discussed about the definition.

70
00:03:59,000 --> 00:04:03,000
Don't worry if you are not able to understand because once we start the practical application everything

71
00:04:03,000 --> 00:04:04,000
will be able to understand.

72
00:04:04,000 --> 00:04:05,000
Okay.

73
00:04:05,000 --> 00:04:08,000
Now let's talk about the second question.

74
00:04:08,000 --> 00:04:10,000
The second most important question.

75
00:04:10,000 --> 00:04:12,000
Why land graph.

76
00:04:14,000 --> 00:04:15,000
Why land graph?

77
00:04:15,000 --> 00:04:22,000
Okay, now here I will be talking about some amazing benefits of using land graph in point wise.

78
00:04:22,000 --> 00:04:28,000
Okay, so let's go and talk about this amazing benefits of using land graph.

79
00:04:28,000 --> 00:04:29,000
So number one.

80
00:04:29,000 --> 00:04:30,000
Okay.

81
00:04:30,000 --> 00:04:41,000
Number one is that it really simplifies the development simplifies development.

82
00:04:41,000 --> 00:04:45,000
Now when I say simplifies development what does this basically mean.

83
00:04:45,000 --> 00:04:52,000
See whatever complexities usually whenever we develop any multi AI agents right.

84
00:04:52,000 --> 00:04:59,000
They are multiple things that is involved the state management, state management, state management

85
00:04:59,000 --> 00:05:05,000
of the agent, like at which stage at what work it needs to really do, and agent coordination.

86
00:05:05,000 --> 00:05:09,000
Let's say one agent needs to communicate with any other agents, right?

87
00:05:10,000 --> 00:05:13,000
When we say agents we are basically talking about multi agents.

88
00:05:13,000 --> 00:05:14,000
Right.

89
00:05:14,000 --> 00:05:16,000
So this two things are very important.

90
00:05:16,000 --> 00:05:22,000
You know here if I probably see in most of the libraries that I've actually used, most of the open

91
00:05:22,000 --> 00:05:25,000
source libraries that I've used to probably develop multi agents.

92
00:05:25,000 --> 00:05:30,000
This two information that we have that is state management and agent coordination.

93
00:05:30,000 --> 00:05:34,000
I found out a lot of difficulties with respect to managing these things.

94
00:05:34,000 --> 00:05:35,000
Right.

95
00:05:35,000 --> 00:05:39,000
But with the help of Landgraaf it really simplifies it.

96
00:05:39,000 --> 00:05:43,000
Now when we talk about state management and agent coordination, what does this basically mean?

97
00:05:43,000 --> 00:05:49,000
Let's say that I'm using 3 to 4 multi agents in my generative AI application.

98
00:05:49,000 --> 00:05:52,000
One agent is probably doing some Wikipedia search.

99
00:05:52,000 --> 00:05:58,000
So let's say I probably need I require agent one, I require agent two.

100
00:05:58,000 --> 00:06:00,000
I require agent three.

101
00:06:00,000 --> 00:06:01,000
Right.

102
00:06:01,000 --> 00:06:04,000
So let's say all these specific agents are there right.

103
00:06:04,000 --> 00:06:09,000
Each and every agent probably needs to it does some specific task.

104
00:06:09,000 --> 00:06:10,000
Right.

105
00:06:10,000 --> 00:06:12,000
Let's say this will be doing a Google search.

106
00:06:14,000 --> 00:06:16,000
This will be doing a Wikipedia search.

107
00:06:18,000 --> 00:06:20,000
And this will probably do a vector search.

108
00:06:20,000 --> 00:06:22,000
Vector DB search.

109
00:06:24,000 --> 00:06:24,000
Right.

110
00:06:25,000 --> 00:06:31,000
And here is my chatbot which is specifically using all this multi agents.

111
00:06:32,000 --> 00:06:40,000
Now whenever we develop this kind of application it is very important that we have to do the state management

112
00:06:40,000 --> 00:06:46,000
efficiently for all the agents and also the agent coordination.

113
00:06:47,000 --> 00:06:54,000
What does agent coordination basically means the communication between the communication between this

114
00:06:54,000 --> 00:06:55,000
kind of agents.

115
00:06:55,000 --> 00:06:58,000
Let's say whenever a query is asked, first of all, we go and ask.

116
00:06:59,000 --> 00:07:03,000
Agent one hey, whether you really need to do a Google search, if you are doing it, you really need

117
00:07:03,000 --> 00:07:05,000
to provide that information to agent two.

118
00:07:05,000 --> 00:07:07,000
Then agent three will probably come into picture.

119
00:07:07,000 --> 00:07:12,000
So this kind of communication is basically a kind of agent coordination.

120
00:07:12,000 --> 00:07:13,000
Okay.

121
00:07:13,000 --> 00:07:18,000
So whenever we are developing this kind of things, you know, and there may be also scenario that when

122
00:07:18,000 --> 00:07:26,000
you're developing a use case the agent one response may be dependent on agent two or response, you

123
00:07:26,000 --> 00:07:26,000
know.

124
00:07:26,000 --> 00:07:30,000
So agent two will only be able to work when they get the response from agent one.

125
00:07:30,000 --> 00:07:33,000
I'm just giving some hypothetical scenarios okay.

126
00:07:34,000 --> 00:07:42,000
Now when we are developing this kind of chatbots, uh, as a developer we really need to define workflows.

127
00:07:43,000 --> 00:07:45,000
We need to define workflows.

128
00:07:45,000 --> 00:07:48,000
We need to define logics.

129
00:07:49,000 --> 00:07:51,000
Right without worrying, right?

130
00:07:51,000 --> 00:07:53,000
Without worrying about so many different things.

131
00:07:53,000 --> 00:07:54,000
Right.

132
00:07:54,000 --> 00:07:57,000
So that is what it actually does.

133
00:07:57,000 --> 00:08:03,000
Line graph actually provides you this entire simply it simplifies this entire development process.

134
00:08:03,000 --> 00:08:07,000
And it will actually help you to create an efficient multi AI agents.

135
00:08:07,000 --> 00:08:07,000
Right.

136
00:08:07,000 --> 00:08:12,000
So we will be discussing more about it when we go ahead and discuss about the practical implementation.

137
00:08:13,000 --> 00:08:17,000
Second thing is that uh why line graph you should use it.

138
00:08:17,000 --> 00:08:22,000
Second thing a very important point is related to flexibility okay.

139
00:08:23,000 --> 00:08:29,000
So whenever we talk about flexibility, I will just, uh, make sure to provide some description information

140
00:08:29,000 --> 00:08:31,000
over here so that you will be able to refer this.

141
00:08:31,000 --> 00:08:32,000
Okay.

142
00:08:34,000 --> 00:08:40,000
So with respect to flexibility, you can see with line graph develops developers have the flexibility

143
00:08:40,000 --> 00:08:43,000
to define their own agent logic communication protocols.

144
00:08:43,000 --> 00:08:48,000
This allows for highly customized application tailored to specific use cases.

145
00:08:48,000 --> 00:08:52,000
Whether you need a chatbot that can handle various types of user requests, or a multi-agent system

146
00:08:52,000 --> 00:08:54,000
that performs complex tasks.

147
00:08:54,000 --> 00:08:57,000
Lang graph provides the tools to build exactly what you need.

148
00:08:57,000 --> 00:09:01,000
Okay, so it's all about giving you the power to create.

149
00:09:01,000 --> 00:09:07,000
So, uh, with respect to flexibility, as I said, the kind of logics that you can basically write

150
00:09:07,000 --> 00:09:08,000
will be quite amazing.

151
00:09:08,000 --> 00:09:13,000
You'll be seeing that how granular level logics you can actually write with respect to each and every

152
00:09:13,000 --> 00:09:15,000
agents that you specifically create.

153
00:09:15,000 --> 00:09:19,000
I will be showing you, as we go ahead with one very good practical example.

154
00:09:19,000 --> 00:09:19,000
Okay.

155
00:09:20,000 --> 00:09:27,000
Then the third thing is that if I talk about the third important point, why specifically we should

156
00:09:27,000 --> 00:09:31,000
use lang graph, uh, it is related to scalability.

157
00:09:33,000 --> 00:09:33,000
Okay.

158
00:09:34,000 --> 00:09:42,000
Now whenever we talk about scalability here, when we are building this multi agent application we can

159
00:09:42,000 --> 00:09:51,000
actually build large scale multi agent application large scale multi agent applications.

160
00:09:52,000 --> 00:09:53,000
Now what?

161
00:09:53,000 --> 00:09:56,000
What do we mean by large scale multi agent application.

162
00:09:57,000 --> 00:09:59,000
See the kind of robust architecture.

163
00:09:59,000 --> 00:10:02,000
We basically use this large scale multi agent.

164
00:10:02,000 --> 00:10:10,000
We basically say this as large scale multi agent application because it can it can handle it can handle

165
00:10:10,000 --> 00:10:16,000
high volume of interaction high volume of interaction.

166
00:10:17,000 --> 00:10:17,000
Right.

167
00:10:17,000 --> 00:10:20,000
The interaction can be between agents.

168
00:10:20,000 --> 00:10:25,000
And it also has a really amazing or complex workflows.

169
00:10:25,000 --> 00:10:29,000
And you'll be seeing when we define about complex workflows.

170
00:10:29,000 --> 00:10:33,000
It it will be very simple to develop this entire workflow itself.

171
00:10:33,000 --> 00:10:34,000
Right.

172
00:10:34,000 --> 00:10:37,000
And even long chain is coming up with a feature.

173
00:10:37,000 --> 00:10:42,000
And probably many people, many companies are going to use specifically in enterprise.

174
00:10:42,000 --> 00:10:42,000
Right.

175
00:10:42,000 --> 00:10:45,000
And there is also an enterprise version.

176
00:10:45,000 --> 00:10:49,000
We can specifically develop this as an enterprise level application, right?

177
00:10:49,000 --> 00:10:50,000
With all the features.

178
00:10:50,000 --> 00:10:55,000
And it is also coming up with its own cloud where you can just do drag and drop and you can actually

179
00:10:55,000 --> 00:10:55,000
create this.

180
00:10:55,000 --> 00:11:04,000
Right, uh, final, uh, important feature, uh, if I talk about is something called as fault tolerance.

181
00:11:05,000 --> 00:11:07,000
Fault tolerance.

182
00:11:07,000 --> 00:11:11,000
So it also has this amazing feature line graph okay.

183
00:11:11,000 --> 00:11:16,000
So the kind of libraries you'll be seeing, line graph libraries will include.

184
00:11:16,000 --> 00:11:16,000
Right.

185
00:11:16,000 --> 00:11:19,000
Uh, it will be able to handle errors.

186
00:11:20,000 --> 00:11:23,000
You'll be seeing that it will be able to handle errors.

187
00:11:24,000 --> 00:11:30,000
Uh, it will be ensuring, uh, even though your application fails, it should be continuously working.

188
00:11:30,000 --> 00:11:36,000
And, uh, let's say that one individual agent encounters an error, right?

189
00:11:36,000 --> 00:11:37,000
Then.

190
00:11:37,000 --> 00:11:43,000
Also there will be some fault tolerance mechanism it will basically have wherein it will not just stop

191
00:11:43,000 --> 00:11:45,000
the application, but instead it will keep on running, right?

192
00:11:46,000 --> 00:11:52,000
So this is one of the very important core core feature that is reliability, right.

193
00:11:52,000 --> 00:11:54,000
Whenever we talk about reliability.

194
00:11:55,000 --> 00:12:00,000
So this was two important things we have discussed about the definition of land graph.

195
00:12:00,000 --> 00:12:01,000
We have discussed why land graph.

196
00:12:01,000 --> 00:12:07,000
Now it's time that I show you some of the amazing applications, how we can actually go ahead with the

197
00:12:07,000 --> 00:12:09,000
development here.

198
00:12:09,000 --> 00:12:13,000
What we are basically going to do is that we are going to create a chatbot, okay.

199
00:12:13,000 --> 00:12:17,000
And we'll try to create an agent, let's say in the form of chatbot.

200
00:12:17,000 --> 00:12:21,000
And again in the back, back side or right or in the back end.

201
00:12:21,000 --> 00:12:22,000
You'll be able to see that.

202
00:12:22,000 --> 00:12:27,000
We'll also be able to create a graph like how that entire agent specifically works.

203
00:12:27,000 --> 00:12:29,000
So quickly I will go ahead.

204
00:12:29,000 --> 00:12:31,000
And this I'm executing in the Google Colab.

205
00:12:31,000 --> 00:12:33,000
You can also go ahead and use it okay.

206
00:12:33,000 --> 00:12:37,000
So let's say that I will just use any of the GPU that I have.

207
00:12:37,000 --> 00:12:38,000
Okay.

208
00:12:38,000 --> 00:12:39,000
I will just go ahead and connect it.

209
00:12:40,000 --> 00:12:40,000
Anyhow.

210
00:12:40,000 --> 00:12:46,000
You don't require GPU in this, uh, but, uh, definitely we will be seeing that if you have any kind

211
00:12:46,000 --> 00:12:51,000
of, uh, if you if you require any kind of keys over here, and when I say that I'm going to create

212
00:12:51,000 --> 00:12:56,000
a chat bot, let me just go ahead and discuss about this architecture of the chat bot.

213
00:12:56,000 --> 00:12:58,000
So what I am going to create over here.

214
00:12:58,000 --> 00:12:58,000
Right.

215
00:12:58,000 --> 00:13:05,000
So let's say that, uh, there is a chat bot over here, this chat bot, I will try to create some kind

216
00:13:05,000 --> 00:13:06,000
of node.

217
00:13:06,000 --> 00:13:09,000
Let's say this will be my start node okay.

218
00:13:11,000 --> 00:13:19,000
Whenever any user query comes, you should be able to see that I will create a chat bot over here.

219
00:13:20,000 --> 00:13:25,000
This chat bot can basically interact with any LM models okay.

220
00:13:25,000 --> 00:13:32,000
And once it probably gives you the output we should end this entire flow.

221
00:13:32,000 --> 00:13:37,000
Okay, so the reason why I'm drawing this in the form of graph.

222
00:13:37,000 --> 00:13:43,000
Because land graph also does the same thing Okay, so line graph also creates the entire flow in the

223
00:13:43,000 --> 00:13:45,000
form of graph itself where you'll have nodes.

224
00:13:45,000 --> 00:13:50,000
And all right now there are two main important things when we see this.

225
00:13:50,000 --> 00:13:54,000
These are specifically nodes right start and end node.

226
00:13:54,000 --> 00:13:56,000
This chat bot is one node.

227
00:13:56,000 --> 00:14:01,000
And when I write chat bot that basically means it is having some kind of definition, right?

228
00:14:01,000 --> 00:14:07,000
If a chat bot needs to move from one step, let's say from one state to the other state, we basically

229
00:14:07,000 --> 00:14:12,000
call that as a state management, right?

230
00:14:12,000 --> 00:14:17,000
So probably after executing this the chat bot is moving towards the end state.

231
00:14:17,000 --> 00:14:19,000
So something is basically happening.

232
00:14:19,000 --> 00:14:20,000
So let's go ahead and create this.

233
00:14:20,000 --> 00:14:23,000
And then you'll be able to understand more about it okay.

234
00:14:23,000 --> 00:14:29,000
So first of all we will go ahead and install pip install lang graph.

235
00:14:29,000 --> 00:14:35,000
So we are going to specifically use lang graph lang graph okay.

236
00:14:35,000 --> 00:14:38,000
And we will also use lang Smith.

237
00:14:38,000 --> 00:14:40,000
So let's go ahead and execute this line.

238
00:14:40,000 --> 00:14:42,000
Smith I hope everybody knows what exactly is.

239
00:14:42,000 --> 00:14:47,000
So till then, I will also go ahead and show you the documentation of line graph.

240
00:14:47,000 --> 00:14:50,000
So this is what a line graph is all about right.

241
00:14:50,000 --> 00:14:52,000
It has Python.

242
00:14:52,000 --> 00:14:54,000
It has it supports JavaScript and all.

243
00:14:54,000 --> 00:15:00,000
But uh uh if I just go ahead and show you line graph tutorials.

244
00:15:00,000 --> 00:15:01,000
Right.

245
00:15:01,000 --> 00:15:04,000
So here you can see this is the tutorial.

246
00:15:04,000 --> 00:15:04,000
Right.

247
00:15:04,000 --> 00:15:06,000
And uh not this.

248
00:15:06,000 --> 00:15:07,000
Sorry.

249
00:15:07,000 --> 00:15:09,000
Uh let's see.

250
00:15:09,000 --> 00:15:09,000
Yes.

251
00:15:09,000 --> 00:15:10,000
Here you go.

252
00:15:11,000 --> 00:15:13,000
Right in the line graph page.

253
00:15:13,000 --> 00:15:15,000
It should be somewhere here.

254
00:15:15,000 --> 00:15:17,000
Or let me just go to lang chain.

255
00:15:18,000 --> 00:15:19,000
Lang chain.com.

256
00:15:20,000 --> 00:15:24,000
And here here is your line graph.

257
00:15:24,000 --> 00:15:25,000
Yes.

258
00:15:25,000 --> 00:15:29,000
So here you can actually see we will try to create this kind of nodes.

259
00:15:29,000 --> 00:15:29,000
Right.

260
00:15:29,000 --> 00:15:34,000
And I hope everybody has seen this kind of nodes specifically.

261
00:15:34,000 --> 00:15:34,000
Right.

262
00:15:34,000 --> 00:15:37,000
So what does Lang graph actually supports you to.

263
00:15:37,000 --> 00:15:37,000
too.

264
00:15:37,000 --> 00:15:41,000
It provides controllable cognitive architecture for any task.

265
00:15:41,000 --> 00:15:44,000
It is designed for human agent collaborations.

266
00:15:44,000 --> 00:15:44,000
All right.

267
00:15:44,000 --> 00:15:45,000
This kind of graphs.

268
00:15:45,000 --> 00:15:47,000
Also you'll be able to see all these things.

269
00:15:47,000 --> 00:15:49,000
I will try to show you in this video.

270
00:15:49,000 --> 00:15:56,000
So it has this fault tolerant scalability optimized for real world interaction and integrated developer

271
00:15:56,000 --> 00:15:57,000
experience.

272
00:15:57,000 --> 00:15:58,000
Amazing features.

273
00:15:58,000 --> 00:16:00,000
And I feel right.

274
00:16:00,000 --> 00:16:05,000
If you probably get the access of the beta server right, and you'll just be able to see the power of

275
00:16:05,000 --> 00:16:06,000
this.

276
00:16:06,000 --> 00:16:10,000
But at the end of the day, we will be creating some amazing agents, you know?

277
00:16:10,000 --> 00:16:14,000
So here you can see I have installed both the libraries Lang and Lang Smith.

278
00:16:14,000 --> 00:16:19,000
Now let's go ahead and start more things over here.

279
00:16:19,000 --> 00:16:26,000
Now as we go ahead we are also going to install Lang chain because we definitely require lang chain.

280
00:16:26,000 --> 00:16:30,000
And then we are going to use lang chain underscore grok.

281
00:16:30,000 --> 00:16:34,000
Along with this we are also going to use lang chain underscore community.

282
00:16:34,000 --> 00:16:34,000
Right.

283
00:16:34,000 --> 00:16:40,000
So these are all libraries will be specifically required in order to build our entire chatbot.

284
00:16:40,000 --> 00:16:40,000
Right.

285
00:16:40,000 --> 00:16:44,000
So here you can see the installation is basically taking place.

286
00:16:44,000 --> 00:16:45,000
Okay.

287
00:16:45,000 --> 00:16:46,000
Perfect.

288
00:16:47,000 --> 00:16:49,000
Now let's go ahead and import OS.

289
00:16:49,000 --> 00:16:56,000
Or what I will do is that I will right from Google Dot Colab okay.

290
00:16:56,000 --> 00:16:59,000
Import user data.

291
00:16:59,000 --> 00:16:59,000
Okay.

292
00:17:00,000 --> 00:17:07,000
Uh, now see, as you all know, when we worked specifically with VS code, you know, we used to create

293
00:17:07,000 --> 00:17:10,000
environment variables to access any keys.

294
00:17:10,000 --> 00:17:13,000
It can be grok API, it can be Lang Smith keys.

295
00:17:13,000 --> 00:17:18,000
Now similarly, with respect to Google Colab, whenever you are working with Google Colab here you can

296
00:17:18,000 --> 00:17:20,000
see one option.

297
00:17:20,000 --> 00:17:20,000
Here.

298
00:17:20,000 --> 00:17:23,000
You can actually go ahead and upload all your secret keys.

299
00:17:23,000 --> 00:17:28,000
Let's say if you want to use grok API, if you want to use open API, if you want to use Lang Smith

300
00:17:28,000 --> 00:17:33,000
API, if you want to use Hugging Face API, you can just go ahead and enter it over here.

301
00:17:33,000 --> 00:17:36,000
Add a new secret key and you can add the key and value pair.

302
00:17:36,000 --> 00:17:38,000
Okay, here is your password.

303
00:17:38,000 --> 00:17:39,000
Here is your key name.

304
00:17:39,000 --> 00:17:44,000
Now in order to access this key you can actually see that I have already uploaded it over here.

305
00:17:44,000 --> 00:17:44,000
Right.

306
00:17:45,000 --> 00:17:51,000
So let's say since I'm going to use a chatbot which will be interacting with my API.

307
00:17:51,000 --> 00:17:56,000
So if you don't know about grok API, you can just go over here and search for grok.com.

308
00:17:56,000 --> 00:18:00,000
Uh, when you go to grok.com you can sign it with your email ID.

309
00:18:00,000 --> 00:18:05,000
Let's say I'm going to sign it because it provides you free API to access the open source models, you

310
00:18:05,000 --> 00:18:06,000
know.

311
00:18:06,000 --> 00:18:08,000
So I will go to grok API over here.

312
00:18:08,000 --> 00:18:13,000
And here you'll be able to see that a lot of different different models are basically available right.

313
00:18:13,000 --> 00:18:15,000
Llama 3.1.

314
00:18:15,000 --> 00:18:17,000
You also have llama three.

315
00:18:17,000 --> 00:18:21,000
You have gamma 29B you have distilled whisper large V three encoding.

316
00:18:21,000 --> 00:18:24,000
Uh n so all these kind of models are there.

317
00:18:24,000 --> 00:18:25,000
You can specifically use this particular model.

318
00:18:26,000 --> 00:18:28,000
And I have already covered this in my previous videos.

319
00:18:28,000 --> 00:18:29,000
Okay.

320
00:18:29,000 --> 00:18:33,000
Now in this scenario, what I'm actually going to do, I will be using some APIs for this.

321
00:18:33,000 --> 00:18:40,000
So if I go and click on Start Building here, you can see that I will go to my Grok Cloud console.

322
00:18:40,000 --> 00:18:43,000
Then here you can go to API keys.

323
00:18:43,000 --> 00:18:47,000
Once you go to API keys you can probably create your own API key.

324
00:18:47,000 --> 00:18:49,000
I've created so many different API keys.

325
00:18:49,000 --> 00:18:52,000
Or you can go ahead and create your own API key, right?

326
00:18:52,000 --> 00:18:55,000
I've already shown that also in my previous videos.

327
00:18:55,000 --> 00:19:00,000
Once you create an API key, just go ahead and click over here, add a new secret key.

328
00:19:00,000 --> 00:19:03,000
Just go ahead and write grok underscore API key and put it over here.

329
00:19:03,000 --> 00:19:05,000
Write all the API keys itself.

330
00:19:06,000 --> 00:19:10,000
Now once you're able to add in the secret, the next thing is that I will try to read that particular

331
00:19:10,000 --> 00:19:13,000
API key in my Google Colab.

332
00:19:13,000 --> 00:19:17,000
So in order to read, I will go ahead and write from Google Colab, import user data.

333
00:19:17,000 --> 00:19:23,000
And let's say that I want my grok underscore API underscore key.

334
00:19:23,000 --> 00:19:29,000
I can just use this user data dot get grok API key.

335
00:19:29,000 --> 00:19:35,000
So if I go ahead and just print this, you'll be able to see that I'm actually able to read it.

336
00:19:35,000 --> 00:19:38,000
You know proc API underscore key.

337
00:19:38,000 --> 00:19:41,000
This is just to show you don't use this anyhow.

338
00:19:41,000 --> 00:19:43,000
Uh so here you can see it is Grant.

339
00:19:44,000 --> 00:19:48,000
It is asking should we access this particular secret name grok API key.

340
00:19:48,000 --> 00:19:54,000
The notebook title untitled 106. Ipy in B does not have access to secret name grant access.

341
00:19:54,000 --> 00:19:56,000
So if I click on grant access.

342
00:19:56,000 --> 00:19:57,000
But right now what happened?

343
00:19:57,000 --> 00:19:58,000
Timeout happened.

344
00:19:58,000 --> 00:19:58,000
Right.

345
00:19:58,000 --> 00:20:00,000
So I'll go ahead and execute it once again.

346
00:20:00,000 --> 00:20:03,000
And now you'll be able to access this right.

347
00:20:03,000 --> 00:20:05,000
So this is my grok API key that you are able to see.

348
00:20:05,000 --> 00:20:08,000
Perfect right.

349
00:20:08,000 --> 00:20:10,000
So now this grok API key I can actually use it.

350
00:20:10,000 --> 00:20:15,000
I can use it for creating my application anything that I want okay.

351
00:20:16,000 --> 00:20:21,000
Now once this is done what I'm actually going to do I'm also going to use Lang Smith okay.

352
00:20:21,000 --> 00:20:24,000
And I hope everybody knows what exactly is Lang Smith.

353
00:20:24,000 --> 00:20:24,000
Right.

354
00:20:24,000 --> 00:20:28,000
So here I will go ahead and write Lang Smith.

355
00:20:29,000 --> 00:20:31,000
Uh, Lang Smith actually helps you to.

356
00:20:31,000 --> 00:20:37,000
So if I go ahead and just do sign up right, it will be able to help you to track each and every information

357
00:20:37,000 --> 00:20:41,000
with respect to the interaction that you have actually created in your chatbot, right?

358
00:20:41,000 --> 00:20:47,000
So if you go to Lang Smith over here, here you also you'll be able to get the dashboard right.

359
00:20:47,000 --> 00:20:50,000
So I'll go to settings.

360
00:20:51,000 --> 00:20:52,000
Here is my API key.

361
00:20:52,000 --> 00:20:55,000
If you don't have an API key go ahead and create an API key.

362
00:20:55,000 --> 00:21:00,000
But if you go ahead and see my secret key I've already added that Lang Smith underscore API key.

363
00:21:00,000 --> 00:21:01,000
Okay.

364
00:21:03,000 --> 00:21:06,000
Now let's go ahead and read the Lang Smith key also.

365
00:21:06,000 --> 00:21:07,000
So I will go ahead and write.

366
00:21:07,000 --> 00:21:13,000
Lang Smith is equal to user data dot get.

367
00:21:13,000 --> 00:21:20,000
And here also I'm going to use Lang Smith Lang Smith.

368
00:21:20,000 --> 00:21:22,000
Let's see what is the key name.

369
00:21:26,000 --> 00:21:27,000
Okay.

370
00:21:29,000 --> 00:21:33,000
so I will just go ahead and print my Lange Smith.

371
00:21:34,000 --> 00:21:35,000
Okay.

372
00:21:36,000 --> 00:21:40,000
So here you will be able to see that I will also be able to get it.

373
00:21:40,000 --> 00:21:41,000
So it will ask for grant access.

374
00:21:41,000 --> 00:21:43,000
I will give the grant access over here.

375
00:21:43,000 --> 00:21:45,000
And it should be able to display it.

376
00:21:45,000 --> 00:21:47,000
And it is displaying a f.

377
00:21:47,000 --> 00:21:48,000
E is the last term.

378
00:21:48,000 --> 00:21:49,000
F is also over here.

379
00:21:50,000 --> 00:21:53,000
So I have read both this particular key and both.

380
00:21:53,000 --> 00:21:57,000
This key will be specifically used for creating my chatbot application.

381
00:21:57,000 --> 00:22:01,000
Lange Smith will be specifically used for tracking everything that is basically happening over here.

382
00:22:02,000 --> 00:22:05,000
Now the next thing will be that I will go ahead and import OS.

383
00:22:06,000 --> 00:22:09,000
Then let's go ahead and import OS dot environ.

384
00:22:09,000 --> 00:22:12,000
I will just go ahead and keep save all these things right.

385
00:22:12,000 --> 00:22:20,000
So first of all I need Lange chain or sorry Lange Smith API key okay I can also go ahead and write Lange

386
00:22:20,000 --> 00:22:20,000
Smith.

387
00:22:20,000 --> 00:22:24,000
Or I can also go ahead and write Lange chain API key.

388
00:22:24,000 --> 00:22:27,000
So let's go ahead and do this Lange chain an API key.

389
00:22:27,000 --> 00:22:30,000
I will set this to my lamb-smith.

390
00:22:30,000 --> 00:22:34,000
Okay, we need to set up this specific key itself.

391
00:22:34,000 --> 00:22:34,000
Okay.

392
00:22:35,000 --> 00:22:38,000
Um, then my end point end point is specifically not required.

393
00:22:38,000 --> 00:22:41,000
I will just go ahead and copy this.

394
00:22:41,000 --> 00:22:42,000
Two things.

395
00:22:42,000 --> 00:22:45,000
And this is basically just used to set up the basic requirements.

396
00:22:45,000 --> 00:22:45,000
Right.

397
00:22:45,000 --> 00:22:48,000
Like chain tracing V2 and Lang chain project okay.

398
00:22:48,000 --> 00:22:54,000
So let's say this will basically be my course lang graph okay.

399
00:22:54,000 --> 00:22:56,000
So this is what is my project name that I'm actually writing.

400
00:22:57,000 --> 00:23:02,000
I'm saying that hey, we need to make sure that you need to keep the tracing underscore v2 as true.

401
00:23:02,000 --> 00:23:06,000
And lang lang chain API key is nothing, but it is assigned to lang with API key.

402
00:23:06,000 --> 00:23:09,000
Now you may be thinking, Chris, why did you use lang chain underscore API key?

403
00:23:09,000 --> 00:23:11,000
No, you can also use Lang Smith.

404
00:23:11,000 --> 00:23:14,000
But according to our documentation, when I saw both of them were satisfied.

405
00:23:14,000 --> 00:23:17,000
So I just used lang chain underscore API key.

406
00:23:17,000 --> 00:23:19,000
So let's go ahead and execute this.

407
00:23:20,000 --> 00:23:24,000
So once this is executed you'll be able to see all the information over here.

408
00:23:24,000 --> 00:23:33,000
Now quickly let's go ahead and write from long chain underscore grok import Chad grok because I need

409
00:23:33,000 --> 00:23:35,000
to use the Chad grant open source models.

410
00:23:35,000 --> 00:23:36,000
Okay.

411
00:23:36,000 --> 00:23:38,000
Now this is done.

412
00:23:38,000 --> 00:23:42,000
Now I will go ahead and create my LM model, which is nothing but Chad Grok.

413
00:23:42,000 --> 00:23:50,000
And inside this I will be using my grok underscore API underscore key which is equal to grok API key.

414
00:23:51,000 --> 00:23:54,000
And my model underscore name will be nothing.

415
00:23:54,000 --> 00:23:57,000
But you can use multiple models any models that you want.

416
00:23:57,000 --> 00:24:00,000
So in the grok cloud I can see there is llama 3.1.

417
00:24:00,000 --> 00:24:04,000
Anything that you want I will just go ahead and use this gamma two nine be it.

418
00:24:04,000 --> 00:24:05,000
Okay.

419
00:24:05,000 --> 00:24:08,000
So this specific model I will go ahead and use it.

420
00:24:08,000 --> 00:24:09,000
It is up to you now.

421
00:24:09,000 --> 00:24:12,000
Nothing compulsory which model you really need to use.

422
00:24:12,000 --> 00:24:15,000
You can use any model that is provided by grok right.

423
00:24:15,000 --> 00:24:16,000
So this is done.

424
00:24:16,000 --> 00:24:19,000
This is my LM model okay.

425
00:24:21,000 --> 00:24:23,000
Now the next step will be that.

426
00:24:23,000 --> 00:24:26,000
Now here you can see here I'm able to access all the models.

427
00:24:26,000 --> 00:24:28,000
I'm able to access the model gamma two nine.

428
00:24:28,000 --> 00:24:29,000
Be it.

429
00:24:29,000 --> 00:24:39,000
Okay, now it's time we start building a chat bot using line graph.

430
00:24:39,000 --> 00:24:40,000
Right.

431
00:24:40,000 --> 00:24:43,000
So here is what we are going to basically start.

432
00:24:43,000 --> 00:24:45,000
And this is the most important thing right.

433
00:24:45,000 --> 00:24:47,000
So if I probably go ahead and say this okay.

434
00:24:48,000 --> 00:24:55,000
So first of all uh understand there are multiple things which we really need to start with the importing

435
00:24:55,000 --> 00:24:55,000
part.

436
00:24:55,000 --> 00:24:56,000
Okay.

437
00:24:56,000 --> 00:25:00,000
So first of all I will be importing something called as annotated.

438
00:25:00,000 --> 00:25:01,000
Right.

439
00:25:01,000 --> 00:25:06,000
So from typing I will be importing annotated from typing extension I will be importing type dict.

440
00:25:06,000 --> 00:25:06,000
Okay.

441
00:25:07,000 --> 00:25:13,000
Uh along with this I will be importing two important libraries from Lang graph.

442
00:25:13,000 --> 00:25:19,000
So I will go ahead and right from lang graph, uh you'll understand why this importing is done just

443
00:25:19,000 --> 00:25:20,000
in some time.

444
00:25:20,000 --> 00:25:20,000
Okay.

445
00:25:20,000 --> 00:25:21,000
From lang graph.

446
00:25:21,000 --> 00:25:23,000
dot graph.

447
00:25:23,000 --> 00:25:27,000
Okay I'm going to just go ahead and import two things.

448
00:25:27,000 --> 00:25:29,000
One is state graph.

449
00:25:29,000 --> 00:25:33,000
State graph actually helps you to manage the entire state management.

450
00:25:33,000 --> 00:25:38,000
Then your start node start node and your end node.

451
00:25:38,000 --> 00:25:38,000
Right.

452
00:25:38,000 --> 00:25:44,000
You remember that I actually created a diagram right where we had a start node.

453
00:25:44,000 --> 00:25:50,000
Then we had an end node which actually, uh, shows the flow of the entire chatbot itself.

454
00:25:50,000 --> 00:25:51,000
Okay.

455
00:25:51,000 --> 00:25:55,000
Along with this, uh, I will also be showing like this.

456
00:25:55,000 --> 00:25:58,000
See, the state graph is basically used for the state management purpose.

457
00:25:59,000 --> 00:26:04,000
Now the state graph needs to keep on changing based on some parameters.

458
00:26:04,000 --> 00:26:05,000
Okay.

459
00:26:05,000 --> 00:26:15,000
So for that what I will be doing I will go ahead and write from line graph, line graph dot graph dot

460
00:26:15,000 --> 00:26:18,000
messages message.

461
00:26:18,000 --> 00:26:22,000
I'm just going to go ahead and import add underscore messages.

462
00:26:22,000 --> 00:26:23,000
Okay.

463
00:26:23,000 --> 00:26:25,000
Now this is one of the function.

464
00:26:25,000 --> 00:26:29,000
What it does is that we have this something called as messages right.

465
00:26:29,000 --> 00:26:35,000
As we keep on adding the messages over here, we will be able to see that our state management, our

466
00:26:35,000 --> 00:26:37,000
state of the agent will keep on changing.

467
00:26:38,000 --> 00:26:43,000
Now this messages is just like you can understand like a when a user is giving a query, the LM model

468
00:26:43,000 --> 00:26:44,000
is giving a response.

469
00:26:44,000 --> 00:26:48,000
When it is giving a response, the message will get added over here.

470
00:26:48,000 --> 00:26:51,000
And then my state of the chatbot will also get changed.

471
00:26:51,000 --> 00:26:52,000
Right.

472
00:26:52,000 --> 00:26:55,000
So this messages is basically keeping track of all those things.

473
00:26:55,000 --> 00:26:56,000
Okay.

474
00:26:56,000 --> 00:26:58,000
So now let's go ahead and execute this.

475
00:26:58,000 --> 00:27:01,000
So this has got executed successfully.

476
00:27:01,000 --> 00:27:04,000
You can understand each and every thing I have actually explained.

477
00:27:04,000 --> 00:27:07,000
We will talk about this two right just in some time.

478
00:27:08,000 --> 00:27:11,000
Now we will go ahead and create our own class.

479
00:27:11,000 --> 00:27:18,000
Let's say this is my class state which will be uh, making sure to, uh, properly control the entire

480
00:27:18,000 --> 00:27:19,000
state management.

481
00:27:19,000 --> 00:27:23,000
Here I will go ahead and write typed dict.

482
00:27:23,000 --> 00:27:23,000
Okay.

483
00:27:24,000 --> 00:27:28,000
So I will go ahead and write typed dict typed dict.

484
00:27:28,000 --> 00:27:29,000
Okay.

485
00:27:31,000 --> 00:27:32,000
Typed dict okay.

486
00:27:32,000 --> 00:27:38,000
So this class is basically inheriting this particular type of dict.

487
00:27:38,000 --> 00:27:39,000
Okay.

488
00:27:39,000 --> 00:27:41,000
Now what we will do.

489
00:27:41,000 --> 00:27:44,000
We will go ahead and write some comments over here.

490
00:27:44,000 --> 00:27:44,000
Okay.

491
00:27:44,000 --> 00:27:48,000
So that you'll be able to understand messages that have the type list.

492
00:27:48,000 --> 00:27:54,000
The add message function in the annotation defines how this state key should be updated.

493
00:27:54,000 --> 00:27:57,000
It appends the message to the list rather than overwriting.

494
00:27:57,000 --> 00:28:01,000
So inside this class I've created a variable called as messages.

495
00:28:01,000 --> 00:28:01,000
Okay.

496
00:28:01,000 --> 00:28:05,000
And this messages is of type annotated.

497
00:28:05,000 --> 00:28:08,000
And this annotated is basically saying hey it is a list type.

498
00:28:08,000 --> 00:28:11,000
And here I'm using this function called as add messages.

499
00:28:11,000 --> 00:28:18,000
This add messages will be responsible on adding or appending the messages to this list okay.

500
00:28:18,000 --> 00:28:23,000
Which is basically created in the form of list in this messages variable, and it will not override

501
00:28:23,000 --> 00:28:23,000
them.

502
00:28:23,000 --> 00:28:27,000
The entire state management will be controlled as we keep on adding this particular messages, because

503
00:28:28,000 --> 00:28:30,000
on every add we will be changing our state.

504
00:28:30,000 --> 00:28:31,000
Okay.

505
00:28:32,000 --> 00:28:38,000
Now the next thing that we will go ahead and define, since I have defined my class state, I will go

506
00:28:38,000 --> 00:28:41,000
ahead and write my graph builder.

507
00:28:41,000 --> 00:28:41,000
Okay.

508
00:28:41,000 --> 00:28:43,000
I will go ahead and define my graph builder.

509
00:28:43,000 --> 00:28:47,000
So this is what we start our graph building process.

510
00:28:47,000 --> 00:28:52,000
So here I'm going to use state graph the state graph which I have actually imported it over here.

511
00:28:52,000 --> 00:28:58,000
And this state graph will have this particular class which is called as state because this state knows

512
00:28:58,000 --> 00:29:02,000
which messages are there, what messages are basically getting appended.

513
00:29:02,000 --> 00:29:06,000
And this graph builder should be responsible in managing the entire state management.

514
00:29:06,000 --> 00:29:06,000
Right.

515
00:29:06,000 --> 00:29:10,000
So once I execute this here is my graph builder.

516
00:29:10,000 --> 00:29:12,000
So let me just go ahead and execute this.

517
00:29:12,000 --> 00:29:15,000
So this is my graph builder over here right.

518
00:29:15,000 --> 00:29:18,000
So here you can see line graph dot graph dot state.

519
00:29:18,000 --> 00:29:21,000
State graph at this specific location.

520
00:29:21,000 --> 00:29:27,000
So guys now after we have created the graph builder uh what we are basically going to do is that uh

521
00:29:27,000 --> 00:29:29,000
already in this diagram you saw that right.

522
00:29:29,000 --> 00:29:31,000
We are going to create this chat bot.

523
00:29:31,000 --> 00:29:34,000
Now this chat bot should be interacting with our LLM.

524
00:29:34,000 --> 00:29:36,000
So for this we will go ahead and write some definition.

525
00:29:37,000 --> 00:29:43,000
So let's quickly go ahead and create a function definition chat bot.

526
00:29:43,000 --> 00:29:51,000
And remember whenever we are creating any node right in this entire graph builder, it needs to take

527
00:29:51,000 --> 00:29:53,000
the parameter as state.

528
00:29:53,000 --> 00:29:55,000
Okay, whatever state we are giving over here.

529
00:29:56,000 --> 00:30:02,000
And this will be important because the reason is very simple because based on this state message, right.

530
00:30:02,000 --> 00:30:07,000
Whatever messages, whatever interaction that we are doing, the state management will keep on changing.

531
00:30:07,000 --> 00:30:12,000
So here we go ahead and define this chat bot where we take the parameter as state.

532
00:30:12,000 --> 00:30:14,000
And then we return.

533
00:30:14,000 --> 00:30:20,000
You know that after any response that we get from the chatbot, we need to update this messages variable.

534
00:30:20,000 --> 00:30:24,000
So here I will go ahead and create this messages.

535
00:30:24,000 --> 00:30:28,000
And here I will just go ahead and write LM dot invoke.

536
00:30:28,000 --> 00:30:28,000
Okay.

537
00:30:28,000 --> 00:30:36,000
And this invoke will be specifically invoking from the state message which will have the user queries.

538
00:30:36,000 --> 00:30:36,000
Right.

539
00:30:36,000 --> 00:30:41,000
So whenever a user queries you will be able to see that this messages will get appended in this particular

540
00:30:41,000 --> 00:30:42,000
message variable.

541
00:30:42,000 --> 00:30:45,000
And once it does that we are just going to invoke that.

542
00:30:45,000 --> 00:30:49,000
And whatever response we are getting it we are again appending it over here.

543
00:30:49,000 --> 00:30:49,000
Right?

544
00:30:49,000 --> 00:30:51,000
Or we are putting in this particular value.

545
00:30:51,000 --> 00:30:54,000
We are returning this entire in this particular format.

546
00:30:54,000 --> 00:30:57,000
When we return this when we are inheriting the state class.

547
00:30:57,000 --> 00:30:58,000
Right.

548
00:30:58,000 --> 00:31:03,000
It is going to understand, hey, whenever we return this kind of message, it is going to trigger this

549
00:31:03,000 --> 00:31:06,000
add message and it is going to add this in this messages variable.

550
00:31:06,000 --> 00:31:07,000
Okay.

551
00:31:07,000 --> 00:31:13,000
So just understand in this way is that here I have a chatbot function which is invoking the previous

552
00:31:13,000 --> 00:31:18,000
messages given by the user, and we are returning some kind of messages over here.

553
00:31:18,000 --> 00:31:22,000
Okay, so once we execute this I will be getting my chat bot.

554
00:31:22,000 --> 00:31:26,000
Now this chat bot needs to get added in this graph builder.

555
00:31:26,000 --> 00:31:33,000
So here I will go ahead and write graph underscore builder dot add underscore node.

556
00:31:33,000 --> 00:31:40,000
And here I'm going to specifically use chat bot as my node name which will have the functionality of

557
00:31:40,000 --> 00:31:42,000
this particular chat bot.

558
00:31:42,000 --> 00:31:42,000
Okay.

559
00:31:42,000 --> 00:31:47,000
So once I execute this you'll be able to see that this entire node is basically getting added.

560
00:31:47,000 --> 00:31:53,000
So now if I go ahead and just display this you'll not be able to see much things over here.

561
00:31:53,000 --> 00:31:56,000
But we will be seeing the entire diagram.

562
00:31:56,000 --> 00:32:01,000
So step by step you can see that what we have done first of all we have created this class state.

563
00:32:01,000 --> 00:32:03,000
Then we have created our graph builder.

564
00:32:03,000 --> 00:32:06,000
Then we have defined our chatbot.

565
00:32:06,000 --> 00:32:09,000
What functionality is basically doing and what it is returning.

566
00:32:09,000 --> 00:32:10,000
It is returning.

567
00:32:10,000 --> 00:32:13,000
Just message colon some some output that we are getting over here.

568
00:32:13,000 --> 00:32:14,000
Right?

569
00:32:14,000 --> 00:32:17,000
And remember, the chat bot is inheriting the state class.

570
00:32:17,000 --> 00:32:21,000
And the state class has one variable messages in the form of list.

571
00:32:21,000 --> 00:32:27,000
And there is a function called as add underscore message, which will keep on appending whatever message

572
00:32:27,000 --> 00:32:29,000
we are specifically getting over here.

573
00:32:29,000 --> 00:32:29,000
Right.

574
00:32:29,000 --> 00:32:31,000
So that is what it is basically doing.

575
00:32:32,000 --> 00:32:38,000
Now since we have created this graph builder, now it's time that we connect this chatbot to the start

576
00:32:38,000 --> 00:32:39,000
and the end node okay.

577
00:32:40,000 --> 00:32:46,000
So here I'm going to go ahead and write Graph Builder dot add edge okay.

578
00:32:46,000 --> 00:32:48,000
So add edge start chatbot.

579
00:32:48,000 --> 00:32:49,000
Okay.

580
00:32:49,000 --> 00:32:52,000
So we are basically going to add the start and the chatbot.

581
00:32:52,000 --> 00:32:55,000
And similarly we are going to add chatbot till the end.

582
00:32:55,000 --> 00:32:56,000
Right.

583
00:32:56,000 --> 00:33:01,000
So then only we will be able to find out or will be able to get this kind of flow.

584
00:33:01,000 --> 00:33:03,000
So start is basically appended with chatbot.

585
00:33:03,000 --> 00:33:09,000
And chatbot is basically getting appended with end start basically means whenever we get a user query

586
00:33:09,000 --> 00:33:13,000
it will just start the process, then chatbot will do the interaction with LLM.

587
00:33:13,000 --> 00:33:18,000
It will give us the value and it will go to the end state and how the state management basically happening

588
00:33:18,000 --> 00:33:22,000
because of this state class, which we have inherited in Graph Builder.

589
00:33:22,000 --> 00:33:23,000
Okay.

590
00:33:23,000 --> 00:33:26,000
So once we execute this, this is done.

591
00:33:27,000 --> 00:33:32,000
So finally what we do after creating this, after adding all this nodes we go ahead and write Graph

592
00:33:32,000 --> 00:33:33,000
Builder.

593
00:33:34,000 --> 00:33:35,000
We need to compile it.

594
00:33:35,000 --> 00:33:38,000
So we'll go ahead and write dot compile.

595
00:33:38,000 --> 00:33:41,000
So once we compile it we'll be getting our entire graph ready.

596
00:33:41,000 --> 00:33:44,000
So here is my graph itself.

597
00:33:44,000 --> 00:33:47,000
So once I execute this my graph is ready.

598
00:33:47,000 --> 00:33:49,000
Now let me just go ahead and display this.

599
00:33:49,000 --> 00:33:55,000
So in order to display this in the documentation I saw this code where they are importing this image

600
00:33:55,000 --> 00:33:55,000
and display.

601
00:33:55,000 --> 00:33:58,000
And there is something called as graph dot get graph.

602
00:33:58,000 --> 00:34:03,000
So here instead of graph I will write graph builder okay or sorry.

603
00:34:04,000 --> 00:34:05,000
It should be graph only because we have compiled it.

604
00:34:05,000 --> 00:34:12,000
Get graph draw mermaid png okay so once I execute this, you'll be able to see that I'll be getting

605
00:34:12,000 --> 00:34:13,000
this entire flow.

606
00:34:13,000 --> 00:34:21,000
So start and end are just like one private, uh, functions that are present inside the, uh, state.

607
00:34:21,000 --> 00:34:22,000
State?

608
00:34:22,000 --> 00:34:26,000
Uh, if I probably say this particular class, the state graph class.

609
00:34:26,000 --> 00:34:27,000
Right.

610
00:34:27,000 --> 00:34:31,000
Uh, which is present inside this line graph, dot graph, lang lang graph or graph.

611
00:34:31,000 --> 00:34:32,000
Right.

612
00:34:32,000 --> 00:34:37,000
And now this will basically as soon as the user queries we will go to the start state.

613
00:34:37,000 --> 00:34:38,000
Then it goes to the chat bot.

614
00:34:38,000 --> 00:34:40,000
Here the interaction will basically happen.

615
00:34:40,000 --> 00:34:43,000
And once the interaction happens the state should change right?

616
00:34:44,000 --> 00:34:46,000
Once we get the response it will go to the end state.

617
00:34:46,000 --> 00:34:49,000
Now let's go ahead and execute this.

618
00:34:49,000 --> 00:34:50,000
And then only you'll be able to see the output.

619
00:34:50,000 --> 00:34:51,000
Okay.

620
00:34:51,000 --> 00:34:53,000
Uh and we are just going to start this.

621
00:34:53,000 --> 00:34:54,000
Okay.

622
00:34:54,000 --> 00:34:56,000
So here I will just go ahead and write.

623
00:34:56,000 --> 00:35:04,000
While true user underscore input is equal to input

624
00:35:07,000 --> 00:35:11,000
User input user.

625
00:35:11,000 --> 00:35:20,000
And here I'm going to just go ahead and write f user underscore input dot lower in.

626
00:35:22,000 --> 00:35:29,000
Let's say I will go ahead and say hey if you are just going and typing in quit or Q right.

627
00:35:29,000 --> 00:35:32,000
You're just going to stop the conversation with the flow, right?

628
00:35:32,000 --> 00:35:34,000
So here I'm just going to write print.

629
00:35:36,000 --> 00:35:37,000
Goodbye.

630
00:35:38,000 --> 00:35:38,000
Okay.

631
00:35:39,000 --> 00:35:42,000
And then we are just going to break from here.

632
00:35:42,000 --> 00:35:42,000
Okay.

633
00:35:43,000 --> 00:35:46,000
But if the user inputs something else.

634
00:35:46,000 --> 00:35:51,000
So here I will go ahead and write for event in graph dot stream.

635
00:35:51,000 --> 00:35:52,000
Okay.

636
00:35:52,000 --> 00:35:53,000
We are just going to stream.

637
00:35:53,000 --> 00:35:59,000
And here we are going to use this messages as my key variable messages is a colon.

638
00:35:59,000 --> 00:36:02,000
And here I'm going to give based on user.

639
00:36:02,000 --> 00:36:03,000
See.

640
00:36:03,000 --> 00:36:09,000
Initially whenever a user gives a input message I need to set this as user right as the parameter,

641
00:36:09,000 --> 00:36:12,000
and here will basically be my user input.

642
00:36:12,000 --> 00:36:20,000
Okay, then I will go ahead and write print event dot values.

643
00:36:21,000 --> 00:36:22,000
We are just going to print the values.

644
00:36:22,000 --> 00:36:28,000
Then here more we can go ahead and probably convert this or explore these values.

645
00:36:28,000 --> 00:36:33,000
So here I will write for value in event dot values print value.

646
00:36:33,000 --> 00:36:37,000
And inside that value there will be a key which is called as message messages.

647
00:36:37,000 --> 00:36:38,000
Okay.

648
00:36:38,000 --> 00:36:42,000
And then we will go ahead and print our assistant.

649
00:36:42,000 --> 00:36:51,000
Message assistant basically means the message that is basically coming from our uh LMS.

650
00:36:51,000 --> 00:36:58,000
So here you will be able to see value messages dot content.

651
00:36:59,000 --> 00:37:01,000
So here let's explore this code.

652
00:37:01,000 --> 00:37:03,000
First of all a user is giving an input.

653
00:37:03,000 --> 00:37:08,000
If it is not giving given, quit and Q so it will go to graph dot stream with respect to all the messages

654
00:37:08,000 --> 00:37:10,000
that users have already given.

655
00:37:10,000 --> 00:37:13,000
Then we are going to get that event dot values for value.

656
00:37:13,000 --> 00:37:14,000
We are going to get two important things.

657
00:37:14,000 --> 00:37:18,000
One is value of messages and one is the value of message of content.

658
00:37:18,000 --> 00:37:22,000
So this value of messages I think it should have the user message.

659
00:37:22,000 --> 00:37:25,000
And this should have the LM model response response.

660
00:37:25,000 --> 00:37:27,000
So let me go ahead and execute it.

661
00:37:28,000 --> 00:37:30,000
So I will go ahead and write hello.

662
00:37:31,000 --> 00:37:31,000
Let's see.

663
00:37:32,000 --> 00:37:34,000
So here assistant you can see right.

664
00:37:34,000 --> 00:37:34,000
Hello.

665
00:37:34,000 --> 00:37:38,000
How can I help you see all these messages are basically coming in the form of big value right.

666
00:37:38,000 --> 00:37:39,000
So here.

667
00:37:39,000 --> 00:37:40,000
Hello.

668
00:37:40,000 --> 00:37:41,000
How can I help you?

669
00:37:41,000 --> 00:37:42,000
Today is the response.

670
00:37:42,000 --> 00:37:43,000
And I'm able to get it.

671
00:37:43,000 --> 00:37:48,000
So let me go and ask what is generative AI right.

672
00:37:48,000 --> 00:37:53,000
So here you will be able to see that all the response is there right.

673
00:37:53,000 --> 00:37:55,000
Generative AI is a type of artificial intelligence.

674
00:37:55,000 --> 00:37:56,000
Think of it.

675
00:37:56,000 --> 00:37:57,000
So it's amazing right?

676
00:37:57,000 --> 00:37:59,000
You are able to get the entire response.

677
00:38:00,000 --> 00:38:03,000
And here also you can see response metadata content is over here.

678
00:38:03,000 --> 00:38:08,000
So if you just go ahead and explore this, some of the other keys will be available over here.

679
00:38:08,000 --> 00:38:08,000
Right.

680
00:38:08,000 --> 00:38:13,000
And uh, uh, if you go ahead and see down.

681
00:38:13,000 --> 00:38:15,000
So this is my entire generated message.

682
00:38:15,000 --> 00:38:20,000
So if I just go ahead and write Q it should be exiting over here.

683
00:38:20,000 --> 00:38:20,000
Right.

684
00:38:20,000 --> 00:38:22,000
So here you can see it says goodbye.

685
00:38:22,000 --> 00:38:25,000
So guys, I hope you liked this specific video.

686
00:38:25,000 --> 00:38:31,000
And you were able to understand how to basically create a simple chatbot in the form of Lang with the

687
00:38:31,000 --> 00:38:33,000
help of Lang graph.

688
00:38:33,000 --> 00:38:38,000
And here we have basically used the graph itself right from start till the end node.

689
00:38:38,000 --> 00:38:44,000
We have understood that whenever we create any node, it also needs to have a definition and uh, how

690
00:38:44,000 --> 00:38:46,000
we can connect each and every node.

691
00:38:46,000 --> 00:38:52,000
Now in the upcoming videos we are going to develop more complex projects on Lang graph where we will

692
00:38:52,000 --> 00:38:54,000
be using external tools.

693
00:38:54,000 --> 00:38:59,000
Uh, there will just not use one node, but there will be multiple nodes as we go ahead.

694
00:38:59,000 --> 00:39:00,000
So I hope you like this particular video.

695
00:39:00,000 --> 00:39:02,000
I will see you all in the next video.

696
00:39:02,000 --> 00:39:02,000
Thank you.

