Shorthand that builds a tool definition and registers it on the active
session's chat object.
Usage
hal_register_tool(fn, name = NULL, description = NULL, types = NULL)
Arguments
- fn
The R function to expose as a tool.
- name
Tool name (defaults to the symbol name of fn).
- description
Description shown to the LLM (when to call this tool).
- types
Optional named list mapping argument names to JSON Schema type
strings: "string", "number", "integer", "boolean", "array",
"object".
Value
Invisibly returns the tool definition.
Examples
if (FALSE) { # \dontrun{
get_time <- function(tz = "UTC") format(Sys.time(), tz = tz)
hal_register_tool(get_time,
description = "Current time in a given timezone"
)
hal("what time is it in Tokyo?")
} # }