File size: 669 Bytes
eeb9404 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import type { ModelRef } from '@/lib/llm/models/assignment';
/** Format context length as a concise string (e.g. "1M ctx", "200K ctx"). */
export function fmtCtx(length: number | undefined): string | null {
if (!length) return null;
if (length >= 1_000_000) {
const val = length / 1_000_000;
return `${val % 1 === 0 ? val.toFixed(0) : val.toFixed(1)}M ctx`;
}
return `${Math.round(length / 1_000)}K ctx`;
}
/** Short model id — the trailing segment after any vendor prefix. */
export function modelRefLabel(ref: ModelRef | null): string {
if (!ref) return '';
const parts = ref.model.split('/');
return parts[parts.length - 1] ?? ref.model;
}
|