科研技能库/可视化与报告
图表可视化
未发现用户侧风险

可视化与报告

将原始指标和分析转化为可视化图表,并通过 Google Cloud Storage 发布为可共享的 HTML 报告。

文件预览

1 个文件
SKILL.md
1.7 KB · 可预览
---
name: visualization-reporting
description: Transforms raw metrics and analysis into visual charts and published, shareable HTML reports using Google Cloud Storage.
---

### Skill: Visualization & Reporting Workflow

**Objective**: Transform raw numerical data and insights into beautiful, shareable assets. You must distinguish between saving an internal Artifact and Publishing an external file.

**Execution Steps**:
1.  **Confirm Data**: Ensure you have gathered the necessary metrics (e.g., a dictionary of channels and their engagement rates) or the final synthesized text.
2.  **Visualize**: Delegate to the `visualization_agent` to create static charts. Pass the raw data to it. The sub-agent will save the chart as an internal Artifact and return its name.
3.  **Retrieve Artifact**: Use the `load_artifacts` tool to load the raw bytes of the image artifact from the session memory.
4.  **Publish Dependencies to GCS**: If your final HTML report will display the image, you MUST publish the image bytes FIRST using `publish_file(content, filename, "image/png")`. This returns a public `https://storage.googleapis.com/...` URL.
5.  **Construct HTML**: Create a clean, well-formatted HTML string containing your analysis. Embed the charts using the *public URLs* obtained in step 4 (e.g., `<img src="https://storage.../chart.png" />`). Do NOT use local paths.
6.  **Final Delivery Options**:
    - **If the user just wants the report saved**: Call `render_html(html_content, "report.html")` to save it as an internal artifact they can download later.
    - **If the user wants a shareable link**: Call `publish_file(html_content, "report.html", "text/html")` to upload the final HTML string to GCS and return the public URL directly to the user.

SKILL.md

元数据
namevisualization-reporting
description使用 Google Cloud Storage 将原始指标和分析转化为可视化图表和可发布的、可分享的 HTML 报告。

技能:可视化与报告工作流

目标:将原始数值数据和洞察转化为美观、可共享的资产。你必须区分保存为内部 Artifact 和发布为外部文件的操作。

执行步骤:

  1. 确认数据:确保已收集必要的指标(例如,频道及其互动率的字典)或最终的合成文本。
  2. 可视化:委托 visualization_agent 创建静态图表。将原始数据传递给它。子代理会将图表保存为内部 Artifact 并返回其名称。
  3. 获取 Artifact:使用 load_artifacts 工具从会话内存中加载图片 Artifact 的原始字节。
  4. 发布依赖项至 GCS:如果你的最终 HTML 报告需要显示图片,你必须首先使用 publish_file(content, filename, "image/png") 发布图片字节。这将返回一个公开的 https://storage.googleapis.com/... URL。
  5. 构建 HTML:创建一个包含分析的整洁、格式良好的 HTML 字符串。使用步骤 4 中获取的公开 URL 嵌入图表(例如 <img src="https://storage.../chart.png" />)。不要使用本地路径。
  6. 最终交付选项:
    • 如果用户仅希望保存报告:调用 render_html(html_content, "report.html") 将其保存为内部 artifact,用户稍后可下载。
    • 如果用户需要可分享的链接:调用 publish_file(html_content, "report.html", "text/html") 将最终 HTML 字符串上传至 GCS,并直接将公开 URL 返回给用户。