Open himself65 opened 1 month ago
I think the streaming protocol should allow gives the id:id
for the first chunk
Hey,
Can't you use the 2: custom JSON added by the user using Data
using toDataStream ?
const data = new StreamData()
data.append('my-id')
const reader = this.stream_result.toDataStream({ data }).getReader()
Like this the first chunk will be your custom json.
Feature Description
We have a chat backend with persistence layer, so everytime user refresh page will keep track of the history messages. So it's necessary that keep message id constant everytime user popup a new message.
But I found that in StreamResponse protocol there is only possible to return text and data. But there's no
id
. and the reason ofgenerateId
is not working because it means id is generated from frontend, but for the ai message, it's actually generated from backend. So it won't work.Use Case
I have some features that will allow user to custimize ai chat message per different browser session. Like double click edit, mark, quote, and index sources. So it's important to keep id constant with backend.
Additional context
my current workaround