Jido.Chat.Content.Image (Jido Chat v1.0.0)

Copy Markdown View Source

Image content block for messages.

Represents an image attachment in a message. Supports both URL-based and base64-encoded images.

Fields

  • url - URL to the image (optional if data is provided)
  • data - Base64-encoded image data (optional if url is provided)
  • media_type - MIME type (e.g., "image/png", "image/jpeg")
  • alt_text - Alternative text description
  • width - Image width in pixels (optional)
  • height - Image height in pixels (optional)

Examples

Image.new("https://example.com/photo.jpg")
Image.new("https://example.com/photo.jpg", media_type: "image/jpeg", alt_text: "A photo")
Image.from_base64(base64_data, "image/png")

Summary

Functions

Creates a new image content block from base64-encoded data.

Creates a new image content block from a URL.

Returns the Zoi schema for Image content

Types

t()

@type t() :: %Jido.Chat.Content.Image{
  alt_text: nil | nil | binary(),
  data: nil | nil | binary(),
  height: nil | nil | integer(),
  media_type: nil | nil | binary(),
  type: :image,
  url: nil | nil | binary(),
  width: nil | nil | integer()
}

Functions

from_base64(data, media_type, opts \\ [])

Creates a new image content block from base64-encoded data.

Parameters

  • data - Base64-encoded image data
  • media_type - MIME type (required for base64 images)
  • opts - Additional options (alt_text, width, height)

new(url, opts \\ [])

Creates a new image content block from a URL.

Options

  • :media_type - MIME type of the image
  • :alt_text - Alternative text description
  • :width - Image width in pixels
  • :height - Image height in pixels

schema()

Returns the Zoi schema for Image content