ai icon indicating copy to clipboard operation
ai copied to clipboard

Add toDataStreamResponse for streamobject

Open dalton5 opened this issue 10 months ago • 3 comments

Feature Description

Hi,

Can you please add toDataStreamResponse for streamobject to get it to work in useChat with streamprotocol data.

Otherwise can you show a workarround?

the UseObject is not convenient because I can't change dynamically the schema.

And as a workarround possibly I could switch based on the needs on: streamprotocol text which works and then switch to data. But for now I can't switch dynamically.

PS: I use svelte.

Use Cases

No response

Additional context

No response

dalton5 avatar Mar 01 '25 17:03 dalton5

Can you tell me more about your use case?

One option could be to use streamText with structured outputs: https://sdk.vercel.ai/docs/ai-sdk-core/generating-structured-data#structured-outputs-with-generatetext-and-streamtext

lgrammel avatar Mar 03 '25 09:03 lgrammel

I would like to propose to user to choose structured output or normal chat response within the same usechat.

I have been able to fix it by forking the project in svelte and switch dynamically between streammode text or data.

And it works well. Now streamobject and streamtext works well in usechat

dalton5 avatar Mar 03 '25 13:03 dalton5

This would be great

botirk38 avatar Apr 21 '25 17:04 botirk38