Skip to content

Commit a1a1183

Browse files
committed
fixup! ai-transport: add message per response doc
1 parent 6b22e2b commit a1a1183

File tree

1 file changed

+21
-26
lines changed

1 file changed

+21
-26
lines changed

src/pages/docs/ai-transport/features/token-streaming/message-per-response.mdx

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,25 @@ This approach is ideal when:
3737
You do not need to mark the message or token stream as completed; the final message will
3838
automatically have the full response with all tokens appended to it.
3939

40+
## Setup
41+
42+
Message append functionality requires the "Message annotations, updates, and deletes" [channel rule](/docs/channels#rules) enabled for your channel or [namespace](/docs/channels#namespaces). This rule automatically enables message persistence.
43+
44+
To enable the channel rule:
45+
46+
1. Go to the [Ably dashboard](https://www.ably.com/dashboard) and select your app.
47+
2. Navigate to the "Configuration" > "Rules" section from the left-hand navigation bar.
48+
3. Choose "Add new rule".
49+
4. Enter a channel name or namespace pattern (e.g. `ai:*` for all channels starting with `ai:`).
50+
5. Select the "Message annotations, updates, and deletes" rule from the list.
51+
6. Click "Create channel rule".
52+
53+
The examples in this guide use the `ai:` namespace prefix, which assumes you have configured the rule for `ai:*`.
54+
55+
### Message size limits
56+
57+
Standard Ably message [size limits](/docs/platform/pricing/limits#message) apply to the complete concatenated message. The system validates size limits before accepting append operations. If appending a token would exceed the maximum message size, the append is rejected.
58+
4059
## Publishing tokens
4160

4261
Publish tokens from a [Realtime](/docs/api/realtime-sdk) client, which maintains a
@@ -51,7 +70,7 @@ Use the [`get()`](/docs/api/realtime-sdk/channels#get) method to create or retri
5170

5271
<Code>
5372
```javascript
54-
const channel = realtime.channels.get('{{RANDOM_CHANNEL_NAME}}');
73+
const channel = realtime.channels.get('ai:{{RANDOM_CHANNEL_NAME}}');
5574
```
5675
</Code>
5776

@@ -193,7 +212,7 @@ await channel.subscribe((msg) => {
193212
responses.set(msg.serial, current + msg.data);
194213
break;
195214
case 'message.update':
196-
// Replace entire response content (e.g. from rewind)
215+
// Replace entire response content
197216
responses.set(msg.serial, msg.data);
198217
break;
199218
}
@@ -473,27 +492,3 @@ data would be simply:
473492
```text
474493
Hello world!
475494
```
476-
477-
## Requirements and restrictions
478-
479-
### Channel rule
480-
481-
Message append functionality requires the "Message annotations, updates, and deletes" [channel
482-
rule](/docs/channels#rules) enabled for your channel or [namespace](/docs/channels#namespaces).
483-
This rule automatically enables messages persistence.
484-
485-
Enabling the channel rule:
486-
487-
1. Go to the [Ably dashboard](https://www.ably.com/dashboard) and select your app.
488-
2. Navigate to the "Configuration" > "Rules" section from the left-hand navigation bar.
489-
3. Choose "Add new rule".
490-
4. Enter a channel name or namespace pattern (e.g. `ai:*` for all channels starting with `ai:`).
491-
5. Select the "Message annotations, updates, and deletes" rule from the list.
492-
6. Click "Create channel rule".
493-
494-
### Message size limits
495-
496-
Standard Ably message [size limits](/docs/platform/pricing/limits#message) apply to the complete
497-
concatenated message. The system validates size limits before accepting append operations. If
498-
appending a token would exceed the maximum message size, the append is rejected.
499-

0 commit comments

Comments
 (0)