Spaces:
No application file
No application file
File size: 864 Bytes
c20f20c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | export function formatContextWindow(size?: number): string {
if (!size) return '-';
// For M: prefer decimal (use decimal for exact thousands)
if (size >= 1000000) {
if (size % 1000000 === 0) {
return `${size / 1000000}M`;
}
return `${(size / 1000000).toFixed(1)}M`;
}
// For K: prefer decimal if divisible by 1000, otherwise use binary
if (size >= 1000) {
if (size % 1000 === 0) {
return `${size / 1000}K`;
}
return `${Math.floor(size / 1024)}K`;
}
return size.toString();
}
export function getProviderTypeLabel(type: string, t: (key: string) => string): string {
const translationKey = `settings.providerTypes.${type}`;
const translated = t(translationKey);
// If translation exists (not equal to key), use it; otherwise fallback to type
return translated !== translationKey ? translated : type;
}
|