LlmCore.LLM.SSEParser (llm_core v0.3.0)

Copy Markdown View Source

Helper module for parsing Server-Sent Events (SSE) from LLM APIs.

Summary

Functions

Parses a raw SSE line and extracts the data payload.

Accumulates streamed chunks into a single content string. Useful for non-streaming consumers or testing.

Functions

parse_line(line)

@spec parse_line(String.t()) :: {:ok, map()} | :done | :ignore

Parses a raw SSE line and extracts the data payload.

Returns {:ok, data} if data is found, :done if stream end signal, or :ignore.

reduce_chunks(enum)

@spec reduce_chunks(Enumerable.t()) :: String.t()

Accumulates streamed chunks into a single content string. Useful for non-streaming consumers or testing.