--- name: sn-infographic description: | 生成专业信息图。87 种布局 x 66 种风格,支持多轮自动评审优化。 需要 SenseNova API。触发词:infographic、信息图、可视化、visual summary。 适合追求自动化质量把控的场景。无 SenseNova API 时用 baoyu-infographic。 metadata: project: SenseNova-Skills tier: 1 category: scene priority: 9 user_visible: true triggers: - "infographic" - "information graphic" - "infographics generation" - "visual summary" - "data visualization" - "visual explanation" - "diagram" - "生成信息图" - "信息图生成" - "生成 infographic" - "信息图表" - "图表生成" - "数据可视化" - "图解" --- # sn-infographic Info graphic generation scene skill (tier 1), relying on the `sn-image-generate`, `sn-image-recognize`, and `sn-text-optimize` tools provided by `sn-image-base` (tier 0). Features: - Evaluation of prompt quality (auto mode) - Prompt expansion (force/auto mode) - Multiple rounds of image generation and VLM review - Output the best result based on quality ranking ## Input Specification | Parameter | Type | Default Value | Description | |-----------|------|---------------|-------------| | `user_prompt` | string | **Required** | User original request | | `max_rounds` | int | `1` | Maximum number of generation rounds | | `output_mode` | string | `friendly` | Output mode: friendly / verbose | | `prompts_expand_mode` | string | `auto` | expand strategy: auto / force / disable | ## API Configuration All API calls in this skill are executed through the `sn_agent_runner.py` of the `sn-image-base` skill, with authentication parameters using default values (CLI > environment variables > built-in defaults),无需显式传入。 | Call Type | Tool | Authentication Parameters | Description | |-----------|------|---------------------------|-------------| | **LLM** | sn-text-optimize (evaluation/expansion) | Default reads `SN_TEXT_API_KEY` -> `SN_CHAT_API_KEY` -> `SN_API_KEY` | Built-in default points to Sensenova internal network service | | **VLM** | sn-image-recognize (image review) | Default reads `SN_VISION_API_KEY` -> `SN_CHAT_API_KEY` -> `SN_API_KEY` | Built-in default points to Sensenova internal network service | | **Image Generation** | sn-image-generate | Default reads `SN_IMAGE_GEN_API_KEY` -> `SN_API_KEY`; `SN_IMAGE_GEN_API_KEY` is only needed for image-specific override | Default uses image generation configuration of `sn-image-base` | **When encountering `MissingApiKeyError` or needing to specify a model**: pass explicitly via CLI parameters, parameter reference `$SN_IMAGE_BASE/references/api_spec.md`. **`$SN_IMAGE_BASE` path explanation**: `$SN_IMAGE_BASE` is the installation directory of the `sn-image-base` skill (`SKILL.md` exists). The agent can locate this path by skill name `sn-image-base` in the list of installed skills. ## Architecture: Main Agent + Worker Agent This skill uses a two-tier agent architecture: | Role | Responsibility | |------|----------------| | **Main Agent** | Receive user request, normalize parameters, send preflight, start Worker, collect results, send text and images to user | | **Worker Agent** | Execute orchestration loop (expand → multiple rounds of generation + review → sort), return structured JSON | **Responsibility Boundaries**: - Worker Agent **does not send any messages to the user directly**, only returns structured JSON - Main Agent is responsible for sending all user-visible messages - Worker Agent's last message **must be and only be** the JSON string defined in the Return Contract - Worker Agent's internal VLM calls **always execute directly**, without spawning subagents ## Workflow ### Main Agent Workflow 1. Extract `user_prompt`, `max_rounds` (default 1), `output_mode` (default `friendly`), and `prompts_expand_mode` (default `auto`) from user request 2. Send uniform preflight message: `"Using sn-infographic skill to generate infographic, please wait..."` 3. Start Worker Agent (Sub-Agent), passing in complete parameters and working directory 4. When Worker Agent returns `status=ok` and `need_main_agent_send=true`: - **max_rounds = 1**: Send a one-sentence description of the image content, then send the rank=1 single image - **max_rounds > 1, friendly mode**: Generate a one-sentence natural language description based on `result` and `violations`, send the evaluation text, then send the rank=1 single image - **max_rounds > 1, verbose mode**: Send complete text summary message, then send all images in rank order to the user 5. If Worker Agent returns `status=error`, report the real `error` field content to the user ### Worker Agent Workflow Worker Agent receives `user_prompt`, `max_rounds`, `output_mode`, `prompts_expand_mode`, and the working directory of this skill (`SN_IMAGE_INFOG`). #### Step 0 — Initialization 1. Generate `task_id` (using timestamp, format `YYYYMMDD_HHMMSS`) 2. Create a uniform temporary directory: `/tmp/openclaw/sn-infographic//` as `TEMP_DIR` 3. Initialize an empty `rounds` list 4. Infer `aspect_ratio` (default `16:9`) and `image_size` (default `2k`) from `user_prompt` based on the rules in `$SKILL_DIR/references/runtime-parameters.md` #### Step 1 — `prompts_expand_mode` Processing **`disable` mode**: - Skip expand, directly use `user_prompt` as `expanded_prompt` - Assign variable and write to temporary directory: ```bash EXPANDED_PROMPT="$USER_PROMPT" echo "$EXPANDED_PROMPT" > "$TEMP_DIR/expanded-prompt.txt" ``` - Record `prompts_expand_skipped = true` **`force` mode**: - Directly execute Step 2 **`auto` mode**: 1. Call sn-text-optimize for evaluation 2. Parse JSON, extract `required_results` and `optional_results` 3. Determine logic: - `required_pass`: All `answer` in `required_results` are `"yes"` - `optional_pass`: The number of `answer="yes"` in `optional_results` / total ≥ 0.6 - `should_expand = not (required_pass and optional_pass)` 4. If JSON parsing fails, default `should_expand = true` (conservative strategy) 5. If `should_expand = false`: Skip Step 2, assign variable and write to temporary directory, record `prompts_expand_skipped = true`: ```bash EXPANDED_PROMPT="$USER_PROMPT" echo "$EXPANDED_PROMPT" > "$TEMP_DIR/expanded-prompt.txt" ``` 6. If `should_expand = true`: Execute Step 2 **Evaluation Call** (using `sn-image-base`'s `sn-text-optimize` tool): ```bash python "$SN_IMAGE_BASE/scripts/sn_agent_runner.py" sn-text-optimize \ --system-prompt-path "$SKILL_DIR/references/evaluation-standard.md" \ --user-prompt "$USER_PROMPT" \ --output-format json ``` #### Step 2 — Content Analysis + Layout & Style Selection + Prompt Expansion **2.0 Content Analysis** (using `sn-image-base`'s `sn-text-optimize` tool): ```bash ANALYSIS=$(python "$SN_IMAGE_BASE/scripts/sn_agent_runner.py" sn-text-optimize \ --system-prompt-path "$SKILL_DIR/references/analysis-framework.md" \ --user-prompt "$USER_PROMPT" \ --output-format json) ``` Save analysis result stdout to `analysis.json` in temporary directory `$TEMP_DIR/analysis.json`: ```bash echo "$ANALYSIS" > "$TEMP_DIR/analysis.json" ``` **2.1 Layout & Style Selection** 1. Read analysis result from temporary directory `$TEMP_DIR/analysis.json`; ```bash ANALYSIS=$(cat "$TEMP_DIR/analysis.json") ``` 2. Based on `data_type`, `tone`, `audience`, select `layout` and `style` based on the rules in `$SKILL_DIR/references/layout-style-selection.md`; 3. Read layout/style definition files: ```bash LAYOUT_DEF=$(cat "$SKILL_DIR/references/layouts/.md") STYLE_DEF=$(cat "$SKILL_DIR/references/styles/