News for hackers. Stuff that matters.
Re:Server Sent Events by 0xCAP on Monday May 15, 2023 @03:39PM (#35953414)
Curious why is this trending? Btw sse are pretty great, only thing I don't get is why they don't allow for binary payloads. That'd have been the icing on the cake.
Re:Server Sent Events by asplake on Monday May 15, 2023 @03:41PM (#35953446)
Re:Server Sent Events by marpstar on Monday May 15, 2023 @04:02PM (#35953716)
My first thought was ChatGPT API's `stream` option: https://platform.openai.com/docs/api-reference/completions/c...
Re:Server Sent Events by corentin88 on Tuesday May 16, 2023 @04:47AM (#35959168)
OP here. I was looking at Anthropic's website as a result of https://news.ycombinator.com/item?id=35948742

Turns out in their FAQ, they have this:

> Our API is designed to be a backend that incorporates Claude into any application you’ve developed. Our application sends text to our API, then receives a response via *server-sent events*, a streaming protocol for the web. We have API documentation with drop-in example code in Python and Typescript to get you started.

Was curious what it was and thought it was probably worth sharing.

Didn't knew OpenAI uses the same mechanism.

Re:Server Sent Events by VWWHFSfQ on Monday May 15, 2023 @03:49PM (#35953540)
> only thing I don't get is why they don't allow for binary payloads

I've always appreciated that it's just a simple line-oriented UTF-8 text protocol. Binary transfers are handled more efficiently with something else. Or just base64 the payload if it's not that big of a deal.

Re:Server Sent Events by mikek on Monday May 15, 2023 @04:00PM (#35953696)
OpenAI uses this in their APIs to stream tokens
Re:Server Sent Events by b33j0r on Monday May 15, 2023 @04:22PM (#35953987)
This got into the zeitgeist somehow. I just implemented my first SSE app with FastAPI last week, then I saw a youtube video and this post!

I was implementing something with websockets and asked chatgpt to tell me about modern alternatives. In my years of full-stack… I hadn’t heard of SSE, or at least never got why I should care.

Damn, I see the limitations of REST, but I was building state machines and custom protocols with websockets. It’s nice to prototype in REST again.

REST+SSE ftw, I guess!

Re:Server Sent Events by bullen on Tuesday May 16, 2023 @03:02AM (#35958546)
String parsing is never the bottleneck. You need to parallelize (shared memory) and understand your system and for that text is pretty convenient.

So also avoid HTTPS.

It's trending because it's the final real-time solution for eternity.