ExAgent.Providers.SSE (ExAgent v0.1.0)

Copy Markdown View Source

Turn a Req asynchronous response into a lazy Stream of Server-Sent-Events.

Req streams the body into the calling process mailbox when into: :self is used; this module wraps that into an idiomatic Elixir stream. Each emitted item is either:

  • a decoded JSON map (the payload of a data: frame),
  • {:error, reason}, or
  • :done — emitted once as the very last item, signalling end-of-stream.

Used by the OpenAI and Anthropic adapters' request_stream/4.

Summary

Functions

stream(resp, opts \\ [])

@spec stream(
  Req.Response.t(),
  keyword()
) :: Enumerable.t()