GEPA.Image (GEPA v0.3.0)

Copy Markdown View Source

Image data wrapper for visual side-information in GEPA.OptimizeAnything.

Include %GEPA.Image{} values anywhere inside evaluator side-info or reflective-dataset records. GEPA.Proposer.InstructionProposal detects these values, replaces them with [IMAGE-N] placeholders in the textual prompt, and appends OpenAI-compatible multimodal content parts to the reflection LLM call.

Provide exactly one of :url, :path, or :base64_data.

Summary

Functions

Create an image wrapper from raw base64 bytes and a MIME type.

Create an image wrapper from a local path.

Create an image wrapper from a URL or data URI.

Return the MIME type for a path-backed image, defaulting to image/png.

Create an image wrapper from keyword or map options.

Convert to an OpenAI-compatible multimodal image_url content part.

Validate an image wrapper, raising on invalid source combinations.

Types

t()

@type t() :: %GEPA.Image{
  base64_data: String.t() | nil,
  media_type: String.t() | nil,
  path: Path.t() | nil,
  url: String.t() | nil
}

Functions

from_base64(base64_data, media_type)

@spec from_base64(String.t(), String.t()) :: t()

Create an image wrapper from raw base64 bytes and a MIME type.

from_path(path, media_type \\ nil)

@spec from_path(Path.t(), String.t() | nil) :: t()

Create an image wrapper from a local path.

from_url(url)

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

Create an image wrapper from a URL or data URI.

media_type(image)

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

Return the MIME type for a path-backed image, defaulting to image/png.

new(opts)

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

Create an image wrapper from keyword or map options.

to_openai_content_part(image)

@spec to_openai_content_part(t()) :: map()

Convert to an OpenAI-compatible multimodal image_url content part.

validate!(image)

@spec validate!(t()) :: t()

Validate an image wrapper, raising on invalid source combinations.