mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
fix(admin-ui): keep sign and precision in CSV, YAML and context labels
CSV export prefixed negative numbers with an apostrophe, which corrupted the data. YAML emitted NaN and Infinity as plain strings. Context windows such as 1500 read as 2k. Numbers now skip the CSV formula guard, non-finite values use YAML float forms, and counts below 10k keep one decimal.
This commit is contained in:
@@ -194,8 +194,13 @@ export function formatContextWindow(tokens: number): string {
|
||||
}
|
||||
|
||||
// 999_500+ would round to "1000k"; the M branch renders it as "1M".
|
||||
if (tokens < 999_500) return `${Math.round(tokens / 1_000)}k`
|
||||
return `${Math.round(tokens / 1_000_000)}M`
|
||||
if (tokens < 999_500) return `${roundScaled(tokens / 1_000)}k`
|
||||
return `${roundScaled(tokens / 1_000_000)}M`
|
||||
}
|
||||
|
||||
/** roundScaled keeps one decimal below 10 ("1.5") so 1500 does not read as 2k, and rounds to whole units from 10 up. */
|
||||
function roundScaled(value: number): string {
|
||||
return value < 10 ? String(Math.round(value * 10) / 10) : String(Math.round(value))
|
||||
}
|
||||
|
||||
/** formatUsdPerMTok renders a USD-per-million-tokens float as "$0.19" (2 decimals) — the shared building block for both the visible cost chip and ModelChip's hover detail. */
|
||||
|
||||
Reference in New Issue
Block a user