How to render HTML in agentspace(Gemini Enterprise) integrated with agent engine #4404
Replies: 1 comment
-
|
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: Yes, HTML artifacts are rendered in the Agentspace chat. You can save your interactive chart as an HTML file and it will be displayed. Hello! As of version 1.2.0, ADK supports rendering HTML artifacts directly in the chat window [1]. You can use the Here is an example of how you could save an HTML artifact: from adk.api import save_artifact
chart_html = """
<!DOCTYPE html>
<html>
<head>
<title>My Interactive Chart</title>
</head>
<body>
<h1>My Chart</h1>
<canvas id="myCanvas" width="200" height="100" style="border:1px solid #000000;">
</canvas>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
cxt.moveTo(0,0);
cxt.lineTo(200,100);
cxt.stroke();
</script>
</body>
</html>
"""
save_artifact(
"interactive_chart.html",
chart_html.encode("utf-8"),
mime_type="text/html",
description="An interactive chart generated by the agent.",
)This will save the HTML file as an artifact, and the Agentspace UI will render it in the chat. Let me know if you have any other questions! [1] https://github.com/google/adk-python/blob/main/CHANGELOG.md |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
If an agent saves an HTML artifact, will it be rendered in the Agentspace chat?
I’m asking because I plan to build an interactive chart, and my approach is to use HTML with Canvas.
Beta Was this translation helpful? Give feedback.
All reactions