docs: add chain-of-thought streaming guides for OpenAI and Anthropic#3135
docs: add chain-of-thought streaming guides for OpenAI and Anthropic#3135GregHolmes wants to merge 2 commits intomainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
044afc9 to
0940eea
Compare
zknill
left a comment
There was a problem hiding this comment.
I'm not sure that Step 3 and Step 5 make sense, they aren't "steps" in how to do it, they are entirely different patterns.
I think we need an intro that explains the two patterns and the differences, and then I think we need to remove the "Step" headers, or make it clear that they are not really "Steps" like how the other guides are
| ```json | ||
| // 1. Reasoning summary tokens stream in | ||
| {"type":"response.reasoning_summary_text.delta","delta":"**Determining the capital of France**\n\n"} | ||
| {"type":"response.reasoning_summary_text.delta","delta":"The user's question is straightforward..."} | ||
|
|
||
| // 2. Output tokens stream in | ||
| {"type":"response.output_text.delta","delta":"The capital of France is Paris."} | ||
| {"type":"response.output_text.delta","delta":" Here's the reasoning:"} | ||
|
|
||
| // 3. Response completes | ||
| {"type":"response.completed","response":{...}} | ||
| ``` | ||
| </Code> |
There was a problem hiding this comment.
I don't think these tokens make sense in this order?
There was a problem hiding this comment.
You're right! The output content didn't really make sense when we've already got the reasoning being shown separately. I've changed the second output delta to the actual information. It has been the capital since the 10th century. instead if Here's the reasoning:
| ``` | ||
| </Code> | ||
|
|
||
| The `publish` call creates an initial empty message and returns its `serial`. Subsequent `appendMessage` calls add tokens to that message. Don't await `appendMessage` calls - Ably batches acknowledgments for efficiency. |
There was a problem hiding this comment.
Don't await
appendMessagecalls - Ably guarantees that deltas appended to the same message serial will always remain in-order.
I don't think anyone will know / understand what ACKs are here, and batching them isn't really the reason to await an append. It's a throughput thing really.
There was a problem hiding this comment.
Good point, I've removed ACK, talked about the throughput and why we're not awaiting.
|
|
||
| ## Step 5: Stream reasoning with the threading pattern <a id="step-5"/> | ||
|
|
||
| The threading pattern publishes reasoning to a separate channel. This allows clients to subscribe to reasoning alongside output, while keeping them on separate channels for flexibility. |
There was a problem hiding this comment.
What is the "flexibility" that this provides?
Let's give a real reason here, because I don't think "flexibility" is a reason (without qualifying why it's more flexible)
In fact, I'd argue it's harder to work with because the customer won't get ordering between reasoning and regular message. Which makes me think; do we even want to promote 2 channels as a pattern? I can't see why you'd want that.
There was a problem hiding this comment.
True, I've replaced the flexibility it with more concrete reasons.
0940eea to
c080243
Compare
ae4969e to
c9dc512
Compare
Thanks Zak for the review. I've moved things around and made changes following from your feedback. I've kept it in a fixup so you can see the difference. When you have some time could I please ask you to re-review this guide? |
c9dc512 to
20f5f00
Compare
20f5f00 to
84df719
Compare
Add two new AI Transport guides demonstrating how to stream chain-of-thought reasoning from thinking models over Ably: - openai-chain-of-thought.mdx: Stream reasoning from OpenAI o1/o3 models - anthropic-chain-of-thought.mdx: Stream extended thinking from Claude Both guides cover: - Inline pattern (reasoning and output on same channel) - Threading pattern (reasoning on separate on-demand channels) - Event handling for reasoning vs output tokens - Message-per-response pattern with serial-based tracking
207b166 to
a7651d9
Compare
a7651d9 to
77a07eb
Compare
Sorry @zknill yep, it was broken. I've fixed and made a few further changes through the docs. I hope you enjoy. |


docs: add chain-of-thought streaming guides for OpenAI and Anthropic
Add two new AI Transport guides demonstrating how to stream
chain-of-thought reasoning from thinking models over Ably:
Both guides cover: