Skip to content

Commit

Permalink
minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sammcj committed May 30, 2024
1 parent 2a90553 commit 8915c3b
Showing 1 changed file with 46 additions and 60 deletions.
106 changes: 46 additions & 60 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,58 +420,32 @@ func (d itemDelegate) Update(msg tea.Msg, m *list.Model) tea.Cmd {
}

var familyColors = map[string]lipgloss.Color{
"llama": lipgloss.Color("205"),
"alpaca": lipgloss.Color("215"),
"vicuna": lipgloss.Color("225"),
"guanaco": lipgloss.Color("235"),
"phi3": lipgloss.Color("275"),
"qwen2": lipgloss.Color("265"),
"command-r": lipgloss.Color("245"),
"starcoder2": lipgloss.Color("285"),
"bert": lipgloss.Color("295"),
"nomic-bert": lipgloss.Color("305"),
"starcoder": lipgloss.Color("315"),
"gemma": lipgloss.Color("325"),
"llama": lipgloss.Color("205"),
"alpaca": lipgloss.Color("215"),
"vicuna": lipgloss.Color("225"),
"guanaco": lipgloss.Color("235"),
"phi3": lipgloss.Color("275"),
"qwen2": lipgloss.Color("265"),
"command-r": lipgloss.Color("245"),
"starcoder2": lipgloss.Color("285"),
"bert": lipgloss.Color("295"),
"nomic-bert": lipgloss.Color("305"),
"starcoder": lipgloss.Color("315"),
"gemma": lipgloss.Color("325"),
}

func quantColor(quant string) lipgloss.Color {
// group by quantization level (e.g. all Q2 models are the same colour (Q2, Q2_K_M, Q2_K, etc))
// for i := 1; i <= 10; i++ {
// if quant == fmt.Sprintf("Q%d", i) {
// return lipgloss.Color(fmt.Sprintf("%d", 10 + i))
// } else if quant == fmt.Sprintf("Q%d_K", i) {
// return lipgloss.Color(fmt.Sprintf("%d", 20 + i))
// } else if quant == fmt.Sprintf("Q%d_K_M", i) {
// return lipgloss.Color(fmt.Sprintf("%d", 30 + i))
// } else if quant == fmt.Sprintf("Q%d_K_S", i) {
// return lipgloss.Color(fmt.Sprintf("%d", 40 + i))
// } else if quant == fmt.Sprintf("IQ%d", i) {
// return lipgloss.Color(fmt.Sprintf("%d", 50 + i))
// } else if quant == fmt.Sprintf("IQ%d_S", i) {
// return lipgloss.Color(fmt.Sprintf("%d", 60 + i))
// } else if quant == fmt.Sprintf("IQ%d_XS", i) {
// return lipgloss.Color(fmt.Sprintf("%d", 70 + i))
// } else if quant == fmt.Sprintf("IQ%d_XXS", i) {
// return lipgloss.Color(fmt.Sprintf("%d", 80 + i))
// } else if quant == fmt.Sprintf("IQ%d_XXXS", i) {
// return lipgloss.Color(fmt.Sprintf("%d", 90 + i))
// } else if quant == fmt.Sprintf("IQ%d_M", i) {
// return lipgloss.Color(fmt.Sprintf("%d", 100 + i))
// }
// }
// refactored above code to be more concise, based on the quant number ranging from cool to warm colours
// e.g. Q2 < Q2_K < Q2_K_S < Q2_K_M < IQ2 < IQ2_S < IQ2_XS < IQ2_XXS < IQ2_XXXS < IQ2_M < Q3 < Q3_K < Q3_K_S < Q3_K_M < IQ3 < IQ3_S < IQ3_XS < IQ3_XXS < IQ3_XXXS < IQ3_M etc...
quantMap := map[string]int{
"Q2": 10,
"IQ2": 15,
"Q3": 20,
"IQ3": 25,
"Q4": 29,
"IQ4": 40,
"Q5": 44,
"Q6": 47,
"Q8": 88,
"FP16": 200,
"Q2": 10,
"IQ2": 15,
"Q3": 20,
"IQ3": 25,
"Q4": 29,
"IQ4": 40,
"Q5": 44,
"Q6": 47,
"Q8": 88,
"FP16": 200,
}
quantParts := strings.Split(quant, "_")
quantLevel := quantParts[0]
Expand All @@ -482,9 +456,21 @@ func quantColor(quant string) lipgloss.Color {
quantValue := quantMap[quantLevel]
if quantModifier != "" {
quantValue += quantMap[quantModifier]
}
return lipgloss.Color(fmt.Sprintf("%d", 10 + quantValue))
}
return lipgloss.Color(fmt.Sprintf("%d", 10+quantValue))
}

func sizeColor(size float64) lipgloss.Color {
if size < 1 {
return lipgloss.Color("225")
}
if size < 2 {
return lipgloss.Color("215")
}
if size < 3 {
return lipgloss.Color("205")
}
return lipgloss.Color("195")
}

// Render the list items
Expand All @@ -494,29 +480,29 @@ func (d itemDelegate) Render(w io.Writer, m list.Model, index int, item list.Ite
return
}
var nameStyle, idStyle, sizeStyle, quantStyle, modifiedStyle, familyStyle lipgloss.Style
familyColor, exists := familyColors[model.Family]
if !exists {
// pick a random colour between 10 and 200
familyColor = lipgloss.Color(fmt.Sprintf("%d", 10 + index % 190))
}

// set the quantization level colour
quantColor := quantColor(model.QuantizationLevel)
familyColor, exists := familyColors[model.Family]
if !exists {
// pick a random colour between 10 and 200
familyColor = lipgloss.Color(fmt.Sprintf("%d", 10+index%190))
}

// set the quantization level colour
quantColor := quantColor(model.QuantizationLevel)
sizeColor := sizeColor(model.Size)

if index == m.Index() {

// Highlight the selected item
nameStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("205")).Bold(true).BorderLeft(true).BorderStyle(lipgloss.OuterHalfBlockBorder())
sizeStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("120"))
sizeStyle = lipgloss.NewStyle().Foreground(sizeColor)
quantStyle = lipgloss.NewStyle().Foreground(quantColor)
familyStyle = lipgloss.NewStyle().Foreground(familyColor)
modifiedStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("115"))
idStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("225"))
} else {
nameStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("254")).Faint(true)
idStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("254")).Faint(true)
sizeStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("254")).Faint(true)
sizeStyle = lipgloss.NewStyle().Foreground(sizeColor).Faint(true)
familyStyle = lipgloss.NewStyle().Foreground(familyColor)
quantStyle = lipgloss.NewStyle().Foreground(quantColor)
modifiedStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("254")).Faint(true)
Expand Down

0 comments on commit 8915c3b

Please sign in to comment.