SkillKit.LLM.Anthropic.Encoder (SkillKit v0.4.0)

Copy Markdown View Source

Translates SkillKit.Types message structs to Anthropic Messages API format.

Summary

Functions

Builds an ephemeral cache_control map for the given TTL.

Tags the last content block of the last encoded message with cache_control.

Wraps a system prompt string in a cached text-block list.

Encodes a list of native message structs into Anthropic API message format.

Encodes Tool structs into Anthropic tool format.

Functions

cache_control(arg1)

Builds an ephemeral cache_control map for the given TTL.

cache_last_message(messages, ttl)

Tags the last content block of the last encoded message with cache_control.

cache_system(system, ttl)

Wraps a system prompt string in a cached text-block list.

encode_messages(messages)

@spec encode_messages([SkillKit.LLM.message()]) :: [map()]

Encodes a list of native message structs into Anthropic API message format.

Consecutive ToolResult messages are grouped into a single user message with tool_result content blocks, as required by the Anthropic API.

encode_tools(tools)

Encodes Tool structs into Anthropic tool format.