Go LLM SDK for streaming, tool-calling AI backends (plus frontend React lib)
Posted by matryer 4 days ago
Comments
Comment by iJohnDoe 4 days ago
If I was going to write a Go application to utilize the OpenAI API, is there a reason to use this vs. just making calls directly to the OpenAI API?
Genuine questions so I can understand and learn more.
Comment by zknill 4 days ago
When you make an LLM call, if you use the streaming responses (typical of token streaming into applications) then the response from the LLM provider comes in a specific format; mostly made up of individual json events, one for each text-delta or token generated, and some framing around start/stop. That API format differs across different LLM providers, and also isn't that convenient to process for what you actually want to show in the client/browser.
The backend portion of these sdks (AI-SDK) are an abstraction over the LLM provider, and re-write the 'events' that you get back from the LLM provider into an abstracted json format that's a little bit easier to work with. And not coupled to a specific provider.
The frontend portion of these SDKs (AI UI SDK) helps you to render those message into a frontend interface, and uses the same abstracted format that the backend uses.
There's one big missing piece though, and that's the fact that the transport between frontend and backend is over a single HTTP+SSE stream. If that connection fails, all the work that the backend is doing cannot be transported to the frontend anymore. The HTTP connection also doesn't allow for useful features like cancellation, steering, interruption, and multiple devices.
If you want those, checkout Ably AI Transport, which targeting the _transport_ section between backend and frontend, to make sure you get reliable experiences in the UI regardless of which AI provider or SDKs you use.
Disclaimer, I work for ably on this product:
Comment by zknill 4 days ago
I think they really missed the opportunity to add in resumable streaming after a dropped SSE connection, or multi-device support. Because these SDKs are easy to drop-in to your applications, but hard once you actually try and build resilient systems on top of them. Systems that can heal from dropped connections, or support multiple users or multiple devices.
Comment by verdverm 4 days ago
https://adk.dev/get-started/about/ | https://github.com/google/adk-go
Comment by ivanvanderbyl 3 days ago
Instead of writing a Go converter to use it with AI SDK Elements, we added this client side and use ADKs SSE streaming and recovery out of the box.
Comment by gregfurman 4 days ago
Comment by throwaway894345 4 days ago
Comment by helsinki 3 days ago
Comment by Merkur 4 days ago
Comment by jnstrdm05 4 days ago
Comment by yakimbo90 4 days ago
Comment by champagnepapi 4 days ago
These days I am very very cautious about the quality of packages. I’ve become a lot more reluctant/hesitant (which is not to say prior I was in favor of just adding packages left and right). I was still conservative, but these days I’ve become much much more conservative when it comes to adding a package to a production system.
I will review this later and report back for the community
Comment by geodel 4 days ago
"Go port of Vercel's AI SDK (github.com/grafana/ai-sdk), providing streaming LLM orchestration wire-compatible with @ai-sdk/react"
Comment by nkapila6 4 days ago
Btw, the emdash in the repo description is a giveaway too.
Comment by champagnepapi 4 days ago
Comment by win311fwg 4 days ago
However, that person worked for Vercel, so be aware that the design is apt to be questionable. Another comment has already pointed out some of the core design flaws, as is emblematic of everything that comes out of Vecel.
But you may find it useful if you have to integrate into that ecosystem.
Comment by 8bitsout 4 days ago