Tinkex.Types.SampleStreamChunk (Tinkex v0.3.4)

View Source

Represents a single chunk from a streaming sample response.

Chunks are emitted incrementally during SSE-based streaming sampling, allowing real-time token-by-token processing of model output.

Summary

Functions

Create a done chunk indicating stream completion.

Check if this is the final chunk in a stream.

Create an error chunk.

Create a SampleStreamChunk from a parsed SSE event map.

Types

t()

@type t() :: %Tinkex.Types.SampleStreamChunk{
  event_type: :token | :done | :error,
  finish_reason: String.t() | nil,
  index: non_neg_integer() | nil,
  logprob: float() | nil,
  token: String.t() | nil,
  token_id: integer() | nil,
  total_tokens: non_neg_integer() | nil
}

Functions

done(finish_reason \\ nil, total_tokens \\ nil)

@spec done(String.t() | nil, non_neg_integer() | nil) :: t()

Create a done chunk indicating stream completion.

done?(arg1)

@spec done?(t()) :: boolean()

Check if this is the final chunk in a stream.

error(message)

@spec error(String.t()) :: t()

Create an error chunk.

from_map(map)

@spec from_map(map()) :: t()

Create a SampleStreamChunk from a parsed SSE event map.