From 541f812e7a39faa166346276fb645d9b795c5c68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=20=D0=9A=D1=83=D1=82?= =?UTF-8?q?=D0=BB=D0=B0=D1=85=D0=BC=D0=B5=D1=82=D0=BE=D0=B2?= Date: Tue, 26 May 2026 13:53:26 +0000 Subject: [PATCH] add README.md --- README.md | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 51928ab..338c0f8 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,60 @@ -# task-699cc158d6d3a5544a3ed35b +# Stream‑mode 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.