View Source Shifts.Tool behaviour (Shifts v0.0.2)

TODO

Summary

Callbacks

Invoked when the tool is called, and must return a String.t() value.

Types

@type args() :: %{optional(String.t()) => arg_type()}
@type param() :: {atom(), param_type(), String.t()}
@type param_type() :: :string | :integer | :float
@type t() :: %Shifts.Tool{
  description: String.t(),
  function: (Shifts.Shift.t(), args() -> String.t() | Shifts.Chat.t()),
  name: String.t(),
  params: [param()]
}

TODO

@type tool_call() ::
  {:tool_use, id :: String.t(), name :: String.t(), input :: args()}
@type tool_record() :: tool_call() | tool_result()
@type tool_result() ::
  {:tool_result, id :: String.t(), name :: String.t(), output :: String.t()}

Callbacks

@callback call(shift :: Shifts.Shift.t(), args :: map()) :: String.t() | Shifts.Chat.t()

Invoked when the tool is called, and must return a String.t() value.

Receives the context Shifts.Shift.t/0 and a map of arguments.

Functions

Link to this macro

description(value)

View Source (macro)
@spec description(String.t()) :: Macro.t()

Sets the tool description.

@spec name(String.t()) :: Macro.t()

Sets the tool name.

Creates a new Shifts.Tool.t/0 struct from the given options.

Link to this macro

param(name, type, description)

View Source (macro)
@spec param(atom(), param_type(), String.t()) :: Macro.t()

Sets a tool parameter.

Link to this macro

tool_result(args \\ [])

View Source (macro)
Link to this macro

tool_result(record, args)

View Source (macro)
Link to this macro

tool_use(args \\ [])

View Source (macro)
Link to this macro

tool_use(record, args)

View Source (macro)
@spec use_tools([t() | module()]) :: [t()]

TODO

@spec validate_mod(term()) :: {:ok, term()} | {:error, String.t()}

TODO