Skip to content

Allow for multiple output #769

@CChen89

Description

@CChen89

Hi,

Thank you for developing these excellent packages. As a beginner with ellmer and shinychat, I'm interested in learning how to return multiple outputs in a single chat round via tool calling.

In R/Shiny, returning a list (e.g., return(list(A = fig1, B = fig2, C = data.frame(), D = Text))) is the typical approach. Is it possible for ellmer's Content() function to bundle multiple output types in one response, like:

Content(
  ContentImage(fig1),
  ContentImage(fig2),
  ContentTable(my_table),
  ContentText(glue::glue('My summary text here'))
)

In my use case, my tool calling function needs to output and shinychatbox should display:

  1. Two figures (ggplot objects)
  2. One table (e.g., a gt HTML table)
  3. One character sentence (e.g., using glue with variables)

I haven't been able to find documentation or tutorials covering this multi-output approach in ellmer/shinychat. I did read your post at #735, but that covers only figures.

I also saw a shinychat article covering ContentToolResults() (https://posit-dev.github.io/shinychat/r/articles/tool-ui.html#alternative-display-content), but it seems to only allow a sentence and table via an extra argument, rather than arbitrary outputs.

Please let me know if this question would be better suited for Stack Overflow.

Thank you for any guidance!

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