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
Copy file name to clipboardExpand all lines: contributing/workflow_samples/message/README.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@ This sample demonstrates different ways to send a message to a user using `Event
7
7
1.**String Messages**: Standard string text replies.
8
8
1.**Multi-modal Messages**: Returning mixed modality inputs, such as a string combined with an inline image.
9
9
1.**Multiple Messages**: Emitting multiple full messages from the same node with a delay between them.
10
+
1.**Streaming Messages**: Simulating an LLM streaming response by breaking a message into chunks and yielding them with the `partial=True` flag at intervals.
10
11
11
12
## Sample Inputs
12
13
@@ -27,6 +28,9 @@ This workflow executes sequentially and successfully without any expected user i
27
28
[ multiple_messages ]
28
29
|
29
30
v
31
+
[ stream_sentence ]
32
+
|
33
+
v
30
34
(Workflow Ends)
31
35
```
32
36
@@ -69,3 +73,19 @@ To send messages in an ADK node, yield an `Event` object with the `message` argu
69
73
70
74
yield Event(message="Done processing.")
71
75
```
76
+
77
+
1.**Stream a message in chunks**:
78
+
Provide the `partial=True` flag for intermediate chunks. This provides a better user experience by allowing the UI to show the response in a streaming fashion, thereby lowering the latency to see the first word. ADK automatically accumulates all partial messages and merges them into a final message for you for session storage.
79
+
80
+
> **Note**: To stream multiple messages or tokens smoothly, your node function **must be an asynchronous generator** (`async def`). This allows ADK to yield messages to the client immediately without blocking.
0 commit comments