(tokens: number, compact?: boolean)
| 143 | } |
| 144 | |
| 145 | export function formatTokenCount(tokens: number, compact?: boolean): string { |
| 146 | const suffix = compact ? "" : " tokens" |
| 147 | if (tokens >= 1000) { |
| 148 | return `${(tokens / 1000).toFixed(1)}K`.replace(".0K", "K") + suffix |
| 149 | } |
| 150 | return tokens.toString() + suffix |
| 151 | } |
| 152 | |
| 153 | export function truncate(str: string, maxLen: number = 60): string { |
| 154 | if (str.length <= maxLen) return str |
no outgoing calls
no test coverage detected