adk_llm_compatible_stream (erlang_adk v0.8.0)

View Source

Bounded raw-SSE assembler for compatible Chat Completions streams.

feed/2 accepts arbitrary HTTP/TCP byte chunks and delegates SSE framing to adk_model_sse_decoder. This module then validates Chat Completions deltas, assembles interleaved parallel tool calls by numeric index, and creates one checked provider result when [DONE] is received.

Summary

Functions

Feed raw SSE bytes. The terminal form retains emissions produced by earlier events in the same byte chunk, so a coalesced delta plus [DONE] can never lose text delivered to the caller.

Types

emission/0

-type emission() :: {text, binary()}.

state/0

-type state() :: map().

Functions

content(State)

-spec content(state()) -> {ok, adk_content:content()} | {error, term()}.

feed(State, Chunk)

-spec feed(state(), binary()) ->
              {ok, state(), [emission()]} |
              {done, adk_provider_result:result(), state(), [emission()]} |
              {error, term()}.

Feed raw SSE bytes. The terminal form retains emissions produced by earlier events in the same byte chunk, so a coalesced delta plus [DONE] can never lose text delivered to the caller.

finish(State)

-spec finish(state()) -> {ok, adk_provider_result:result()} | {error, term()}.

new()

-spec new() -> {ok, state()} | {error, term()}.

new(Options)

-spec new(map()) -> {ok, state()} | {error, term()}.

result(State)

-spec result(state()) -> {ok, adk_provider_result:result()} | {error, term()}.