Dsxir. LM. StreamChunk
(dsxir v0.5.0)
Copy Markdown
Provider-neutral streaming event emitted by a Dsxir.LM implementation when a
:stream callback is passed to generate_text/3.
Implementations translate their provider SDK's chunk type into this struct so
consumers never depend on a specific provider (the same boundary Dsxir.Cost
and Dsxir.Errors.LM.* draw for usage and errors). The :type tag selects
what :data carries:
:text_delta—datais aString.t()fragment of generated text.:reasoning_delta—datais aString.t()fragment of reasoning text.:tool_call_delta—datais%{id: String.t(), name: String.t() | nil, arguments_delta: String.t()}.:usage—datais a%Dsxir.Cost{}with final token counts.:done— terminal success;datais the final accumulator (oftennil).:failed/:incomplete/:cancelled— terminal failure;datais aDsxir.Errors.LM.*describing why the stream halted.
index disambiguates parallel tool calls or multiple choices when the provider
supplies it; it is nil otherwise.
Summary
Types
@type t() :: %Dsxir.LM.StreamChunk{ data: term(), index: non_neg_integer() | nil, type: type() }
@type type() ::
:text_delta
| :reasoning_delta
| :tool_call_delta
| :usage
| :done
| :failed
| :incomplete
| :cancelled