TUTORIAL_BUILD_A_RAG_AGENT
TUTORIALLearn how to give your agent long-term memory and access to private documentation using Vector Stores.
INTRODUCTION#
Retrieval-Augmented Generation (RAG) combines the power of LLMs with external knowledge. In this tutorial, we will build a "Knowledge Base Agent" that can answer questions about a fictional product manual.
- Vector Database: To store and retrieve document embeddings.
- Tooling: A custom tool to query the database.
- Agent: To synthesize the retrieved information.
SETUP_KNOWLEDGE_BASE
First, we need a way to store and retrieve documents. We'll define a simple VectorStore interface.
CREATE_RETRIEVAL_TOOL
We wrap our search function in a Tool so the agent knows how and when to use it.
INITIALIZE_AGENT
Now we give the tool to the agent. Notice the system prompt encourages using the tool.
TEST_IT
Run the agent with a question that requires external knowledge.
PRO_TIP
For large datasets, use the @AKIOS/rag package (coming soon) which handles chunking, embedding, and re-ranking automatically.