Jido.Chat.StreamChunk (Jido Chat v1.0.0)

Copy Markdown View Source

Typed stream input chunk used by outbound stream payloads.

Summary

Functions

Returns the best text fallback for the chunk.

Builds a stream chunk from serialized map data.

Creates a stream chunk from normalized map input.

Normalizes supported stream chunk inputs.

Normalizes a list of stream chunk inputs.

Returns the Zoi schema for StreamChunk.

Builds a text chunk.

Serializes a stream chunk into a plain map with type marker.

Types

input()

@type input() :: t() | String.t() | map()

t()

@type t() :: %Jido.Chat.StreamChunk{
  kind:
    :text | :markdown | :status | :plan | :data | :step_start | :step_finish,
  metadata: map(),
  payload: nil | nil | any(),
  text: nil | nil | binary()
}

Functions

fallback_text(value)

@spec fallback_text(t() | String.t()) :: String.t()

Returns the best text fallback for the chunk.

from_map(map)

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

Builds a stream chunk from serialized map data.

new(chunk)

Creates a stream chunk from normalized map input.

normalize(chunk)

@spec normalize(input()) :: t() | String.t()

Normalizes supported stream chunk inputs.

normalize_many(chunks)

@spec normalize_many([input()]) :: [t() | String.t()]

Normalizes a list of stream chunk inputs.

schema()

Returns the Zoi schema for StreamChunk.

text(value, opts \\ [])

@spec text(String.t(), keyword() | map()) :: t()

Builds a text chunk.

to_map(chunk)

@spec to_map(t()) :: map()

Serializes a stream chunk into a plain map with type marker.