ReqLLM.Message.ContentPart (ReqLLM v1.0.0-rc.5)

View Source

ContentPart represents a single piece of content within a message.

Supports multiple content types:

  • :text - Plain text content
  • :image_url - Image from URL
  • :image - Image from binary data
  • :file - File attachment
  • :tool_call - Tool invocation
  • :tool_result - Tool execution result
  • :thinking - Chain-of-thought thinking content

See also

  • ReqLLM.Message - Multi-modal message composition using ContentPart collections

Summary

Types

t()

@type t() :: %ReqLLM.Message.ContentPart{
  data: binary() | nil,
  filename: String.t() | nil,
  input: term() | nil,
  media_type: String.t() | nil,
  metadata: map(),
  output: term() | nil,
  text: String.t() | nil,
  tool_call_id: String.t() | nil,
  tool_name: String.t() | nil,
  type:
    :text | :image_url | :image | :file | :tool_call | :tool_result | :thinking,
  url: String.t() | nil
}

Functions

file(data, filename, media_type \\ "application/octet-stream")

@spec file(binary(), String.t(), String.t()) :: t()

image(data, media_type \\ "image/png")

@spec image(binary(), String.t()) :: t()

image_url(url)

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

text(content)

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

text(content, metadata)

@spec text(String.t(), map()) :: t()

thinking(content)

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

thinking(content, metadata)

@spec thinking(String.t(), map()) :: t()

tool_call(id, name, input)

@spec tool_call(String.t(), String.t(), term()) :: t()

tool_result(id, output)

@spec tool_result(String.t(), term()) :: t()

valid?(arg1)

@spec valid?(t()) :: boolean()