The Issue:
Databricks Playground typically has limited native support for rendering base64 images
directly in the chat interface. This is a known limitation in many AI playground
environments.
Potential Workarounds:
1. Use Markdown Image Syntax
If your tool returns base64 data, try formatting it as a data URI with markdown:
# In your tool's return value
image_b64 = "your_base64_string_here"
return f""
2. Return a Public URL Instead
Instead of returning base64, save the chart to a location accessible via HTTP:
# Save to DBFS and return a displayable URL
dbutils.fs.put(f"/tmp/chart_{uuid.uuid4()}.png", image_bytes)
# Return the URL or use display() in notebooks
3. Use DisplayHTML in Notebooks
If testing in a Databricks notebook (not Playground), you can use:
from IPython.display import HTML, display
display(HTML(f'<img src="data:image/png;base64,{image_b64}" />'))
4. Structured Output with Content Type
Ensure your tool returns properly structured output with content type hints:
{
"type": "image",
"content": base64_string,
"mime_type": "image/png"
}
5. File Path Reference
Return a file path that can be accessed through Databricks:
# Save to a volume or DBFS location
return f"Image saved to: /Volumes/catalog/schema/volume/chart.png"
Recommended Approach:
The most reliable workaround is to:
1. Save the generated chart to a Databricks volume or DBFS
2. Return the file path in the tool response
3. View the image separately in a notebook using display(Image(path))
The Playground interface is primarily designed for text-based interactions, so rich
media rendering may require using notebooks or custom applications instead.