add README.md

This commit is contained in:
2026-05-26 13:53:26 +00:00
parent 1f55b92a8e
commit 541f812e7a
+59 -1
View File
@@ -1,2 +1,60 @@
# task-699cc158d6d3a5544a3ed35b
# Streammode LangChain Agent
## What this project does
This repository contains a minimal example that demonstrates how to replace the
`invoke()` call of a LangChain agent with the streaming interface `stream()`. The
output is printed token by token so that the user can see the agent “think” in
real time.
The script uses the BroJS LLM provider and a tiny mock tool called
`get_price` to illustrate how tools are called while streaming.
## File structure
```
├── main.py # Entry point shows three example invocations
├── requirements.txt # Dependencies (no exact versions)
└── README.md # This file
```
## Installation
```bash
pip install -r requirements.txt
export JOURNAL_MCP_PAT=YOUR_BROJS_TOKEN # required for the LLM
python main.py
```
## Example output
Running `python main.py` produces something like:
```
=== Example 1 ===
--- Step 0 ---
Paris is the capital of France.
--- End ---
=== Example 2 ===
--- Step 0 ---
The price of milk in Kazan is 89 rubles.
--- End ---
=== Example 3 ===
--- Step 0 ---
The price of bread in Kazan is 45 rubles.
The price of coffee in Moscow is 120 rubles.
--- End ---
```
## How it works
* The agent is created with `create_agent` and a single tool.
* `agent.stream()` returns an iterator that yields tuples `(chunk_type,
chunk_data)` where `chunk_type` can be `'messages'` or `'updates'`.
* Tokens are printed as they arrive, and step changes are highlighted with
a separator line.
Feel free to extend the tool set or modify the prompt the streaming logic
remains unchanged.