and then I can't get stream output, I have tried many times, but still can't stream output. I don't know why. Has anyone encountered the same problem as me?
Hi , welcome to the Vercel Community! Thanks for posting your question here.
I'll try to recreate the issue and debug it with you. Meanwhile, I notice that in the code snippet above you pass the data: streamingData to the console.log statement but not in the return result.toDataStreamResposne() statement. Can you confirm this from your application code?
It'd also be helpful if you could share a larger code snippet for better context of the variables used and also can you confirm what is the exact output do you see: is it nothing or is it the text you expect but just not streaming?
"Hi , thanks for your help!
If I run this: return result.toDataStreamResponse({ data: streamingData });, the issue arises right there.
Vercel Staff
Hi Taype, to help you debug this better could you answer a few questions for me?
What is the exact output do you see: is it nothing or is it the text you expect but just not streaming?
If you get an error in the console, could you share that here?
Also, it’d be very helpful if you could share a larger code snippet for better context of the variables used. If this is a public repository, you can also share the link to it here.
Hi , thanks for your help again
I got the text,but just not streaming.
I didn't get error in my console, it just not streaming output.
6.I didn't change the front-end code ,they are in here /components/custom/chat.tsx and /componets/custom/message.tsx
7. can i get your whatsapp or other chat app, so I can give you more info.
Thank you very much for help me.
Vercel Staff
Hi , thanks for providing more context. Let me try and recreate this to help you better.
can i get your whatsapp or other chat app, so I can give you more info.
I don't need any private information at this time, but even if we do, we can do so here on the community in a private space. I'll guide you when we need such information.
reply to #6
Vercel Staff
Hi , I was reading through the AI SDK docs and one difference I noticed in your code and the linked example is that you are doing
const result = await streamText({
Whereas the AI SDK docs suggest doing
const result = streamText({
I think using await consumes the stream and returns the text and that is why you see the text but not streaming. Can you try this change and see if it works?
Hi , thanks for your help again
I have tried it many times, and the streaming problem has been solved using your method, but my front end still takes a long time to return the first block of stream content. Can you help me take a look? I will post the code.
my back-end code: