Skip to content

Using parallel_chat_structured() with ContentImageRemote objects errors unless objects wrapped in nested list #596

Open
@thisisnic

Description

@thisisnic

I'm loving parallel_chat_structured(), though I'm running into a minor issue when I try to input images and I get an error unless I wrap each image in a list.

library(ellmer)
chat <- chat_openai()
#> Using model = "gpt-4.1".
r_image <- content_image_url("https://www.r-project.org/Rlogo.png")
py_image <- content_image_url("https://upload.wikimedia.org/wikipedia/commons/thumb/c/c3/Python-logo-notext.svg/640px-Python-logo-notext.svg.png")
parallel_chat_structured(
  chat,  
  list(r_image, py_image),
  type = type_object(
    primary_shape = type_string(),
    primary_colour = type_string()
  )
)
#> Error in as.vector(x, "list"): cannot coerce type 'object' to vector of type 'list'

Workaround:

parallel_chat_structured(
  chat,  
  list(list(r_image), list(py_image)),
  type = type_object(
    primary_shape = type_string(),
    primary_colour = type_string()
  )
)
#> [working] (0 + 0) -> 1 -> 1 | ■■■■■■■■■■■■■■■■                  50%
#> [working] (0 + 0) -> 0 -> 2 | ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■  100%
#>                            primary_shape  primary_colour
#> 1                      circle and letter   grey and blue
#> 2 two interlocking abstract snake shapes blue and yellow

Created on 2025-06-28 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions