feat: solution for 'Untitled Task'

This commit is contained in:
2026-05-28 13:17:50 +03:00
parent 130c4f20fb
commit 346f9ff776
3 changed files with 3 additions and 90 deletions
+1 -34
View File
@@ -1,34 +1 @@
# 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 <repo-url>
cd <repo-dir>
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
# LangGraph Streaming Agent\n\nThis project demonstrates how to use LangGraph to stream responses from an AI agent in real-time. Instead of waiting for the entire answer, the agent outputs tokens as they are generated, providing a more interactive experience.\n\n## Prerequisites\n\n- Python 3.10 or higher\n- An OpenAI API key (set as `OPENAI_API_KEY` in your environment)\n\n## Installation\n\nbash\npip install -r requirements.txt\n\n\n## Running the Agent\n\nbash\npython src/main.py\n\n\nThe agent will ask a simple math question and stream the answer token by token. You will see a separator when the agent moves to a new step.\n\n## Customization\n\n- Modify the `messages` in `src/main.py` to ask different questions.\n- Add or replace tools in the `tools` list to extend the agent's capabilities.\n