Skip to content

Commit b37d4b7

Browse files
committed
fix(docs): AI streaming example uses streamText and thread.post
Thread has no .stream() method and generateText has no .textStream. Correct pattern: streamText() returns { textStream } and thread.post() accepts AsyncIterable<string> directly.
1 parent 53fb7f2 commit b37d4b7

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,21 +181,21 @@ await thread.post(
181181

182182
## AI Streaming
183183

184-
Stream AI responses with the post+edit pattern (works best on Telegram):
184+
Stream AI responses with the post+edit pattern (works best on Telegram). `thread.post()` accepts an `AsyncIterable<string>`, so you can pass the `textStream` from `streamText` directly:
185185

186186
```typescript
187-
import { generateText } from "ai";
187+
import { streamText } from "ai";
188188
import { openai } from "@ai-sdk/openai";
189189

190190
bot.onNewMessage(/.*/, async (thread, message) => {
191-
const result = await generateText({
191+
const result = streamText({
192192
model: openai("gpt-4o"),
193193
prompt: message.text,
194194
});
195195

196196
// On Telegram: posts initial message, edits as tokens arrive
197197
// On other platforms: collects full response, posts once
198-
await thread.stream(result.textStream);
198+
await thread.post(result.textStream);
199199
});
200200
```
201201

0 commit comments

Comments
 (0)