adk_llm_compatible_content (erlang_adk v0.8.0)

View Source

Checked ADK content translation for OpenAI-compatible Chat Completions.

The module is a pure JSON boundary. Emitted wire maps have binary keys; provider input is bounded and treated as untrusted; errors never retain prompts, model text, function arguments, tool results, or schema values.

Summary

Functions

Decode one assistant message from a completed choice. Text and parallel tool calls may coexist. Every call preserves its provider id.

Encode ordinary ADK function declarations into the Chat Completions nested {type:function,function:{...}} shape.

Functions

decode_message(Message, LimitOverrides)

-spec decode_message(term(), map()) -> {ok, adk_content:content(), list()} | {error, term()}.

Decode one assistant message from a completed choice. Text and parallel tool calls may coexist. Every call preserves its provider id.

encode(Role, Content, LimitOverrides)

-spec encode(system | user | assistant | agent | tool, term(), map()) -> {ok, [map()]} | {error, term()}.

encode_history(History, LimitOverrides)

-spec encode_history(term(), map()) -> {ok, [map()]} | {error, term()}.

encode_tools(Tools)

-spec encode_tools(term()) -> {ok, [map()]} | {error, term()}.

Encode ordinary ADK function declarations into the Chat Completions nested {type:function,function:{...}} shape.

outcome(Content)

-spec outcome(adk_content:content()) ->
                 {ok, binary() | adk_content:content()} | {tool_calls, list()} | {error, term()}.

text_parts(Content)

-spec text_parts(adk_content:content()) -> [binary()].

tool_calls(Content)

-spec tool_calls(adk_content:content()) -> list().