You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 of generateId 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
onFinish: useCallback((message: Message)=>{// handle the AI message generated by the backend, because id is not returned in the response,// we need to fetch the latest session to get the id of the last messagegetChatSessionFromBackend({
sessionId,}).then((newSession)=>{constlastAIMessage=newSession.chat_messages?.sort((a,b)=>(a.index>b.index ? 1 : -1)).at(-1);if(lastAIMessage?.role!=="assistant"){throwunexpected()return;}else{constid=lastAIMessage.id;storeMessage({ ...message, id })// store message to indexeddb});}}).then(async()=>{awaitrefetch();})},[pipelineId,refetch],),
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: