WEBVTT

00:00.400 --> 00:02.880
All right, so let's get stuck in.

00:02.880 --> 00:05.880
So before we get stuck in, let me set your expectations.

00:06.240 --> 00:07.600
There's going to be terminology.

00:07.600 --> 00:12.840
There's going to be some new concepts coming with Landgraf just as we've had in the past.

00:12.840 --> 00:19.080
And I realize that it's a bit jarring to say put all the crew stuff to one side, just just put that

00:19.080 --> 00:19.400
away.

00:19.440 --> 00:20.760
Compartmentalize.

00:20.760 --> 00:23.080
We're on to something new now, but it will be quick.

00:23.080 --> 00:27.680
We're going to get through the terminology quickly, and I'm going to be drilling it into you by repeating

00:27.680 --> 00:32.600
it several times, and then it's going to be second nature and you'll forget all about crew.

00:32.640 --> 00:33.400
All right.

00:33.520 --> 00:35.280
So what is the terminology.

00:35.320 --> 00:36.040
Here we go.

00:36.200 --> 00:43.680
So agent workflows are described in Landgraf speak as a graph.

00:43.840 --> 00:47.120
A graph is something that'll be very familiar to people in computer science.

00:47.120 --> 00:49.680
But a graph you can think of like a tree structure.

00:49.680 --> 00:54.320
It's something which has, uh, I'm about to say the names of the things I'm about to describe, but

00:54.320 --> 01:00.280
it has things connected together in, in something which looks a bit like a tree and some sort of a

01:00.280 --> 01:04.560
hierarchy where one thing depends on others beneath it.

01:05.040 --> 01:13.040
And so this, this idea of representing workflows in this kind of graph way, that is the the core idea

01:13.040 --> 01:15.520
of land graph as the name gives away.

01:16.440 --> 01:18.800
And then a state.

01:18.800 --> 01:26.440
So the state is something that represents the current snapshot, the current state of affairs, the

01:26.440 --> 01:28.520
status of your whole application.

01:28.640 --> 01:33.680
It's an object that that needs to encapsulate the state of the world.

01:33.920 --> 01:39.720
And that object is something which, which, uh, is is shared across the whole application.

01:39.720 --> 01:42.080
And it's something very fundamental to land graph.

01:42.080 --> 01:44.200
So you need to remember state.

01:44.200 --> 01:45.720
We're going to be using state a lot.

01:45.760 --> 01:48.760
And that's something which is it is uh it's a variable.

01:48.760 --> 01:51.520
It's like um it's, it's a, it's information.

01:51.760 --> 01:53.240
Um, it's not not a function.

01:53.240 --> 01:54.440
It's information.

01:54.480 --> 01:56.560
Nodes are functions.

01:56.760 --> 02:00.080
So a node which when people talk about graphs, they talk about nodes.

02:00.080 --> 02:01.720
They are the points on the graph.

02:01.720 --> 02:05.800
They are the, the, the things that are going to get connected together.

02:06.120 --> 02:09.240
The nodes are actually representing a function.

02:09.440 --> 02:12.360
Every node is a Python function.

02:12.360 --> 02:14.200
And that can be confusing the first time you hear it.

02:14.200 --> 02:19.360
Because when you think about graphs, you sometimes think of nodes as being things, as being data connected

02:19.360 --> 02:20.080
in some way.

02:20.080 --> 02:22.880
But no nodes in a graph are functions.

02:22.880 --> 02:29.360
They are Python functions, and they represent a piece of logic, a piece of ancient logic, a thing,

02:29.400 --> 02:30.960
an operation of some sort.

02:31.520 --> 02:35.040
They receive the current state as an input.

02:35.400 --> 02:36.800
They do something.

02:37.000 --> 02:40.080
They do something that might, might involve calling an LLM.

02:40.120 --> 02:42.320
It might involve some sort of a side effect.

02:42.320 --> 02:47.680
Changing something, writing something to a file, doing something that affects the world.

02:48.040 --> 02:52.440
And then they return an update, an updated state.

02:52.440 --> 02:54.760
That's that's what comes afterwards.

02:55.040 --> 02:59.400
So they take in a state, they do something and they return a new state.

02:59.680 --> 03:04.120
And I should say that the state you should think of as being like an immutable thing, the state object

03:04.120 --> 03:04.680
itself.

03:04.720 --> 03:05.080
You don't.

03:05.080 --> 03:06.040
You don't change it.

03:06.080 --> 03:13.760
You receive a state and then you return a new state, which is a difference from the state you had before.

03:14.840 --> 03:16.000
So far, you're with me.

03:16.280 --> 03:18.880
State and notes that the the two words.

03:19.200 --> 03:20.280
And then edges.

03:20.320 --> 03:24.640
And anyone that's ever looked at graphs will be familiar with the term edges.

03:24.640 --> 03:25.600
The edges, of course.

03:25.600 --> 03:26.360
The lines.

03:26.360 --> 03:30.520
The words I was trying not to say earlier is that graphs consist of nodes and edges.

03:30.720 --> 03:38.040
Edges are the connections between the nodes, and edges in the graph are also Python functions.

03:38.040 --> 03:45.840
They are Python functions that determine what node should be executed next based on the state, so the

03:45.840 --> 03:48.640
state can tell it what happens next.

03:48.680 --> 03:52.320
Now there are simple edge connections, which just means that is the next thing to happen.

03:52.320 --> 03:59.680
So if you have one node that is a function, the Python function that uh, that prints hello to to the

03:59.680 --> 04:00.200
output.

04:00.200 --> 04:02.800
And you have another node that prints goodbye.

04:02.800 --> 04:03.480
And they're connected.

04:03.480 --> 04:05.480
Then it will print hello, and then it will print goodbye.

04:05.480 --> 04:06.240
And that's it.

04:06.240 --> 04:11.600
But you can have, uh, connections which are conditional, which depend on something happening.

04:11.720 --> 04:17.320
And in that case, that would mean that one operation would happen and then subject to the condition,

04:17.320 --> 04:19.920
maybe the other one would happen, maybe not.

04:21.040 --> 04:23.200
So that is an edge.

04:23.560 --> 04:27.520
And then simply put, nodes are the things that do the work.

04:27.560 --> 04:30.400
They are the things that carry out tasks.

04:30.400 --> 04:35.960
They do stuff and edges are the things that determine, okay, that stuff was done, what's the next

04:35.960 --> 04:37.000
stuff that should be done?

04:37.200 --> 04:39.400
And that's all there is to it.

04:39.400 --> 04:41.840
That's the that's the main terminology.

04:41.840 --> 04:44.280
There are a couple of other things, but this is the core stuff.

04:44.440 --> 04:47.400
So if you've got this then you're most of the way there with Landgraf.

04:47.440 --> 04:50.520
And of course it would be nice to show this in some sort of a diagram.

04:50.560 --> 04:52.120
And this is the obvious diagram.

04:52.320 --> 04:55.120
So no surprise this is what it looks like.

04:55.120 --> 04:56.480
These are On nodes.

04:56.840 --> 05:03.760
Uh, the three orange circles there representing the three nodes, three operations happening in this

05:03.760 --> 05:05.280
graph, the edges.

05:05.280 --> 05:08.080
I'm trying to show there that one edge is not conditional.

05:08.080 --> 05:14.720
It just wants the top node is run, then the next one will run and it will have the state that's passed

05:14.720 --> 05:20.280
in will be the result of the, the the output from that first node.

05:21.200 --> 05:27.360
And the other edge is meant to show some sort of conditional edge that in some situations the node on

05:27.360 --> 05:28.840
the bottom right will run.

05:29.480 --> 05:33.400
So again, nodes do the work, edges choose what to do next.

05:34.560 --> 05:37.120
So that again is the terminology.

05:37.400 --> 05:40.520
So we are going to build our first graph.

05:40.520 --> 05:42.080
We're actually not going to do it today.

05:42.120 --> 05:43.280
Today is just a theory.

05:43.280 --> 05:46.040
Only one because I'm going to leave the practical for tomorrow.

05:46.080 --> 05:48.200
I'm going to let you brew over this.

05:48.200 --> 05:53.400
I'm going to let this sort of sink in so that the new terminology is something that's super clear to

05:53.400 --> 05:53.680
you.

05:53.680 --> 05:56.890
But the five steps to building your graph.

05:56.930 --> 05:58.130
Your first graph running it.

05:58.130 --> 06:00.170
And it's going to have some more terminology.

06:00.610 --> 06:06.250
First of all, you have to define your state class, the class which is going to store state.

06:06.290 --> 06:10.890
You don't you don't to create a state object because there'll be new objects created all the time.

06:11.210 --> 06:16.010
Uh, and, and so it will define the state class and you'll find out when we actually do this.

06:16.010 --> 06:19.970
There's something associated with that state class known as the reducer.

06:20.090 --> 06:22.530
And that's a very important concept.

06:22.530 --> 06:24.370
But I'm going to leave that concept to tomorrow.

06:25.370 --> 06:29.610
Secondly you start something called the graph builder.

06:29.650 --> 06:34.730
And the graph builder is a thing you're going to use to lay out all the nodes in your graph.

06:34.890 --> 06:36.690
This is something you're doing up front.

06:36.730 --> 06:38.090
Nothing's actually running.

06:38.090 --> 06:41.130
It's not like we actually have an agent system that's running.

06:41.130 --> 06:41.650
This is all.

06:41.690 --> 06:46.290
Before we run the agent system, we first start a graph builder.

06:47.050 --> 06:52.730
We then create a node that is one of these functions that's going to represent some operation that we're

06:52.730 --> 06:59.490
going to want to happen as part of this Landgraf and then we create some edges and we may repeat steps

06:59.490 --> 06:59.970
three and four.

06:59.970 --> 07:04.010
We may create lots of nodes and lots of edges to lay out the story.

07:04.050 --> 07:09.410
We're laying out the story of what we want our agent system to do, and this is all before it's actually

07:09.730 --> 07:11.610
live, before it's doing anything.

07:11.610 --> 07:14.490
It's not like we create nodes and edges and then things happen.

07:14.570 --> 07:20.170
No, we create nodes and edges as part of defining the graph, describing what this will do.

07:20.370 --> 07:25.010
Think of this as a bit like writing a program, but we're sort of doing it dynamically at runtime.

07:25.810 --> 07:30.850
So once we've done that, once at runtime, we've we've described the node, we've created the nodes,

07:30.850 --> 07:32.010
we've created the edges.

07:32.010 --> 07:35.010
We've laid out our whole agent workflow.

07:35.330 --> 07:39.130
We then run an operation called compiling the graph.

07:39.250 --> 07:42.850
And that will turn this into something that's ready to be executed.

07:42.890 --> 07:44.970
And then we kick it off and it runs.

07:45.970 --> 07:48.770
So it is important to get your head around this.

07:48.810 --> 07:51.010
What I've described there, this 12345.

07:51.050 --> 07:57.170
This is all stuff that that is running when we when we start our our system running, we do this process

07:57.170 --> 08:02.610
of defining the state class, starting the graph builder, creating nodes and edges, and compiling

08:02.610 --> 08:03.370
the graph.

08:03.650 --> 08:10.530
It's almost like part of running our system involves the sort of two phases, a phase when it's like

08:10.530 --> 08:16.210
defining itself, laying out the whole workflow, and then a second phase when that actually runs.

08:16.330 --> 08:19.890
And so that first phase, we're not really used to doing that when we code.

08:19.890 --> 08:25.170
We don't normally have a sort of meta phase when we're describing what it is that we want to do and

08:25.170 --> 08:26.410
then running it.

08:26.410 --> 08:31.250
But that's how it works with graph, and I hope that's made some sense.

08:31.250 --> 08:35.610
I'm going to explain it one more time when we go through this tomorrow.

08:35.610 --> 08:43.050
But this is the, uh, this is this is the overall approach that's used for building agentic workflows

08:43.050 --> 08:43.770
with graph.

08:43.770 --> 08:47.250
And with apologies for belaboring the point, let me say it one more time.

08:47.450 --> 08:53.050
When you run a graph application, when you kick it off, there's two phases.

08:53.050 --> 08:54.170
Two things happen.

08:54.170 --> 09:00.050
The first thing is that it runs some of your code that lays out the graph that defines what it is that

09:00.050 --> 09:01.930
you're trying to achieve with agents.

09:02.090 --> 09:04.930
And then once you've done that and that is these five steps here.

09:04.970 --> 09:07.690
Once you've done that, you then initiate it.

09:07.690 --> 09:09.690
You then run it, you invoke it.

09:09.690 --> 09:12.130
And then off this graph runs.

09:12.170 --> 09:16.250
And those two phases, both of them are part of running your application.

09:16.330 --> 09:20.370
And so what we're going to do next time is go through these five steps.

09:20.370 --> 09:21.890
Write code that will do all of this.

09:21.890 --> 09:23.170
And then call it.

09:23.250 --> 09:26.410
And you will then see the results all in one go.

09:26.970 --> 09:30.730
And if this if this is completely clear to you then sorry for saying it three times.

09:30.890 --> 09:32.410
Uh, hang on in there.

09:32.450 --> 09:38.090
And if this is not completely clicking for you, then then fear not when you see the actual code, I

09:38.090 --> 09:40.770
feel like it's going to come together and it's going to be easy peasy.

09:41.050 --> 09:44.090
And that indeed is what we're going to do tomorrow.

09:44.330 --> 09:47.050
So in day two we will do some actual code.

09:47.050 --> 09:48.010
We'll get to the lab.

09:48.010 --> 09:51.810
We'll build our first land graph agent I can't wait.

09:51.810 --> 09:52.730
I'll see you then.
