| llm_tool | R Documentation |
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.
llm_tool(fn, name, description, parameters = NULL, required = NULL)
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 |
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. |
required |
Character vector of required argument names. Defaults to all
parameter names when |
An object of class llmr_tool.
call_llm_tools(), tool_calls()
weather <- llm_tool(
fn = function(city) paste0("22C and clear in ", city),
name = "get_weather",
description = "Current weather for a city.",
parameters = list(city = list(type = "string", description = "City name"))
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.