{ "cells": [ { "attachments": {}, "cell_type": "markdown", "id": "04b012ac-e0b5-483e-a645-d13d0e215aad", "metadata": {}, "source": [ "# How to stream data from within a tool\n", "\n", "
Prerequisites
\n", "\n", " This guide assumes familiarity with the following:\n", "
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", "ASYNC IN PYTHON<=3.10
\n", "\n", "Any Langchain `RunnableLambda`, a `RunnableGenerator`, or `Tool` that invokes other runnables and is running async in python<=3.10, will have to propagate callbacks to child objects **manually**. This is because LangChain cannot automatically propagate callbacks to child objects in this case.\n", " \n", "This is a common reason why you may fail to see events being emitted from custom runnables or tools.\n", "
\n", "Use async for the astream events API
\n", "\n", " You should generally be using `async` code (e.g., using `ainvoke` to invoke the llm) to be able to leverage the astream events API properly.\n", "
\n", "