WEBVTT

00:00.300 --> 00:01.620
Eden: Hey there, Eden here.

00:01.620 --> 00:03.900
And in this video, we're going to discuss

00:03.900 --> 00:06.570
what's LangGraph and why do we need it,

00:06.570 --> 00:09.300
and why it's different from LangChain.

00:09.300 --> 00:12.150
So LangChain has been existing for a year

00:12.150 --> 00:14.040
and it's an amazing framework

00:14.040 --> 00:16.980
for building generative AI applications.

00:16.980 --> 00:20.670
If you want to build RAG applications or even agents,

00:20.670 --> 00:22.470
LangChain is here to help.

00:22.470 --> 00:25.260
It has gone a long way since it was created,

00:25.260 --> 00:26.850
and I mean it for the good.

00:26.850 --> 00:29.850
It got more secure, more flexible,

00:29.850 --> 00:32.100
more readable, and more usable,

00:32.100 --> 00:35.010
especially with the LangChain Expression Language.

00:35.010 --> 00:38.610
Leveraging composability, the way now to interact

00:38.610 --> 00:41.880
with the LangChain components couldn't be more convenient.

00:41.880 --> 00:45.180
And LangChain is the open-source framework

00:45.180 --> 00:47.670
which is at the moment pioneering

00:47.670 --> 00:50.160
a lot of work around agents.

00:50.160 --> 00:52.710
And in LangChain, we can build agents,

00:52.710 --> 00:55.050
and I even showed it in my LangChain course,

00:55.050 --> 00:58.860
how to build agents and what's the logic behind it.

00:58.860 --> 01:01.170
However, we do have limitations

01:01.170 --> 01:03.750
when we build agents within LangChain.

01:03.750 --> 01:05.370
And I think this diagram,

01:05.370 --> 01:08.730
which LangChain published when they launched LangGraph,

01:08.730 --> 01:10.680
demonstrating the challenges

01:10.680 --> 01:13.710
of building complex agentic systems.

01:13.710 --> 01:16.770
So, the person with the computer is code,

01:16.770 --> 01:21.150
and the person talking, you can think about it as an LLM.

01:21.150 --> 01:25.200
The top line represent sequential code that we write.

01:25.200 --> 01:29.310
This is deterministic code that simply runs and execute.

01:29.310 --> 01:33.060
So we, the developers, have full control of it.

01:33.060 --> 01:37.320
At the very bottom, we have agents or autonomous agents,

01:37.320 --> 01:41.430
which they can decide what they need to do and how to do it,

01:41.430 --> 01:42.870
and they simply do it.

01:42.870 --> 01:44.460
And by the way, at the moment,

01:44.460 --> 01:46.530
there aren't any autonomous agents

01:46.530 --> 01:49.593
which are quite production-ready or usable.

01:50.490 --> 01:52.920
So those have the most freedom.

01:52.920 --> 01:55.530
When we make a regular LLM call,

01:55.530 --> 01:58.860
then the LLM decides what is the output

01:58.860 --> 02:00.450
and we have no control of it,

02:00.450 --> 02:03.570
but we decide which steps to take before

02:03.570 --> 02:05.760
and which steps to take after.

02:05.760 --> 02:08.130
But those are very simple applications.

02:08.130 --> 02:11.310
For example, you can think of a cybersecurity company

02:11.310 --> 02:15.750
that is making a request to the LLM to explain an alert.

02:15.750 --> 02:18.930
We can build some useful features with it,

02:18.930 --> 02:21.630
but nothing really complex.

02:21.630 --> 02:24.030
And when we use LangChain chains,

02:24.030 --> 02:26.670
we can have a bunch of LLM calls

02:26.670 --> 02:29.520
and we still have control of what happens before

02:29.520 --> 02:30.960
and after those calls.

02:30.960 --> 02:33.750
So, we can still build some very cool things

02:33.750 --> 02:36.870
because we are chaining a lot of LLM calls together

02:36.870 --> 02:39.780
and we have more freedom at the moment.

02:39.780 --> 02:42.840
Now, within LangChain, we can use something

02:42.840 --> 02:46.110
which are called router chains or router agents,

02:46.110 --> 02:50.880
which are leveraging LLMs to decide which call to make

02:50.880 --> 02:52.950
or what steps to take.

02:52.950 --> 02:54.270
And we can easily do it

02:54.270 --> 02:55.830
with the LangChain Expression Language,

02:55.830 --> 02:57.960
and I showed it in my LangChain course.

02:57.960 --> 03:00.870
However, with the LangChain Expression Language,

03:00.870 --> 03:03.450
we can't make cycles.

03:03.450 --> 03:06.210
We can only have the acyclic graphs.

03:06.210 --> 03:09.810
So a certain flow that we write beforehand,

03:09.810 --> 03:12.480
but we can't iterate, we can't come back

03:12.480 --> 03:15.390
to the original node that we started from

03:15.390 --> 03:17.610
and start the process all over again.

03:17.610 --> 03:19.650
There are LangChain implementations

03:19.650 --> 03:20.880
for those kind of things,

03:20.880 --> 03:23.310
but they are ad hoc implementations,

03:23.310 --> 03:25.650
like for example, the React algorithm,

03:25.650 --> 03:29.160
where there is literally a while loop in the source code.

03:29.160 --> 03:32.160
This is exactly where LangGraph blends in.

03:32.160 --> 03:35.160
It gives us another dimension of freedom

03:35.160 --> 03:39.090
and complexity we can add into our agents.

03:39.090 --> 03:43.290
So we can with LangGraph implement cycles.

03:43.290 --> 03:45.090
And this feature is super important

03:45.090 --> 03:47.670
when we want to build very complex agent

03:47.670 --> 03:50.040
that have a certain amount of freedom

03:50.040 --> 03:52.560
that we are not used to from before.

03:52.560 --> 03:54.810
And the concept of this,

03:54.810 --> 03:57.840
it relates to something which is called flow engineering.

03:57.840 --> 04:00.120
So we as the developers,

04:00.120 --> 04:03.390
we can define the flow of our program

04:03.390 --> 04:06.293
and we can blend in with LangGraph the LLM.

04:06.293 --> 04:08.820
And the LLM can also help us

04:08.820 --> 04:10.740
where do we want to go in the flow,

04:10.740 --> 04:13.560
whether to go to flow A or flow B,

04:13.560 --> 04:17.250
or to finish, or to go back to where we started

04:17.250 --> 04:19.140
and to continue from there.

04:19.140 --> 04:22.230
So the cycles gives us a lot of freedom,

04:22.230 --> 04:25.500
and with LangGraph, it's very elegant

04:25.500 --> 04:28.713
and very easy to implement those kind of solutions.

04:29.610 --> 04:33.150
So from the LangGraph documentation,

04:33.150 --> 04:36.150
you can see it's listed as building language agents

04:36.150 --> 04:37.200
as graphs.

04:37.200 --> 04:41.160
So the entire logic, the entire flow of the agent

04:41.160 --> 04:44.250
can be expressed as a graph,

04:44.250 --> 04:46.080
as a graph with cycles,

04:46.080 --> 04:47.700
and this is very convenient.

04:47.700 --> 04:51.510
And with LangGraph, we can build some very advanced systems,

04:51.510 --> 04:54.483
and we'll even see something like that in the course.
