WEBVTT

00:00.200 --> 00:00.720
Hey there.

00:00.760 --> 00:01.520
Eden here.

00:01.520 --> 00:05.600
And in this video we're going to implement the retrieve node.

00:05.840 --> 00:08.160
So this node is going to get the state.

00:08.160 --> 00:11.600
It's going to extract the question that the user asked.

00:11.600 --> 00:15.480
And it's going to retrieve the relevant documents for that state.

00:15.480 --> 00:19.920
So that is going to be using our vector store semantic search capabilities.

00:20.160 --> 00:26.640
And after this node we should update the state documents to hold the relevant documents from our vector

00:26.640 --> 00:27.040
store.

00:27.960 --> 00:28.800
Alrighty.

00:29.000 --> 00:35.400
Let's go to our notes package and we want to create a new file and let's call it retrieve.

00:37.520 --> 00:41.160
So let's start with the imports from typing.

00:41.160 --> 00:44.000
We want any and dict for type hinting.

00:44.000 --> 00:48.400
We want to import our graph state because that's the input for our node.

00:48.920 --> 00:51.080
And that's what the node is updating.

00:51.240 --> 00:55.160
And we also want to import the retriever from the ingestion file.

00:55.360 --> 01:02.330
And by now the retriever is supposed to reference our local vector store with all the embeddings stored

01:02.330 --> 01:02.770
already.

01:03.290 --> 01:06.130
Alrighty, let's go and define our node.

01:06.130 --> 01:07.930
And it's going to be a function.

01:08.290 --> 01:10.570
And this function is going to receive the state.

01:10.570 --> 01:12.490
And it's going to return us a dictionary.

01:12.490 --> 01:14.370
So what to update in the state.

01:14.650 --> 01:16.090
And we'll call it retrieve.

01:16.130 --> 01:21.210
We'll print that we're retrieving will extract the question from the current state.

01:21.530 --> 01:27.930
And we're simply going to use the retrieval dot invoke method with the question which is going to do

01:27.930 --> 01:31.250
the semantic search and get us all the relevant documents.

01:31.850 --> 01:39.690
And as a return value, we want to update the field of documents in our current state with the retrieve

01:39.730 --> 01:40.570
documents.

01:40.570 --> 01:44.890
And here, just in case, I also added the original question.

01:44.930 --> 01:46.770
Note that I didn't have to do it.

01:46.770 --> 01:50.970
This is just being cautious and that's it for this node.

01:51.690 --> 01:57.890
If you want to get the exact code, you can go to the five retrieve node branch on GitHub.

01:58.050 --> 02:01.330
And that's where you have all of the code you just saw in this video.
