You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The key change in `BaseClient` is the return type of `send_message()`: it **now returns `AsyncIterator[StreamResponse]`** (v0.3 returned`AsyncIterator[ClientEvent | Message]`).
325
+
The `BaseClient.send_message()`return type is standardised from `AsyncIterator[ClientEvent | Message]` to `AsyncIterator[StreamResponse]`.
329
326
330
-
```python
331
-
from a2a.types import Message, Part, Role, SendMessageRequest
332
-
from uuid import uuid4
327
+
Each `StreamResponse` yields exactly one of: `task`, `message`, `status_update`, or `artifact_update`. Use `HasField()` to check which field is set.
333
328
334
-
request = SendMessageRequest(
335
-
message=Message(
336
-
role=Role.ROLE_USER,
337
-
parts=[Part(text=user_input)],
338
-
message_id=uuid4().hex,
339
-
)
340
-
)
341
329
330
+
**Before (v0.3):**
331
+
```python
332
+
asyncfor event, message in client.send_message(request):
333
+
ifisinstance(event, Task):
334
+
...
335
+
ifisinstance(event, UpdateEvent):
336
+
...
337
+
if message:
338
+
...
339
+
```
340
+
341
+
**After (v1.0):**
342
+
```python
342
343
asyncfor chunk in client.send_message(request):
343
344
if chunk.HasField('artifact_update'):
344
345
...
@@ -350,9 +351,6 @@ async for chunk in client.send_message(request):
350
351
...
351
352
```
352
353
353
-
Each `StreamResponse` yields exactly one of: `task`, `message`, `status_update`, or `artifact_update`. Use `HasField()` to check which field is set.
354
-
355
-
> **Note**: The legacy `A2AClient` class has been removed. Use `create_client()` as shown in [section 5](#5-client-creating-a-client). **Example**: [`helloworld/test_client.py` in PR #474](https://github.com/a2aproject/a2a-samples/pull/474/files#diff-f62c07d3b00364a3100b7effb3e2a1cca0624277d3e40da1bdb07bb46b6a8cef)
0 commit comments