Dsxir.Stream.Event (dsxir v0.5.0)

Copy Markdown

Unified streaming event surfaced to a :stream consumer of Dsxir.Predictor.Predict.

Predict translates each Dsxir.LM.StreamChunk into one of these and, when listen: names output fields, injects :field_delta events carrying marker-stripped field content. A single sink therefore sees the whole stream; a UI answer-box filters to :field_delta for its field while a raw-output view consumes :token. The :type tag selects the payload:

  • :tokendata is the raw text delta straight from the model (markers and all); the unfiltered firehose.
  • :field_deltadata is a fragment of a listened output field's value, markers stripped; field names the field. Only emitted for fields named in listen:.
  • :reasoningdata is a reasoning-text fragment.
  • :tool_calldata is %{id, name, arguments_delta}.
  • :usagedata is a %Dsxir.Cost{}.
  • :done — terminal success; data is the final accumulator (often nil).
  • :error — terminal failure; data is a Dsxir.Errors.LM.*.

field is nil for every type except :field_delta.

Summary

Types

t()

@type t() :: %Dsxir.Stream.Event{data: term(), field: atom() | nil, type: type()}

type()

@type type() ::
  :token | :field_delta | :reasoning | :tool_call | :usage | :done | :error