|
I’m using tanstack/ai on the frontend, but my backend is written in Python and does not use TanStack AI internally. Instead, I map my backend responses to match the expected API format. Use case I want to send custom message types from the backend to the frontend, for example: Questions SSE simulation Since my backend is not TanStack-based, I also want to simulate the expected SSE stream. Is there: For example: In the meanwhile I still have https://github.com/nirtamir2/tanstack-ai-issues-reproduction/ to reproduce stuff, I tries to simulate the SSE - but I don't know what is "correct" |
Replies: 1 comment
|
I would not extend the core message-part protocol for this. Keep the backend stream mapped to the known TanStack/AG-UI events for normal chat output, tool calls, tool results, run start/end, etc., then put app-specific UI signals on the custom-event side channel. On the client, handle those with const chat = useChat({
connection: fetchServerSentEvents('/api/chat'),
onCustomEvent: (eventType, data, context) => {
// e.g. image progress, canvas updates, VM logs, etc.
// context.toolCallId lets you attach the event to a specific tool call
},
})For a Python backend, the safest shape is to write a small adapter layer: translate your backend's SSE into the standard event stream that |
I would not extend the core message-part protocol for this. Keep the backend stream mapped to the known TanStack/AG-UI events for normal chat output, tool calls, tool results, run start/end, etc., then put app-specific UI signals on the custom-event side channel.
On the client, handle those with
onCustomEvent:For a Python backend, the safest shape is to write a small adapter layer: translate your backend's SSE into the standard …