Normalized message struct used across all LLM providers.
Represents a single message in a conversation, supporting system, user, assistant, and tool roles.
Summary
Functions
Creates a new message with validated attributes.
Types
@type attachment() :: %{data: binary(), mime_type: String.t()} | %{file_ref: ExAgent.FileRef.t()}
@type role() :: :system | :user | :assistant | :tool
Functions
Creates a new message with validated attributes.
Examples
iex> {:ok, msg} = ExAgent.Message.new(role: :user, content: "Hello")
iex> msg.role
:user
iex> ExAgent.Message.new(role: :invalid, content: "Hello")
{:error, "invalid role: :invalid. Must be one of: [:system, :user, :assistant, :tool]"}
iex> ExAgent.Message.new(role: :user)
{:error, "content is required"}