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 .env file or export OPENAI_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

S
Description
BroJS: Untitled Task
Readme 29 KiB
Languages
Python 100%