MCPcopy Create free account
hub / github.com/diillson/chatcli / FormatPayloadSize

Function FormatPayloadSize

cli/history_compactor.go:105–116  ·  view source on GitHub ↗

FormatPayloadSize returns a human-readable size for display.

(bytes int)

Source from the content-addressed store, hash-verified

103
104// FormatPayloadSize returns a human-readable size for display.
105func FormatPayloadSize(bytes int) string {
106 switch {
107 case bytes >= 1024*1024*1024:
108 return fmt.Sprintf("%.1f GB", float64(bytes)/(1024*1024*1024))
109 case bytes >= 1024*1024:
110 return fmt.Sprintf("%.1f MB", float64(bytes)/(1024*1024))
111 case bytes >= 1024:
112 return fmt.Sprintf("%.1f KB", float64(bytes)/1024)
113 default:
114 return fmt.Sprintf("%d B", bytes)
115 }
116}
117
118// DefaultCompactConfig returns sensible defaults for chat mode.
119func DefaultCompactConfig(provider, model string) CompactConfig {

Callers 4

TestFormatPayloadSizeFunction · 0.85
CompactMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestFormatPayloadSizeFunction · 0.68