Claudex.ContentBlock (Claudex v0.6.1)

Copy Markdown View Source

One block of content in a message. A reply from Claude is a list of these — usually just text, sometimes thinking or a tool call mixed in. decode/1 reads a block's "type" field and returns the matching struct.

Summary

Functions

Decodes one content block. Falls back to Claudex.ContentBlock.Unknown for a block type not modeled yet, so a new block type from the API never breaks decoding — it just arrives un-typed.

Turns a decoded block back into the map the API expects in a request, so a reply can be sent straight back as conversation history.

Types

Functions

decode(json)

@spec decode(map()) :: t()

Decodes one content block. Falls back to Claudex.ContentBlock.Unknown for a block type not modeled yet, so a new block type from the API never breaks decoding — it just arrives un-typed.

to_param(block)

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

Turns a decoded block back into the map the API expects in a request, so a reply can be sent straight back as conversation history.

A map is passed through untouched, so hand-written blocks keep working.