Declares the tool parameters and their classes. The agent is expected to only provide the arguments specified, and wizrd will attempt to convert whatever the agent sends to the declared class.

can_accept_as(`_x`, ..., `_parameters` = list(...))

Arguments

_x

The Tool object

...

Each argument is any S7 class object, including base classes, S3 classes, and unions. The arguments are matched to the underlying function via match.call, i.e. normal R calling semantics.

_parameters

Convenience for providing a list instead of parameter classes instead of individual args in ....

Details

By default (if this function is never called), the formals of the underlying function are taken as the parameters, and each accepts any value. ..., if present, is declared as a list.

The agent is expected to send only the declared parameters, with some potentially being captured by ... in the underlying function. To request that the agent send extra arguments (as a list) that would be captured by ..., pass an argument named "\dots", e.g. accept_as(x, "..." = class_list), which is the default behavior as mentioned above.

The arguments are evaluated in the env passed to chat, so declaring an argument as a language object (class_name or class_call) will evaluate the argument as R code. See the below example for how this could be useful.

Value

The input Tool object except with newly declared parameters and types.

Author

Michael Lawrence

Examples

if (FALSE) { # \dontrun{
    var <- 1:10
    agent <- llama() |>
        equip(tool(mean) |> describe_with_Rd() |> can_accept_as(class_name)) |>
        predict("What is the mean of var?")
} # }