I encountered an error when attempting to create a tool definition for the get_pums function from the tidycensus package using the create_tool_def function from ellmer.
Reproduction steps:
-
Load the tidycensus and ellmer libraries:
library(tidycensus)
library(ellmer)
-
Create a chat_gemini object:
chat <- chat_gemini("gemini-2.0-flash")
-
Attempt to create a tool definition for get_pums:
create_tool_def(get_pums, chat)
Expected behavior:
I expected create_tool_def to successfully generate a tool definition for the get_pums function, allowing it to be used within the ellmer framework.
Actual behavior:
Instead of creating the tool definition, the code produced the following response/error:
tool(
tidycensus::get_pums,
"Load data from the American Community Survey Public Use Microdata Series API",
variables = type_array(
"A vector of variables from the PUMS API. Use `View(pums_variables)` to browse variable options.",
items = type_string()
),
state = type_string(
"A state, or vector of states, for which you would like to request data. The entire US can be requested with `state = \"all\"` - though be
patient with the data download!",
required = FALSE # TODO: could also be a vector, unclear how to Error in merge_func(left, right, path) : is.list(left) is not TRUE
Error during wrapup: 'S4SXP': should not happen - please report
Error: no more error handlers available (recursive errors?); invoking 'abort' restart
Additional Information:
- I've tried create_tool_def with other functions (e.g. sum) and it seems to work, so it seems to be related to something specific about the tidycensus::get_pums function.
I encountered an error when attempting to create a tool definition for the
get_pumsfunction from thetidycensuspackage using thecreate_tool_deffunction fromellmer.Reproduction steps:
Load the
tidycensusandellmerlibraries:Create a
chat_geminiobject:Attempt to create a tool definition for
get_pums:Expected behavior:
I expected
create_tool_defto successfully generate a tool definition for theget_pumsfunction, allowing it to be used within theellmerframework.Actual behavior:
Instead of creating the tool definition, the code produced the following response/error:
Additional Information: