Normandy.Components.ContentBlock.Protocol protocol
(normandy v2.2.0)
View Source
What every consumer needs from a content block, answered by the block itself.
Normandy.Components.ContentBlock.Text, Image and Document implement it, so
the adapter, the token counter, the window manager and the summarizer call the
protocol instead of switching on the block structs. A new block type implements
the three functions and every consumer handles it.
Raw Anthropic block maps (%{"type" => "text", ...}) are not blocks in this
sense; consumers pass them through or read them as data.
Summary
Functions
An estimate of the tokens the block adds to a request, never below zero.
A short human-readable line for the block: its text, or a placeholder such as
"[image]". Used in summaries and debug previews.
The block as the Anthropic/Claudio content-block map (string keys).
Types
@type t() :: term()
All the types that implement this protocol.
Functions
@spec estimate_tokens(t()) :: non_neg_integer()
An estimate of the tokens the block adds to a request, never below zero.
A short human-readable line for the block: its text, or a placeholder such as
"[image]". Used in summaries and debug previews.
The block as the Anthropic/Claudio content-block map (string keys).
Raises ArgumentError for a block that cannot be sent (for example a document
whose source is not :file_id).