WEBVTT

00:00.240 --> 00:01.470
Eden: Hey there, Eden here.

00:01.470 --> 00:05.190
And in this video we're going to define our graph state,

00:05.190 --> 00:07.050
which is going to be passed around

00:07.050 --> 00:08.730
during our nodes execution.

00:08.730 --> 00:10.440
And this is going to be a short video

00:10.440 --> 00:12.480
because it's pretty straightforward.

00:12.480 --> 00:15.360
And as always, if you want to get the exact code for

00:15.360 --> 00:17.790
what we're going to be writing in this video,

00:17.790 --> 00:21.663
feel free to check out the Github branch of 4-state.

00:24.180 --> 00:28.020
Alrighty, let's go to state.py and we want to start

00:28.020 --> 00:33.020
with the imports and we'll import list and TypeDict.

00:33.150 --> 00:36.390
And let's create the class of GraphState

00:36.390 --> 00:38.940
which will inherit from TypeDict.

00:38.940 --> 00:41.790
And this will include all the state that we need

00:41.790 --> 00:43.410
for the graph execution.

00:43.410 --> 00:45.870
And let's discuss before we implement.

00:45.870 --> 00:48.510
Of course, we want to have the question in our state,

00:48.510 --> 00:50.760
because we always want to reference it,

00:50.760 --> 00:54.000
whether to determine if the documents retrieved are relevant

00:54.000 --> 00:58.140
to the question or even to what's to search online.

00:58.140 --> 01:00.480
We want to save the documents that are going

01:00.480 --> 01:02.460
to help us answer this question.

01:02.460 --> 01:05.280
So those are going to be the retrieved documents

01:05.280 --> 01:09.030
or the documents that we get back from the search result.

01:09.030 --> 01:10.740
And for that we're going to be saving

01:10.740 --> 01:12.390
in a list of documents.

01:12.390 --> 01:14.250
We want to have a Boolean flag

01:14.250 --> 01:17.220
that will tell us whether we need to search online

01:17.220 --> 01:19.710
for extra results or not.

01:19.710 --> 01:23.340
And of course we want to have the generation field,

01:23.340 --> 01:26.160
which is going to be the generated answer.

01:26.160 --> 01:30.930
Alrighty, let's go and let's define those attributes.

01:30.930 --> 01:34.020
So question is going to be a string, generation is going

01:34.020 --> 01:38.130
to be a string, web search is going to be a Boolean.

01:38.130 --> 01:42.450
And finally, documents is going to be a list of strings,

01:42.450 --> 01:44.760
which is going to be a list of the content

01:44.760 --> 01:46.020
of those documents.

01:46.020 --> 01:48.870
And that's pretty much it. That's our state.

01:48.870 --> 01:52.500
And if you want to check out the exact code, you are welcome

01:52.500 --> 01:54.870
to go to the GitHub repository,

01:54.870 --> 01:59.520
and go and look for the branch 4-state.

01:59.520 --> 02:04.520
So you can see that under graph we have the state.py file,

02:04.560 --> 02:06.110
and this is the implementation.
