From 603db89c8b23308615e93e69a5d7afce59bea937 Mon Sep 17 00:00:00 2001 From: collhoun <2904yr@mail.ru> Date: Wed, 8 Apr 2026 11:31:21 +0300 Subject: [PATCH] =?UTF-8?q?#5=20=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D1=82=D1=8C=20=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D1=81=D0=BA=D1=83=D1=8E=20=D1=87=D0=B0=D1=81=D1=82=D1=8C=20?= =?UTF-8?q?=D0=BA=D0=B0=D0=BD=D0=B0=D0=BB=D0=B0=20=D0=BE=D0=B1=D1=89=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F.=20=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=B4=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=B0=D1=86=D0=B8=D1=8F=20api=20=D0=B0=D0=B3=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index f36c9b4..496c876 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,14 @@ async def main(): async for chunk in response: if isinstance(chunk, MsgEventTextChunk): print(chunk.text, end="", flush=True) + elif isinstance(chunk, MsgEventToolCallChunk): + print(f"Tool call started: {chunk.tool_name}") + elif isinstance(chunk, MsgEventToolResult): + print(f"Tool result: {chunk.result}") + elif isinstance(chunk, MsgEventCustomUpdate): + print(f"Progress update: {chunk.payload}") + elif isinstance(chunk, MsgEventEnd): + print(f"Generation ended, tokens used: {chunk.tokens_used}") finally: await api.close() @@ -39,6 +47,8 @@ async def main(): asyncio.run(main()) ``` +> `AgentApi.send_message()` возвращает стриминг-итерируемый объект, который может выдавать не только текстовые чанки, но и события инструментов (`MsgEventToolCallChunk`, `MsgEventToolResult`, `MsgEventCustomUpdate`) и финальный `MsgEventEnd`. + ## Предполагаемое использование ```python