Skip to content

Conversation

@micahhahn
Copy link

Hey @bflyblue!

Much like the author of #4 I found myself wanting to use this library to parse SSE for communicating with an LLM API.

The work to do so was not so bad - I didn't realize that #5 existed though until after it was done. Perhaps for the better since I didn't have knowledge of the pre-Servant.API.Stream API.

Some notes:

  • Adding a FromServerEvent class fit well parity wise with ToServerEvent
  • I made the (probably breaking) change of converting ToServerEvent to Text. This matches the specs better which explicitly specify that streams must be UTF-8.
  • The spec says that newlines in the form of \r\n, \r, and \n should all be supported when interpreting a stream, so I've done that.
  • I needed to expose ServerEventFraming for my use case because I'm trying to make a streaming POST request. My endpoint looks like StreamPost ServerEventFraming EventStream (SourceIO x)
  • I went for the lightest touch possible changing this file, the tests from Rudimentary servant-client support and parsing of SSE events #5 are probably salvageable. We could also add roundtrip-tests around FramingRender <-> FramingUnrender and ToServerEvent <-> FromServerEvent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants