Hey there.
Eden here.
And in this video we're going to implement the retrieve node.
So this node is going to get the state.
It's going to extract the question that the user asked.
And it's going to retrieve the relevant documents for that state.
So that is going to be using our vector store semantic search capabilities.
And after this node we should update the state documents to hold the relevant documents from our vector
store.
Alrighty.
Let's go to our notes package and we want to create a new file and let's call it retrieve.
So let's start with the imports from typing.
We want any and dict for type hinting.
We want to import our graph state because that's the input for our node.
And that's what the node is updating.
And we also want to import the retriever from the ingestion file.
And by now the retriever is supposed to reference our local vector store with all the embeddings stored
already.
Alrighty, let's go and define our node.
And it's going to be a function.
And this function is going to receive the state.
And it's going to return us a dictionary.
So what to update in the state.
And we'll call it retrieve.
We'll print that we're retrieving will extract the question from the current state.
And we're simply going to use the retrieval dot invoke method with the question which is going to do
the semantic search and get us all the relevant documents.
And as a return value, we want to update the field of documents in our current state with the retrieve
documents.
And here, just in case, I also added the original question.
Note that I didn't have to do it.
This is just being cautious and that's it for this node.
If you want to get the exact code, you can go to the five retrieve node branch on GitHub.
And that's where you have all of the code you just saw in this video.