I’m looking to build on top of the Assistants API and I’m having troubles figuring out the streaming portion of my app. I’m using Remix and I’m not sure how to handle the stream.
- Should I call an endpoint using a fetcher to get the stream itself and parse the stream?
- Should I have the endpoint filter data and then send it to the client?
I’ve found this Next.js example from Open AI and they handle the stream on the frontend which (to me) seems like the incorrect way to handle things in Remix. I’d like to use as few hooks as possible and just send everything down as a minimal list while still having the streaming and/or “typing” style reponse.
1 Like
If you’d like you can go straight into the Streams API.
All needed to be done is setup an intermediate process that performs any work on the incoming stream (like stripping away the metadata) and then passes the content directly to the user through whatever way you seem fit (could be held in a state)
You can set this up using the TransformStream
interface.
Yes(ish). You almost always want to run the stream through your server first if you are providing a service to clients. You don’t necessarily need to read it though.
3 Likes
Thanks @anon10827405 - I was actually introduced to this package by Vercel https://sdk.vercel.ai/ and it seems to be doing what I need it to do.
1 Like
For most frameworks that you can deploy on vercel, their AI SDK
should serve most purposes. Including streaming.