Skip to content

Commit 772f74f

Browse files
Improve model catalog context display
1 parent 8290fb7 commit 772f74f

2 files changed

Lines changed: 60 additions & 35 deletions

File tree

local-llm/lib/75-display.ps1

Lines changed: 55 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,43 @@ function Format-LocalLLMSpectreFitCell {
299299
return "[$color]$marker[/]$star$QuantKey"
300300
}
301301

302+
function Format-LocalLLMSpectreCatalogQuants {
303+
param(
304+
[Parameter(Mandatory = $true)]$Def,
305+
[int]$Limit = 10
306+
)
307+
308+
if (-not $Def.ContainsKey("Quants")) {
309+
return "[grey50](single file)[/]"
310+
}
311+
312+
$quantCells = @(
313+
foreach ($qk in $Def.Quants.Keys) {
314+
$fit = Get-QuantFitClass -Def $Def -QuantKey $qk
315+
Format-LocalLLMSpectreFitCell -QuantKey $qk -FitClass $fit -IsDefault:($qk -eq $def.Quant)
316+
}
317+
)
318+
319+
if ($quantCells.Count -le $Limit) {
320+
return ($quantCells -join ' ')
321+
}
322+
323+
$hidden = $quantCells.Count - $Limit
324+
return (@($quantCells | Select-Object -First $Limit) -join ' ') + " [grey50]+$hidden[/]"
325+
}
326+
327+
function Format-LocalLLMSpectreCatalogContexts {
328+
param([Parameter(Mandatory = $true)]$Def)
329+
330+
$contextLabels = @(
331+
$Def.Contexts.Keys | ForEach-Object {
332+
if ([string]::IsNullOrWhiteSpace($_)) { "def" } else { $_ }
333+
}
334+
)
335+
336+
return ConvertTo-LocalLLMSpectreSafe ($contextLabels -join ' ')
337+
}
338+
302339
function Show-ModelCatalogSpectre {
303340
param([switch]$All)
304341

@@ -319,43 +356,29 @@ function Show-ModelCatalogSpectre {
319356

320357
foreach ($key in $visibleKeys) {
321358
$def = Get-ModelDef -Key $key
322-
$tier = Get-ModelTier -Def $def
323-
324-
$tierLabel = switch ($tier) {
325-
'recommended' { '[green]recommended[/]' }
326-
'experimental' { '[yellow]experimental[/]' }
327-
'legacy' { '[grey50]legacy[/]' }
328-
default { ConvertTo-LocalLLMSpectreSafe $tier }
329-
}
330-
331-
if ($def.ContainsKey("Quants")) {
332-
$quantCells = foreach ($qk in $def.Quants.Keys) {
333-
$fit = Get-QuantFitClass -Def $def -QuantKey $qk
334-
Format-LocalLLMSpectreFitCell -QuantKey $qk -FitClass $fit -IsDefault:($qk -eq $def.Quant)
335-
}
336-
$quants = ($quantCells -join ' ')
337-
$defaultQuant = "[cyan]$($def.Quant)[/]"
338-
} else {
339-
$quants = "[grey50](single file)[/]"
340-
$defaultQuant = "[grey50]—[/]"
341-
}
342-
343-
$contextLabels = @($def.Contexts.Keys | ForEach-Object {
344-
if ([string]::IsNullOrWhiteSpace($_)) { "default" } else { $_ }
345-
})
346-
$contexts = ($contextLabels -join ' · ')
359+
$quants = Format-LocalLLMSpectreCatalogQuants -Def $def
347360

348361
$rows.Add([pscustomobject]@{
349-
Key = "[white]$key[/]"
350-
Name = ConvertTo-LocalLLMSpectreSafe $def.DisplayName
351-
Tier = $tierLabel
352-
Default = $defaultQuant
353-
Quants = $quants
354-
Contexts = ConvertTo-LocalLLMSpectreSafe $contexts
362+
Key = "[white]$key[/]"
363+
Name = ConvertTo-LocalLLMSpectreSafe $def.DisplayName
364+
Quants = $quants
365+
Ctx = Format-LocalLLMSpectreCatalogContexts -Def $def
355366
}) | Out-Null
356367
}
357368

358-
$rows | Format-SpectreTable -Border Rounded -Color Blue -AllowMarkup -Wrap | Out-Host
369+
$keyWidth = 14
370+
$nameWidth = 36
371+
$ctxWidth = 30
372+
$quantWidth = 44
373+
374+
$properties = @(
375+
@{ Name = 'Key'; Expression = { $_.Key }; Width = $keyWidth }
376+
@{ Name = 'Name'; Expression = { $_.Name }; Width = $nameWidth }
377+
@{ Name = 'Quants'; Expression = { $_.Quants }; Width = $quantWidth }
378+
@{ Name = 'Ctx'; Expression = { $_.Ctx }; Width = $ctxWidth }
379+
)
380+
381+
$rows | Format-SpectreTable -Property $properties -Border Rounded -Color Blue -AllowMarkup -Wrap | Out-Host
359382

360383
Write-Host ""
361384
Write-Host " Quant cells: " -ForegroundColor DarkGray -NoNewline

local-llm/llm-models.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,8 @@
277277
"": 131072,
278278
"32k": 32768,
279279
"64k": 65536,
280-
"128k": 131072
280+
"128k": 131072,
281+
"256k": 262144
281282
},
282283
"Strict": true,
283284
"SpecType": "draft-mtp",
@@ -325,7 +326,8 @@
325326
"": 131072,
326327
"32k": 32768,
327328
"64k": 65536,
328-
"128k": 131072
329+
"128k": 131072,
330+
"256k": 262144
329331
},
330332
"Strict": true,
331333
"SpecType": "draft-mtp",
@@ -347,4 +349,4 @@
347349
}
348350
},
349351
"CommandAliases": {}
350-
}
352+
}

0 commit comments

Comments
 (0)