130c4f20fbea480a26a9df06adc241c363cf6b26
LangGraph Streaming Agent
This project demonstrates how to use LangGraph's streaming capabilities to display LLM responses token by token in real time.
Prerequisites
- Python 3.10+
- An OpenAI API key. Set it in a
.envfile or exportOPENAI_API_KEY.
Installation
bash
git clone
cd
python -m venv .venv
source .venv/bin/activate # On Windows use .venv\Scripts\activate
pip install -r requirements.txt
Usage
bash python src/main.py
You will be prompted to enter a question. The answer will stream to the console as it is generated.
How it works
The script builds a simple LangGraph agent that uses the OpenAI LLM. It calls agent.stream() with stream_mode=['messages', 'updates'] and iterates over the returned chunks, printing each token as it arrives.
License
MIT
Description
Languages
Python
100%