{ "cells": [ { "cell_type": "markdown", "id": "492f050f-3dc3-44fa-8fdc-03362afd5488", "metadata": {}, "source": [ "# Reflection\n", "\n", "\n", "In the context of LLM agent building, reflection refers to the process of prompting an LLM to observe its past steps (along with potential observations from tools/the environment) to assess the quality of the chosen actions.\n", "This is then used downstream for things like re-planning, search, or evaluation.\n", "\n", "\n", "\n", "This notebook demonstrates a very simple form of reflection in LangGraph." ] }, { "cell_type": "markdown", "id": "3ef94e7e-c9a5-4eee-a865-acf411b5c235", "metadata": {}, "source": [ "## Setup\n", "\n", "First, let's install our required packages and set our API keys" ] }, { "cell_type": "code", "execution_count": 1, "id": "8b323f43-328b-4b4b-88b0-6c84dc0a1d60", "metadata": {}, "outputs": [], "source": [ "%pip install -U --quiet langgraph langchain-fireworks\n", "%pip install -U --quiet tavily-python" ] }, { "cell_type": "code", "execution_count": null, "id": "3368f330-cad6-4d35-a291-68fbf4389d98", "metadata": {}, "outputs": [], "source": [ "import getpass\n", "import os\n", "\n", "\n", "def _set_if_undefined(var: str) -> None:\n", " if os.environ.get(var):\n", " return\n", " os.environ[var] = getpass.getpass(var)\n", "\n", "_set_if_undefined(\"TAVILY_API_KEY\")\n", "_set_if_undefined(\"FIREWORKS_API_KEY\")" ] }, { "cell_type": "markdown", "id": "9182b7d5", "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", "