Current section

Files

Jump to
liter_llm lib liter_llm assistant_part.ex
Raw

lib/liter_llm/assistant_part.ex

# This file is auto-generated by alef — DO NOT EDIT.
# alef:hash:7944d9976ed5e784d58bb60b20a64df43c6faa98460b1282aa94dfadc636b045
# To regenerate: alef generate
# To verify freshness: alef verify --exit-code
defmodule LiterLlm.AssistantPart do
@moduledoc """
One part of a structured assistant response.
`#[serde(tag = "type", rename_all = "snake_case")]` matches OpenAI's
parts-spec discriminator (`"type": "text"`, `"type": "output_image"`, …).
"""
@typedoc "One part of a structured assistant response."
@type t :: term()
@typedoc "A text segment of the response."
@type text :: %{type: :text, text: String.t()}
@typedoc "A refusal — the model declined to respond."
@type refusal :: %{type: :refusal, refusal: String.t()}
@typedoc "An image produced by the model (e.g. `gpt-image-1`, Gemini Imagen)."
@type output_image :: %{type: :output_image, image_url: LiterLlm.ImageUrl.t()}
@typedoc "Audio produced by the model (e.g. `gpt-4o-audio-preview`)."
@type output_audio :: %{type: :output_audio, audio: LiterLlm.AudioContent.t()}
def text(text), do: {:text, %{text: text}}
def refusal(refusal), do: {:refusal, %{refusal: refusal}}
def output_image(image_url), do: {:output_image, %{image_url: image_url}}
def output_audio(audio), do: {:output_audio, %{audio: audio}}
end