if (FALSE) {
library(ellmer)
# Example 1: Custom tool
tool_rnorm <- ellmer::tool(
rnorm,
description = "Draw numbers from a random normal distribution",
arguments = list(
n = ellmer::type_integer("The number of observations"),
mean = ellmer::type_number("The mean value"),
sd = ellmer::type_number("The standard deviation")
)
)
tidyllm_tool_rnorm <- ellmer_tool(tool_rnorm)
llm_message("Generate 100 random numbers") |>
chat(openai(), .tools = tidyllm_tool_rnorm)
# Example 2: Builtin tool
web_search <- ellmer_tool(ellmer::claude_tool_web_search())
llm_message("What are the latest AI developments?") |>
chat(claude(), .tools = web_search)
}
Run the code above in your browser using DataLab