Wraps an R function with the name, description, and JSON-Schema argument
specification that providers need for native tool calling. Pass a list of
tools to call_llm_tools() (or to a chat_session() via that function),
which executes the calls the model makes and returns the model's final
answer.
Arguments
- fn
The R function to expose. It is called with the model's arguments matched by name, so use the same parameter names as in
parameters.- name
Tool name shown to the model (letters, digits,
_,-).- description
One or two sentences telling the model what the tool does and when to use it. Write it for the model, not for a human reader; it is the only documentation the model sees.
- parameters
Either a named list of JSON-Schema property definitions, e.g.
list(city = list(type = "string", description = "City name")), or a complete JSON-Schema object (a list withtype = "object"andproperties). A tool with no arguments may omit it.- required
Character vector of required argument names. Defaults to all parameter names when
parametersis a property list.