Arcanum.Response (arcanum v0.1.2)

Copy Markdown View Source

Canonical response struct from all inference calls.

Content is always a list of typed blocks — symmetric with Intent.

Chat Response

%Response{content: [%{type: :text, text: "Hello!"}]}

Streaming Delta

%Response{content: [%{type: :text, text: "chunk"}]}

Media Response

%Response{
  content: [
    %{type: :image, data: <<...>>, content_type: "image/png", revised_prompt: "..."}
  ]
}

Summary

Functions

Extracts all text from response content blocks, joined by newline. Returns nil if content is nil or contains no text blocks.

Types

t()

@type t() :: %Arcanum.Response{
  content: [Arcanum.Intent.content_block()] | nil,
  finish_reason: String.t() | nil,
  thinking: String.t() | nil,
  tool_calls: [tool_call()] | nil,
  usage: usage() | nil
}

tool_call()

@type tool_call() :: %{
  id: String.t(),
  function: %{name: String.t(), arguments: String.t()}
}

usage()

@type usage() :: %{
  prompt_tokens: non_neg_integer(),
  completion_tokens: non_neg_integer(),
  total_tokens: non_neg_integer()
}

Functions

text(response)

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

Extracts all text from response content blocks, joined by newline. Returns nil if content is nil or contains no text blocks.