{ "cells": [ { "cell_type": "markdown", "id": "47e3b43b", "metadata": {}, "source": [ "This directory is retained purely for archival purposes and is no longer updated. Please see the newly [consolidated LangChain documentation](https://docs.langchain.com/oss/python/langgraph/overview) for the most current information and resources." ] }, { "cell_type": "markdown", "id": "425fb020-e864-40ce-a31f-8da40c73d14b", "metadata": {}, "source": [ "# Agentic RAG\n", "\n", "[Retrieval Agents](https://python.langchain.com/v0.2/docs/tutorials/qa_chat_history/#agents) are useful when we want to make decisions about whether to retrieve from an index.\n", "\n", "To implement a retrieval agent, we simple need to give an LLM access to a retriever tool.\n", "\n", "We can incorporate this into [LangGraph](https://langchain-ai.github.io/langgraph/).\n", "\n", "## Setup\n", "\n", "First, let's download the required packages and set our API keys:" ] }, { "cell_type": "code", "execution_count": null, "id": "969fb438", "metadata": {}, "outputs": [], "source": [ "%%capture --no-stderr\n", "%pip install -U --quiet langchain-community tiktoken langchain-openai langchainhub chromadb langchain langgraph langchain-text-splitters" ] }, { "cell_type": "code", "execution_count": 1, "id": "e4958a8c", "metadata": {}, "outputs": [], "source": [ "import getpass\n", "import os\n", "\n", "\n", "def _set_env(key: str):\n", " if key not in os.environ:\n", " os.environ[key] = getpass.getpass(f\"{key}:\")\n", "\n", "\n", "_set_env(\"OPENAI_API_KEY\")" ] }, { "cell_type": "markdown", "id": "3d07e8d4", "metadata": {}, "source": [ "
Set up LangSmith for LangGraph development
\n", "\n", " 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. \n", "
\n", "