Code lab 12.1 – adding a LangGraph agent to RAG
In this code lab, we will add an agent to our existing RAG pipeline that can make decisions about whether to retrieve from an index or use a web search. We will show the inner thoughts of the agent as it processes data that it retrieves toward the goal of providing you with a more thorough response to your question. As we add the code for our agent, we will see new components, such as tools, toolkits, graphs, nodes, edges, and, of course, the agent itself. For each component, we will go more in-depth into how that component interacts and supports your RAG application. We will also add code so that this functions more like a chat session, rather than a Q&A session:
- First, we will install some new packages to support our agent development:
%pip install tiktoken
%pip install langgraph
In the first line, we install the
tiktoken
package, which is an OpenAI package used for tokenizing text data before feeding it into language...