From 5d2e2b7a6b245d9e72ed962aedbe8ebf6b1b8eea Mon Sep 17 00:00:00 2001 From: MrKan Date: Wed, 15 Apr 2026 02:09:41 +0300 Subject: [PATCH] =?UTF-8?q?manual=20=D1=82=D0=B5=D1=81=D1=82=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=BD=D0=BE=D0=B2=D1=8B=D1=85=20=D0=BC=D0=BE=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/manual.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tests/manual.py b/tests/manual.py index d59754c..a39802b 100644 --- a/tests/manual.py +++ b/tests/manual.py @@ -2,24 +2,33 @@ import asyncio import traceback from lambda_agent_api.agent_api import AgentApi -from lambda_agent_api.server import MsgEventTextChunk +from lambda_agent_api.server import MsgEventTextChunk, MsgEventToolCallChunk, MsgEventToolResult -def my_callback(message): - print(f"Callback: {message}") - async def main(): - api = AgentApi("agent-1", "ws://localhost:8000/agent_ws/", callback=my_callback) + api = AgentApi("agent-1", "ws://localhost:8000/agent_ws/") await api.connect() while True: try: prompt = await asyncio.get_event_loop().run_in_executor(None, input, ">>> ") print("Agent: ", end="") + is_tool = False async for chunk in api.send_message(prompt): - if isinstance(chunk, MsgEventTextChunk): - print(chunk.text, end="", flush=True) + match chunk: + case MsgEventTextChunk(): + is_tool = False + print(chunk.text, end="", flush=True) + case MsgEventToolCallChunk(): + if not is_tool: + print(f"\n\n### TOOL CALL: ({chunk.tool_name}) ", end="", flush=True) + is_tool = True + print(chunk.args_chunk, end="", flush=True) + case MsgEventToolResult(): + is_tool = False + print(f"\nResult: {chunk.result}\n\n", end="", flush=True) + print("\n") except KeyboardInterrupt: break