Skill Tracer
Skills › Scientific Agent Skills › infographics › iterative_refinement.md

iterative_refinement.md

136 lines · skills/infographics/references/iterative_refinement.md at 5f2bc03

Open on GitHub

Most marks come from matching words in the file, so treat them as pointers.

1# Smart Iterative Refinement
2
3The generate-review-refine loop, the command-line reference, and configuration.
4

Smart Iterative Refinement

The generate-review-refine loop, the command-line reference, and configuration.

Raw lines 1 to 4
5## Smart Iterative Refinement
6
7The diagram below shows the successful review path. If generation fails, the loop stops
8without replaying the paid call; the latest saved draft is retained. If review produces
9no usable score or verdict, the loop stops with quality unverified. A verdict requesting
10changes can trigger refinement even without a score. A saved PNG is not a factual check.

Smart Iterative Refinement

The diagram below shows the successful review path. If generation fails, the loop stops without replaying the paid call; the latest saved draft is retained. If review produces no usable score or verdict, the loop stops with quality unverified. A verdict requesting changes can trigger refinement even without a score. A saved PNG is not a factual check.

Raw lines 5 to 11
12### How It Works
14```text
15Generate PNG with Nano Banana 2
16 -> Review with Gemini 3.7 Flash
17 -> Score meets target AND no improvements requested?
18 YES: retain PNG, quality_met=true
19 NO: refine prompt while budget remains
20 (otherwise retain draft, quality_met=false)
21```

How It Works

Generate PNG with Nano Banana 2
    -> Review with Gemini 3.7 Flash
    -> Score meets target AND no improvements requested?
       YES: retain PNG, quality_met=true
       NO: refine prompt while budget remains
           (otherwise retain draft, quality_met=false)
Raw lines 12 to 22
23### Quality Review Criteria
25Gemini 3.7 Flash evaluates each infographic on:
271. **Visual Hierarchy & Layout** (0-2 points)
28 - Clear visual hierarchy
29 - Logical reading flow
30 - Balanced composition
322. **Typography & Readability** (0-2 points)
33 - Readable text
34 - Bold headlines
35 - No overlapping
373. **Data Visualization** (0-2 points)
38 - Prominent numbers
39 - Clear charts/icons
40 - Proper labels
424. **Color & Accessibility** (0-2 points)
43 - Professional colors
44 - Sufficient contrast
45 - Colorblind-friendly
475. **Overall Impact** (0-2 points)
48 - Professional appearance
49 - Free of visual bugs
50 - Achieves communication goal

Quality Review Criteria

Gemini 3.7 Flash evaluates each infographic on:

  1. Visual Hierarchy & Layout (0-2 points)
  2. Clear visual hierarchy
  3. Logical reading flow
  4. Balanced composition
  1. Typography & Readability (0-2 points)
  2. Readable text
  3. Bold headlines
  4. No overlapping
  1. Data Visualization (0-2 points)
  2. Prominent numbers
  3. Clear charts/icons
  4. Proper labels
  1. Color & Accessibility (0-2 points)
  2. Professional colors
  3. Sufficient contrast
  4. Colorblind-friendly
  1. Overall Impact (0-2 points)
  2. Professional appearance
  3. Free of visual bugs
  4. Achieves communication goal
Raw lines 23 to 51
52### Review Log
54Each generation produces a JSON review log:
55```json
57 "user_prompt": "5 benefits of exercise...",
58 "infographic_type": "list",
59 "style": "healthcare",
60 "doc_type": "marketing",
61 "quality_threshold": 8.5,
62 "iterations": [
63 {
64 "iteration": 1,
65 "image_path": "figures/exercise_v1.png",
66 "score": 8.7,
67 "needs_improvement": false,
68 "critique": "SCORE: 8.7\nSTRENGTHS:..."
69 }
70 ],
71 "final_score": 8.7,
72 "quality_met": true,
73 "termination_reason": "quality_met",
74 "image_model": "google/gemini-3.1-flash-image",
75 "review_model": "google/gemini-3.7-flash",
76 "early_stop": true,
77 "early_stop_reason": "Quality score 8.7 meets threshold 8.5"
79```
81---

Review Log

Each generation produces a JSON review log:

{
  "user_prompt": "5 benefits of exercise...",
  "infographic_type": "list",
  "style": "healthcare",
  "doc_type": "marketing",
  "quality_threshold": 8.5,
  "iterations": [
    {
      "iteration": 1,
      "image_path": "figures/exercise_v1.png",
      "score": 8.7,
      "needs_improvement": false,
      "critique": "SCORE: 8.7\nSTRENGTHS:..."
    }
  ],
  "final_score": 8.7,
  "quality_met": true,
  "termination_reason": "quality_met",
  "image_model": "google/gemini-3.1-flash-image",
  "review_model": "google/gemini-3.7-flash",
  "early_stop": true,
  "early_stop_reason": "Quality score 8.7 meets threshold 8.5"
}

Raw lines 52 to 82
83## Command-Line Reference
85```bash
86python skills/infographics/scripts/generate_infographic.py [OPTIONS] PROMPT
88Arguments:
89 PROMPT Description of the infographic content
91Options:
92 -o, --output PATH Output .png path (required)
93 -t, --type TYPE Infographic type preset
94 -s, --style STYLE Industry style preset
95 -p, --palette PALETTE Colorblind-safe palette
96 -b, --background COLOR Background color (default: white)
97 --doc-type TYPE Document type for quality threshold
98 --iterations N Positive generation-attempt budget (default: 3)
99 -r, --research Gather candidate facts with Sonar Pro
100 --context-image PATH Reference image; repeat up to 14 times
101 --api-key KEY OpenRouter API key
102 -v, --verbose Verbose output
103 --list-options List all available options
104```
106`success` means a draft was saved. `quality_met` is true only for a usable score at or
107above the target with no requested improvements. `termination_reason` is `quality_met`,
108`review_unavailable`, `max_iterations`, or `generation_failed`. Even a passing score
109requires source, spelling, number, geometry, contrast, and accessibility checks.
111`--context-image` supports local PNG, JPEG, GIF, and WebP references, sent as base64
112`input_references` to the Image API. Up to 14 references are supported by the currently
113reviewed Gemini providers; the script sends one output request per iteration. Generated
114PNG dimensions are provider-selected: a requested pixel size written in a prompt is not
115an API-enforced size. Inspect the actual artifact before print or platform delivery.

Command-Line Reference

python skills/infographics/scripts/generate_infographic.py [OPTIONS] PROMPT

Arguments:
  PROMPT                    Description of the infographic content

Options:
  -o, --output PATH         Output .png path (required)
  -t, --type TYPE           Infographic type preset
  -s, --style STYLE         Industry style preset
  -p, --palette PALETTE     Colorblind-safe palette
  -b, --background COLOR    Background color (default: white)
  --doc-type TYPE           Document type for quality threshold
  --iterations N            Positive generation-attempt budget (default: 3)
  -r, --research           Gather candidate facts with Sonar Pro
  --context-image PATH     Reference image; repeat up to 14 times
  --api-key KEY             OpenRouter API key
  -v, --verbose             Verbose output
  --list-options            List all available options

success means a draft was saved. quality_met is true only for a usable score at or above the target with no requested improvements. termination_reason is quality_met, review_unavailable, max_iterations, or generation_failed. Even a passing score requires source, spelling, number, geometry, contrast, and accessibility checks.

--context-image supports local PNG, JPEG, GIF, and WebP references, sent as base64 input_references to the Image API. Up to 14 references are supported by the currently reviewed Gemini providers; the script sends one output request per iteration. Generated PNG dimensions are provider-selected: a requested pixel size written in a prompt is not an API-enforced size. Inspect the actual artifact before print or platform delivery.

Raw lines 83 to 116
Runs code python skills/infographics/scripts/generate_infographic.py :86
117### List All Options
119```bash
120python skills/infographics/scripts/generate_infographic.py --list-options
121```
123---

List All Options

python skills/infographics/scripts/generate_infographic.py --list-options

Raw lines 117 to 124
Runs code python skills/infographics/scripts/generate_infographic.py :120
125## Configuration
127### API Key Setup
129Set your OpenRouter API key:
130```bash
131export OPENROUTER_API_KEY='your_api_key_here'
132```
134Get an API key at: https://openrouter.ai/keys
136---

API Key Setup

Set your OpenRouter API key:

export OPENROUTER_API_KEY='your_api_key_here'

Get an API key at: https://openrouter.ai/keys


Raw lines 127 to 136