SSEParser

org.llm4s.llmconnect.streaming.SSEParser
@Stable
object SSEParser

Server-Sent Events (SSE) parser for streaming LLM responses.

Handles the SSE format used by both OpenAI and Anthropic streaming endpoints. SSE format consists of fields like:

  • data:
  • event:
  • id:
  • retry:
  • :

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
SSEParser.type

Members list

Type members

Classlikes

final case class SSEEvent

Represents a parsed SSE event

Represents a parsed SSE event

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object SSEEvent

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
SSEEvent.type

Parse streaming data with a buffer for incomplete events. This is useful for parsing data as it arrives from a network stream.

Parse streaming data with a buffer for incomplete events. This is useful for parsing data as it arrives from a network stream.

Attributes

Supertypes
class Object
trait Matchable
class Any

Value members

Concrete methods

Create a new streaming parser instance

Create a new streaming parser instance

Attributes

def parseEvent(eventString: String): SSEEvent

Parse a single SSE event from a string. An event is terminated by a double newline.

Parse a single SSE event from a string. An event is terminated by a double newline.

Attributes

def parseStream(stream: String): Iterator[SSEEvent]

Parse a stream of SSE data into individual events. Returns an iterator of SSEEvents.

Parse a stream of SSE data into individual events. Returns an iterator of SSEEvents.

Attributes