humanRate renders throughput: `25 tok/s`, `5.3 tok/s`. Returns "" on degenerate input (no tokens or zero elapsed) so the caller omits the segment. Sub-10 tok/s keeps one decimal: reasoning models sit at 1.x where that decimal is the only signal; above 10 it's noise.
(tokens int, d time.Duration)
| 46 | // segment. Sub-10 tok/s keeps one decimal: reasoning models sit at 1.x |
| 47 | // where that decimal is the only signal; above 10 it's noise. |
| 48 | func humanRate(tokens int, d time.Duration) string { |
| 49 | if tokens <= 0 || d <= 0 { |
| 50 | return "" |
| 51 | } |
| 52 | r := float64(tokens) / d.Seconds() |
| 53 | if r >= 10 { |
| 54 | return fmt.Sprintf("%d tok/s", int(r+0.5)) |
| 55 | } |
| 56 | return fmt.Sprintf("%.1f tok/s", r) |
| 57 | } |
| 58 | |
| 59 | // backendLabel renders the connection signal. Connected: profile name, bold, |
| 60 | // no colour. Disconnected: bold yellow plus a `!` marker, so the state stays |
no outgoing calls