View Source Anthropix.FunctionCall (Anthropix v0.1.0)

The Anthropix.FunctionCall module is used to capture function calls from Claud's responses and, match the function call to an existing Anthropix.Tool.t/0, and then invoke the function.

Usually, function calling is all handled automatically by the Anthropix.Agent module.

Summary

Types

t()

Function Call struct

Functions

Extracts function calls from the given text. Specifically, it looks for a <function_calls> XML snippet and parses any function calls into a list of t/0 structs.

Invokes the given function using the matched tool. The arguments from the t/0 struct are passed to the function, and the result is set on the FunctionCall struct.

Iterates over the given list of t/0 structs, finding a matching t:Tool.t/0 for each, and calling invoke/2. Returns a list of function calls with results or an exception of any function raises.

Types

@type t() :: %Anthropix.FunctionCall{
  args: %{optional(String.t()) => String.t()},
  name: String.t(),
  result: any()
}

Function Call struct

Functions

@spec extract!(String.t()) :: [t()]

Extracts function calls from the given text. Specifically, it looks for a <function_calls> XML snippet and parses any function calls into a list of t/0 structs.

@spec invoke(t(), Anthropix.Tool.t()) :: t()

Invokes the given function using the matched tool. The arguments from the t/0 struct are passed to the function, and the result is set on the FunctionCall struct.

Link to this function

invoke_all(functions, tools)

View Source
@spec invoke_all([t()], [Anthropix.Tool.t()]) :: [t()] | Exception.t()

Iterates over the given list of t/0 structs, finding a matching t:Tool.t/0 for each, and calling invoke/2. Returns a list of function calls with results or an exception of any function raises.