Jido.Chat.PostPayload (Jido Chat v1.0.0)

Copy Markdown View Source

Typed normalized outbound payload used by thread/channel posting helpers.

Summary

Functions

Returns the best text fallback for the payload.

Builds post payload from serialized data.

Creates a normalized post payload.

Returns outbound attachments including normalized file uploads.

Returns the Zoi schema for PostPayload.

Builds a stream payload marker.

Builds a stream payload from chunk input.

Builds a text payload.

Serializes post payload into plain map with type marker.

Returns upload candidates preserving canonical file inputs where present.

Types

t()

@type t() :: %Jido.Chat.PostPayload{
  ast: nil | nil | any(),
  attachments: [
    %Jido.Chat.Attachment{
      data: term(),
      duration: term(),
      filename: term(),
      height: term(),
      kind: term(),
      media_type: term(),
      metadata: term(),
      path: term(),
      size_bytes: term(),
      url: term(),
      width: term()
    }
  ],
  card: nil | nil | any(),
  fallback_text: nil | nil | binary(),
  files: [
    %Jido.Chat.FileUpload{
      data: term(),
      duration: term(),
      filename: term(),
      height: term(),
      kind: term(),
      media_type: term(),
      metadata: term(),
      path: term(),
      size_bytes: term(),
      url: term(),
      width: term()
    }
  ],
  formatted: nil | nil | binary(),
  kind: :text | :markdown | :raw | :ast | :card | :stream,
  markdown: nil | nil | binary(),
  metadata: map(),
  raw: nil | nil | any(),
  stream: nil | nil | any(),
  text: nil | nil | binary()
}

Functions

display_text(payload)

@spec display_text(t()) :: String.t() | nil

Returns the best text fallback for the payload.

from_map(map)

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

Builds post payload from serialized data.

new(payload)

@spec new(map() | t()) :: t()

Creates a normalized post payload.

outbound_attachments(payload)

@spec outbound_attachments(t()) :: [Jido.Chat.Attachment.t()]

Returns outbound attachments including normalized file uploads.

schema()

Returns the Zoi schema for PostPayload.

stream()

@spec stream() :: t()

Builds a stream payload marker.

stream(chunks, opts)

@spec stream(term(), keyword() | map()) :: t()

Builds a stream payload from chunk input.

text(value, opts \\ [])

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

Builds a text payload.

to_map(payload)

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

Serializes post payload into plain map with type marker.

upload_candidates(payload)

@spec upload_candidates(t()) :: [Jido.Chat.Attachment.t() | Jido.Chat.FileUpload.t()]

Returns upload candidates preserving canonical file inputs where present.