Packages

An API for LLM completion that unifies across different providers.

Current section

Files

Jump to
overlay_llm src overlay@llm@tool.erl
Raw

src/overlay@llm@tool.erl

-module(overlay@llm@tool).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/overlay/llm/tool.gleam").
-export([tool_call_failure_to_string/1]).
-export_type([tool/0, call/0, function_call/0, return/0, tool_call_failure/0]).
-type tool() :: {tool,
binary(),
binary(),
list({binary(), castor:ref(castor:schema()), boolean()})}.
-type call() :: {call, binary(), function_call()}.
-type function_call() :: {function_call,
binary(),
gleam@dict:dict(binary(), oas@generator@utils:any_())}.
-type return() :: {return, binary(), list(binary())}.
-type tool_call_failure() :: {unknown_tool, binary()} |
{bad_arguments, list(gleam@dynamic@decode:decode_error())} |
{execution_aborted, binary()}.
-file("src/overlay/llm/tool.gleam", 31).
-spec tool_call_failure_to_string(tool_call_failure()) -> binary().
tool_call_failure_to_string(Failure) ->
case Failure of
{unknown_tool, Name} ->
<<"Unknown tool: "/utf8, Name/binary>>;
{bad_arguments, _} ->
<<"Bad arguments for tool call "/utf8>>;
{execution_aborted, Reason} ->
<<"Execution aborted: "/utf8, Reason/binary>>
end.