Generate visualization for specific step
(current_step: int, current_tokens: List[str],
token_steps: List[int], max_step: int)
| 81 | return f"#{r:02x}{g:02x}{b:02x}" |
| 82 | |
| 83 | def generate_step_visualization(current_step: int, current_tokens: List[str], |
| 84 | token_steps: List[int], max_step: int) -> str: |
| 85 | """Generate visualization for specific step""" |
| 86 | html = [] |
| 87 | |
| 88 | for idx, token in enumerate(current_tokens): |
| 89 | style = [ |
| 90 | "color: #000000", |
| 91 | "padding: 6px 8px", |
| 92 | "margin: 3px", |
| 93 | "border-radius: 6px", |
| 94 | "display: inline-block", |
| 95 | "font-weight: 600", |
| 96 | "font-size: 16px", |
| 97 | "font-family: 'Segoe UI', sans-serif", |
| 98 | "box-shadow: 0 3px 6px rgba(12,55,112,0.15)", |
| 99 | "transition: all 0.2s ease", |
| 100 | "position: relative", |
| 101 | "width: 120px", |
| 102 | "min-width: 120px", |
| 103 | "text-align: center", |
| 104 | "white-space: nowrap", |
| 105 | "overflow: hidden", |
| 106 | "text-overflow: ellipsis", |
| 107 | "box-sizing: border-box" |
| 108 | ] |
| 109 | |
| 110 | if token == '<|mdm_mask|>': |
| 111 | style.extend([ |
| 112 | "background: #f8fafc", |
| 113 | "border: 2px solid #ffffff", |
| 114 | "font-weight: 800", |
| 115 | "text-transform: uppercase", |
| 116 | "padding: 4px 6px" |
| 117 | ]) |
| 118 | display_text = "Mask" |
| 119 | else: |
| 120 | bg_color = generate_background_color(token_steps[idx], max_step) |
| 121 | style.append(f"background-color: {bg_color}") |
| 122 | display_text = token if token != " " else "␣" |
| 123 | |
| 124 | html.append(f'<span style="{"; ".join(style)}">{display_text}</span>') |
| 125 | |
| 126 | return '\n'.join(html) |
| 127 | |
| 128 | def main(target_step: int = 64): |
| 129 | """Main function supporting target step specification""" |
no test coverage detected