View Source Anthropic.Messages.Message (anthropic_community v0.5.0)

A message returned by the Anthropic Messages API — the {:ok, message} result of Anthropic.Messages.create/2 or the final fold of Anthropic.Messages.stream/2.

Summary

Functions

Converts this message into a plain map suitable for the messages request param, for continuing a conversation (tool-use loop, multi-turn chat).

True if this message is asking the caller to run tools.

All tool_use content blocks in this message, in order.

Types

@type t() :: %Anthropic.Messages.Message{
  content: [Anthropic.Messages.Content.t()],
  id: String.t() | nil,
  model: String.t() | nil,
  role: String.t() | nil,
  stop_reason: String.t() | nil,
  stop_sequence: String.t() | nil,
  type: String.t() | nil,
  usage: map()
}

Functions

@spec from_json(map()) :: t()
@spec to_param(t()) :: map()

Converts this message into a plain map suitable for the messages request param, for continuing a conversation (tool-use loop, multi-turn chat).

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

True if this message is asking the caller to run tools.

@spec tool_uses(t()) :: [Anthropic.Messages.Content.ToolUse.t()]

All tool_use content blocks in this message, in order.