WEBVTT

00:00.630 --> 00:01.920
Eden: Hey, there, Eden here.

00:01.920 --> 00:04.320
And in this video, we're going to cover,

00:04.320 --> 00:06.630
from the theoretical point of view,

00:06.630 --> 00:09.210
the core components of LangGraph.

00:09.210 --> 00:10.800
And this is super important

00:10.800 --> 00:12.720
because right after this video, we're going

00:12.720 --> 00:16.623
to start implementing project using those components.

00:18.870 --> 00:20.700
Alright, so with LangGraph, we're going

00:20.700 --> 00:23.700
to be implementing a well-defined control flow

00:23.700 --> 00:25.740
or a state machine or a graph.

00:25.740 --> 00:27.570
You can call it whatever you want.

00:27.570 --> 00:30.960
But the basic idea here is that within this well-defined

00:30.960 --> 00:33.240
and well scoped control flow, we're going

00:33.240 --> 00:34.890
to be leveraging LLMs

00:34.890 --> 00:37.440
and they're going to have a very crucial role.

00:37.440 --> 00:41.010
So LLMs are either going to define in the control flow

00:41.010 --> 00:42.510
where we're going to go next.

00:42.510 --> 00:45.030
So this is going to be non-deterministic,

00:45.030 --> 00:47.400
or we can even, in this control flow,

00:47.400 --> 00:50.310
execute LLM calls or agent calls.

00:50.310 --> 00:53.940
And to get started, we need three LangGraph core components:

00:53.940 --> 00:57.000
nodes, edges, and conditional edges.

00:57.000 --> 00:59.580
Nodes are literally python functions.

00:59.580 --> 01:02.190
So you can put here any code you want.

01:02.190 --> 01:05.550
This code can be deterministic code, regular Python code,

01:05.550 --> 01:08.190
it can be Python code that calls an LLM,

01:08.190 --> 01:10.860
or it can even be an LLM agent.

01:10.860 --> 01:14.130
But you have full flexibility of what you want to do

01:14.130 --> 01:15.750
inside the nodes.

01:15.750 --> 01:19.290
Edges connect those nodes within the graphs execution

01:19.290 --> 01:22.230
and conditional edges are helped to make decisions

01:22.230 --> 01:24.960
whether to go to node A or to node B,

01:24.960 --> 01:28.230
and this is dynamic and can be very, very flexible.

01:28.230 --> 01:30.930
And this is the power of LangGraph.

01:30.930 --> 01:33.780
So we have full control of how we're going

01:33.780 --> 01:36.513
to navigate in this graph execution.

01:38.640 --> 01:42.330
Cool. Two important built-in LangGraph nodes

01:42.330 --> 01:45.180
are the start node and the end node.

01:45.180 --> 01:47.580
And the start node is the entry point

01:47.580 --> 01:49.470
for our graph execution.

01:49.470 --> 01:51.720
So we're going to start from there

01:51.720 --> 01:54.300
and the end node is going to be the last node

01:54.300 --> 01:56.370
that is going to be executed.

01:56.370 --> 01:59.190
And both of those nodes don't really do anything.

01:59.190 --> 02:02.373
So you can think about them as no operation.

02:06.420 --> 02:09.240
One of the most important concepts in LangGraph

02:09.240 --> 02:11.850
is the state or the agent state.

02:11.850 --> 02:14.820
And the state is simply a dictionary

02:14.820 --> 02:16.890
that is going to have information

02:16.890 --> 02:19.740
that is important for us to keep tracking the graph.

02:19.740 --> 02:22.230
Maybe some nodes execution results,

02:22.230 --> 02:26.430
maybe some temporary results or even our chat history.

02:26.430 --> 02:29.910
It can be fairly simple like only storing the chat history,

02:29.910 --> 02:33.300
so the results of the LLMs every time,

02:33.300 --> 02:35.100
or it could be very complex

02:35.100 --> 02:37.953
and we can customize it to anything we want.

02:39.240 --> 02:42.450
It is local to the graph that is it is available

02:42.450 --> 02:46.140
for every node to access within our graph's execution.

02:46.140 --> 02:51.120
And it is also available on each edge and it can be local.

02:51.120 --> 02:54.450
So within our graph execution in our runtime.

02:54.450 --> 02:58.530
However, we can also persist it into persistent storage.

02:58.530 --> 03:02.310
So if you want to stop for some reason, the flow execution

03:02.310 --> 03:05.280
of the graph and we want to continue from that same point

03:05.280 --> 03:08.400
with that given state, we can do it with persistence

03:08.400 --> 03:10.830
and we're going to show you that in the course.

03:10.830 --> 03:13.170
Alright, so remember that I told you

03:13.170 --> 03:16.500
that every node in LangGraph is a function

03:16.500 --> 03:18.870
and we can write there whatever we want.

03:18.870 --> 03:20.160
This is still the case,

03:20.160 --> 03:22.590
but nodes are special functions

03:22.590 --> 03:24.840
that always receive as an input,

03:24.840 --> 03:27.180
the current graph state, which is going

03:27.180 --> 03:29.790
to have all the information that the node needs

03:29.790 --> 03:32.310
in order to do its work.

03:32.310 --> 03:35.040
And what this function returns the node function,

03:35.040 --> 03:39.360
it's updating the state, so it always returns a dictionary

03:39.360 --> 03:43.233
with the keys of what do we want to update in our state.

03:44.820 --> 03:48.420
And the result of this is that in LangGraph,

03:48.420 --> 03:50.460
every node is going to update the state.

03:50.460 --> 03:53.730
So the state object is going to change over time

03:53.730 --> 03:56.430
and the conditional edges and the edges

03:56.430 --> 03:58.050
are going to rely on the states

03:58.050 --> 04:01.260
whether to go to node A or to node B.

04:01.260 --> 04:04.050
And this is how our software is going to look like.

04:04.050 --> 04:06.270
So with these core components,

04:06.270 --> 04:08.793
we can build very advanced things.

04:10.710 --> 04:14.460
Alright, so more concepts that are important for the rest

04:14.460 --> 04:17.820
of the course is, first, a cyclic graph.

04:17.820 --> 04:21.030
So with LangGraph, we can also implement loops

04:21.030 --> 04:25.080
and this is very powerful, which is something that

04:25.080 --> 04:27.210
with LangChain was super hard to do,

04:27.210 --> 04:30.720
and we're going to later discuss this in the course.

04:30.720 --> 04:32.220
Also human in the loop.

04:32.220 --> 04:35.220
So if we want to get human feedback

04:35.220 --> 04:38.160
and this will decide where do we need to go

04:38.160 --> 04:42.180
in the graph's execution, so to node A or to node B,

04:42.180 --> 04:43.650
then this is also something

04:43.650 --> 04:47.430
that LangGraph also helps us to easily implement.

04:47.430 --> 04:50.940
And the last thing is persistence, which I mentioned it.

04:50.940 --> 04:54.600
And LangGraph comes with very nice

04:54.600 --> 04:56.850
and simple built-in functions

04:56.850 --> 05:00.120
that will help us persist our state of the graph.

05:00.120 --> 05:04.710
And this will help us also make our software more robust

05:04.710 --> 05:06.480
and more fault-tolerant,

05:06.480 --> 05:09.150
but also implement some very cool logic

05:09.150 --> 05:12.420
that will show you in the course that is going to result us

05:12.420 --> 05:15.333
with very nice user experience.
