Small formatting issue that we should try to run tool arguments through tool_request_args() so they reflect the converted data structures before echoing the tool request.
pkgload::load_all()
#> ℹ Loading ellmer
tool <- tool(
function(greeting = c("Hello", "Goodbye"), name = "your") {
args <<- list(greeting = greeting, name = name)
cli::format_inline("{greeting}, {.and {name}}!")
},
.description = "Random number between 1 and 10.",
.name = "greet",
greeting = type_array(
description = "Choose a greeting",
items = type_enum(values = c("Hello", "Goodbye")),
),
name = type_array("Name or names to greet", items = type_string())
)
req <- ContentToolRequest(
id = "test",
name = "greet",
arguments = list(
greeting = list("Hello"),
name = list("Hadley", "Simon")
),
tool = tool
)
cat(format(req))
#> [tool request (test)]: greet(greeting = list("Hello"), name = list("Hadley", "Simon"))
# Should be...
#> [tool request (test)]: greet(greeting = "Hello", name = c("Hadley", "Simon"))
str(tool_request_args(req))
#> List of 2
#> $ greeting: Factor w/ 2 levels "Hello","Goodbye": 1
#> $ name : chr [1:2] "Hadley" "Simon"
Small formatting issue that we should try to run tool arguments through
tool_request_args()so they reflect the converted data structures before echoing the tool request.