T
tRPC

Streaming responses (eg. for streaming ai chat completion text)

Streaming responses (eg. for streaming ai chat completion text)

Ssebbbbbbbbbbbbbbb6/17/2023
Hello! Has anyone used Vercel's ai package or any similar libraries which stream their responses with tRPC? I'm wondering what the best way to achieve a streamed response like that is while maintaining type safety. The trouble with useSubscription() is that it behaves more like a query than a mutation, so it would need to be called immediately when the component mounts rather than being triggered by some user action.
Ssebbbbbbbbbbbbbbb6/19/2023
Glad to have found that it looks like others are thinking about this feature as well: - https://github.com/trpc/trpc/pull/4530 - https://github.com/trpc/trpc/pull/4489 - https://github.com/trpc/trpc/issues/4477 Seems like the best option for now is to stream such responses outside of tRPC while waiting for one of those PRs to land. But if there are any better workarounds for now, do let me know!

Looking for more? Join the community!

T
tRPC

Streaming responses (eg. for streaming ai chat completion text)

Join Server