-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
Background
The ellmer package recently added support for tool results that return non-JSON content types like images and PDFs (ellmer PR #735).
Problem
Currently, shinychat tries to convert tool results to JSON strings using tool_string(), which fails when the tool result contains S7 content types like content_image() or content_pdf().
Proposed Solution
Modify the tool result handling to:
- Detect S7 content types
- Render these content types appropriately in the chat interface
- Fallback to existing JSON conversion for other content types
Example Scenario
library(ellmer)
# Tool that returns an image
cat_image_tool <- tool(
function() {
# Simulate generating a cat image
tmpf <- tempfile(fileext = ".jpg")
download.file("[https://placekitten.com/200/300](vscode-file://vscode-app/Applications/Positron.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html#)", tmpf, quiet =
TRUE)
content_image_file(tmpf)
},
name = "get_cat_image",
description = "Generate a random cat image"
)
# Create a chat
chat <- chat_openai()
chat$register_tool(cat_image_tool)
shinychat::chat_app(chat)Related Work
- ellmer PR: feat: Support images and PDFs in tool results tidyverse/ellmer#735
- Specific issue: Handling of
tool_string()for S7 content types
/cc @gadenbuie
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels