formatBytes returns a human-readable byte size string (e.g. "1.2 MB").
(b int64)
| 88 | |
| 89 | // formatBytes returns a human-readable byte size string (e.g. "1.2 MB"). |
| 90 | func formatBytes(b int64) string { |
| 91 | const unit = 1024 |
| 92 | if b < unit { |
| 93 | return fmt.Sprintf("%d B", b) |
| 94 | } |
| 95 | div, exp := int64(unit), 0 |
| 96 | for n := b / unit; n >= unit; n /= unit { |
| 97 | div *= unit |
| 98 | exp++ |
| 99 | } |
| 100 | return fmt.Sprintf("%.1f %cB", float64(b)/float64(div), "KMGTPE"[exp]) |
| 101 | } |
| 102 | |
| 103 | func writeAssistantMessage(builder *strings.Builder, msg session.Message) { |
| 104 | builder.WriteString("\n## Assistant") |
no outgoing calls