Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create_tool_def Error with tidycensus::get_pums: "Error in merge_func(left, right, path) : is.list(left) is not TRUE" #358

Open
mrembert opened this issue Mar 7, 2025 · 1 comment

Comments

@mrembert
Copy link

mrembert commented Mar 7, 2025

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:

  1. Load the tidycensus and ellmer libraries:

    library(tidycensus)
    library(ellmer)
  2. Create a chat_gemini object:

    chat <- chat_gemini("gemini-2.0-flash")
  3. 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.
@hadley
Copy link
Member

hadley commented Mar 8, 2025

Can you please provide a minimal reprex (reproducible example)? The goal of a reprex is to make it as easy as possible for me to recreate your problem so that I can fix it: please help me help you! If you've never heard of a reprex before, start by reading about the reprex package, including the advice further down the page. Please make sure your reprex is created with the reprex package as it gives nicely formatted output and avoids a number of common pitfalls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants