Build Agentic RAG Systems
Agentic RAG implements retrieval agents for decision-making on index retrieval, powered by LangGraph.
Why it matters
Implement an agentic Retrieval Augmented Generation (RAG) system using LangGraph. This asset enables LLMs to decide when to retrieve information from an index, enhancing their decision-making capabilities for complex queries.
Outcomes
What it gets done
Index external documents for retrieval.
Create a retriever tool for LLM access.
Define a graph state to manage messages.
Orchestrate agent decisions and tool calls.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/lg-langgraphagenticrag | bash Capabilities
What this agent can do
Chunks, embeds, and indexes documents for semantic retrieval.
Condenses long documents or threads into key takeaways.
Searches the web and retrieves relevant sources.
Labels or categorizes text, files, or data points.
Overview
Agentic RAG
What it does
Implement retrieval agents when you need to make decisions about whether to retrieve from an index. Incorporate this into LangGraph by giving an LLM access to a retriever tool. The graph starts with an agent, which can decide to call a function. If it does, it proceeds to an action to call a tool (retriever). The agent is then called again with the tool output added to the messages state.
How it connects
2024-06-13T21:07:07.998Z
Source README
This directory is retained purely for archival purposes and is no longer updated. Please see the newly consolidated LangChain documentation for the most current information and resources.
Agentic RAG
Retrieval Agents are useful when we want to make decisions about whether to retrieve from an index.
To implement a retrieval agent, we simple need to give an LLM access to a retriever tool.
We can incorporate this into LangGraph.
Setup
First, let's download the required packages and set our API keys:
Set up LangSmith for LangGraph development
Sign up for LangSmith to quickly spot issues and improve the performance of your LangGraph projects. LangSmith lets you use trace data to debug, test, and monitor your LLM apps built with LangGraph - read more about how to get started here.
Retriever
First, we index 3 blog posts.
Then we create a retriever tool.
Agent State
We will define a graph.
A state object that it passes around to each node.
Our state will be a list of messages.
Each node in our graph will append to it.
Nodes and Edges
We can lay out an agentic RAG graph like this:
- The state is a set of messages
- Each node will update (append to) state
- Conditional edges decide which node to visit next
Graph
- Start with an agent,
call_model - Agent make a decision to call a function
- If so, then
actionto call tool (retriever) - Then call agent with the tool output added to messages (
state)
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.