Converts an R function into a hal tool definition suitable for
$register_tool(). Infers parameter types from function formals;
override with the types argument for non-string parameters.
Examples
my_sum <- function(x, y) x + y
tool <- hal_tool(my_sum, "add_numbers",
description = "Add two numbers",
types = list(x = "number", y = "number")
)
str(tool)
#> List of 4
#> $ name : chr "add_numbers"
#> $ description: chr "Add two numbers"
#> $ fun :function (x, y)
#> $ parameters :List of 3
#> ..$ type : chr "object"
#> ..$ properties:List of 2
#> .. ..$ x:List of 1
#> .. .. ..$ type: chr "number"
#> .. ..$ y:List of 1
#> .. .. ..$ type: chr "number"
#> ..$ required :List of 2
#> .. ..$ : chr "x"
#> .. ..$ : chr "y"
if (FALSE) { # \dontrun{
# register on the active session so the model can call it
hal_register_tools(list(tool))
} # }
