| hal_tool | R Documentation |
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.
hal_tool(fn, name = NULL, description = NULL, types = NULL)
fn |
The R function to expose as a tool. |
name |
Tool name (defaults to the symbol name of |
description |
Description shown to the LLM (when to call this tool). |
types |
Optional named list mapping argument names to JSON Schema type
strings: |
A list with name, description, fun, and parameters – ready
for chat$register_tool().
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)
## Not run:
# register on the active session so the model can call it
hal_register_tools(list(tool))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.