Vercel AI SDK Stremaing
Unanswered
Pacific sand lance posted this in #help-forum
Pacific sand lanceOP
Does anyone know how i can return this stream data from my api in a compatible way with useChat hook
import { streamText } from 'ai';
import { openai } from '@ai-sdk/openai';
const result = await streamText({
model: openai('gpt-3.5-turbo'),
maxTokens: 1024,
system: 'You are a helpful chatbot.',
messages: [
{
role: 'user',
content: 'Hello!',
},
{
role: 'assistant',
content: 'Hello! How can I help you today?',
},
{
role: 'user',
content: 'I need help with my computer.',
},
],
});
for await (const textPart of result.textStream) {
console.log(textPart);
}