A PNG or JPEG to send with a call.
An image goes into a request by its reference, a string that stands for it. Put
the TypeSafe.Image where it belongs in the state or in a question, and pass it
in the :images option of TypeSafe.system_one/4. It encodes to JSON as its
reference and interpolates as it, so it can sit inside a map or a string:
photo = TypeSafe.Image.from_file!("kitchen.jpg")
TypeSafe.system_one(client, %{photo: photo}, %{
mug: TypeSafe.box("The coffee mug in `photo`")
}, model: "jev-1.14.0", images: [photo])Every use of a reference sends another copy of the image to the model, and images
are billed as input tokens. They work with jev-1.13.0 and jev-1.14.0.
The API rejects what it can't use: a side shorter than 280 or longer than 1568 pixels, a file over 16 MiB, or anything other than PNG and JPEG. It doesn't resize. Rotate the pixels upright first, because EXIF orientation is not applied.
Summary
Functions
An image from the bytes of a PNG or JPEG file. Returns
{:error, :unsupported_format} for anything else, such as GIF, WebP or HEIC.
Like from_binary/1, but returns the image or raises ArgumentError.
An image read from a PNG or JPEG file. Returns {:error, reason} with a
File.read/1 reason, or :unsupported_format.
Like from_file/1, but returns the image or raises ArgumentError.
Types
Functions
An image from the bytes of a PNG or JPEG file. Returns
{:error, :unsupported_format} for anything else, such as GIF, WebP or HEIC.
Like from_binary/1, but returns the image or raises ArgumentError.
@spec from_file(Path.t()) :: {:ok, t()} | {:error, File.posix() | :unsupported_format}
An image read from a PNG or JPEG file. Returns {:error, reason} with a
File.read/1 reason, or :unsupported_format.
Like from_file/1, but returns the image or raises ArgumentError.