{ "cells": [ { "cell_type": "markdown", "id": "15c4bd28", "metadata": {}, "source": [ "# How to stream from the final node" ] }, { "cell_type": "markdown", "id": "964686a6-8fed-4360-84d2-958c48186008", "metadata": {}, "source": [ "A common use case is streaming from an agent is to stream LLM tokens from inside the final node. This guide demonstrates how you can do this.\n", "\n", "## Setup\n", "\n", "First let's install our required packages and set our API keys" ] }, { "cell_type": "code", "execution_count": 1, "id": "c04a3f8e-0bc9-430b-85db-3edfa026d2cd", "metadata": {}, "outputs": [], "source": [ "%%capture --no-stderr\n", "%pip install -U langgraph langchain-openai langchain-community" ] }, { "cell_type": "code", "execution_count": null, "id": "c87e4a47-4099-4d1a-907c-a99fa857165a", "metadata": {}, "outputs": [], "source": [ "import getpass\n", "import os\n", "\n", "\n", "def _set_env(var: str):\n", " if not os.environ.get(var):\n", " os.environ[var] = getpass.getpass(f\"{var}: \")\n", "\n", "\n", "_set_env(\"OPENAI_API_KEY\")" ] }, { "cell_type": "markdown", "id": "eb79e50b", "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", "