Packages

Gleam SDK for the Anthropic Claude API with agentic tool-use loop and BEAM concurrency

Current section

Files

Jump to
claude_gleam src claude@types@content.erl
Raw

src/claude@types@content.erl

-module(claude@types@content).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/claude/types/content.gleam").
-export([text/1, tool_use/3, tool_result/3]).
-export_type([content_block/0, content_block_param/0, tool_result_content/0, citation/0, image_source/0, document_source/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-type content_block() :: {text, binary(), list(citation())} |
{thinking, binary(), binary()} |
{redacted_thinking, binary()} |
{tool_use, binary(), binary(), binary()} |
{server_tool_use, binary(), binary(), binary()} |
{web_search_result, binary(), binary(), binary(), binary()}.
-type content_block_param() :: {text_param, binary()} |
{image_param, image_source()} |
{document_param, document_source()} |
{tool_use_param, binary(), binary(), binary()} |
{tool_result_param, binary(), tool_result_content(), boolean()} |
{thinking_param, binary(), binary()} |
{redacted_thinking_param, binary()} |
{server_tool_use_param, binary(), binary(), binary()}.
-type tool_result_content() :: {string_result, binary()} |
{blocks_result, list(content_block_param())}.
-type citation() :: {char_location_citation,
binary(),
integer(),
integer(),
integer()} |
{page_location_citation, binary(), integer(), integer(), integer()} |
{content_block_location_citation, binary(), integer(), integer(), integer()} |
{web_search_result_location_citation, binary(), binary(), binary()}.
-type image_source() :: {base64_image, binary(), binary()} |
{url_image, binary()}.
-type document_source() :: {base64_document, binary(), binary()} |
{url_document, binary()}.
-file("src/claude/types/content.gleam", 78).
?DOC(" Create a simple text content block with no citations.\n").
-spec text(binary()) -> content_block().
text(T) ->
{text, T, []}.
-file("src/claude/types/content.gleam", 83).
?DOC(" Create a tool-use content block.\n").
-spec tool_use(binary(), binary(), binary()) -> content_block().
tool_use(Id, Name, Input) ->
{tool_use, Id, Name, Input}.
-file("src/claude/types/content.gleam", 92).
?DOC(" Create a tool-result content block param with string content.\n").
-spec tool_result(binary(), binary(), boolean()) -> content_block_param().
tool_result(Id, Content, Is_error) ->
{tool_result_param, Id, {string_result, Content}, Is_error}.