本页还没有译文
本页 3 段还没译成Español,下面显示的是英文原文。Stream Object
还没翻译译自英文(ai-sdk.dev)本页 3 段都还没译
Object generation can sometimes take a long time to complete, especially when you're generating a large schema.
In Generative UI use cases, it is useful to stream the object to the client in real-time
to render UIs as the object is being generated.
You can use streamText with Output.object to generate partial object streams.
import { streamText, Output } from 'ai';
import { z } from 'zod';
const { partialOutputStream } = streamText({
model: 'openai/gpt-6-astra',
output: Output.object({
schema: z.object({
recipe: z.object({
name: z.string(),
ingredients: z.array(z.string()),
steps: z.array(z.string()),
}),
}),
}),
prompt: 'Generate a lasagna recipe.',
});
for await (const partialObject of partialOutputStream) {
console.clear();
console.log(partialObject);
}AI 翻译查看英文原文