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 0254bd9 commit 232a9b1
Showing 1 changed file with 61 additions and 61 deletions.
122 changes: 61 additions & 61 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,51 @@ import (
"golang.org/x/term"
)

type Model struct {
Name string
ID string
Size float64
QuantizationLevel string
Modified time.Time
Selected bool
Family string
}

type KeyMap struct {
Space key.Binding
Delete key.Binding
SortByName key.Binding
SortBySize key.Binding
SortByModified key.Binding
RunModel key.Binding
ConfirmYes key.Binding
ConfirmNo key.Binding
}

type AppModel struct {
client *api.Client
list list.Model
keys *KeyMap
models []Model
width int
height int
confirmDeletion bool
selectedForDeletion []Model
}

var (
logLevel = "debug"
debugLogger *log.Logger
infoLogger *log.Logger
errorLogger *log.Logger
)

// Custom delegate to handle the rendering of the list items without extra spacing
type itemDelegate struct {
appModel *AppModel
familyColors map[string]lipgloss.Color
}

func init() {
f, err := os.OpenFile("gollama.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
Expand All @@ -43,27 +81,6 @@ func init() {
errorLogger = log.New(f, "ERROR: ", log.Ldate|log.Ltime|log.Lshortfile)
}

type Model struct {
Name string
ID string
Size float64
QuantizationLevel string
Modified time.Time
Selected bool
Family string
}

type KeyMap struct {
Space key.Binding
Delete key.Binding
SortByName key.Binding
SortBySize key.Binding
SortByModified key.Binding
RunModel key.Binding
ConfirmYes key.Binding
ConfirmNo key.Binding
}

func (m Model) Title() string { return m.Name }

func (m Model) Description() string {
Expand Down Expand Up @@ -108,17 +125,6 @@ func NewKeyMap() *KeyMap {
}
}

type AppModel struct {
client *api.Client
list list.Model
keys *KeyMap
models []Model
width int
height int
confirmDeletion bool
selectedForDeletion []Model
}

func main() {
client, err := api.ClientFromEnvironment()
if err != nil {
Expand Down Expand Up @@ -370,12 +376,6 @@ func calculateColumnWidths(totalWidth int) (nameWidth, sizeWidth, quantWidth, mo
return
}

// Custom delegate to handle the rendering of the list items without extra spacing
type itemDelegate struct {
appModel *AppModel
familyColors map[string]lipgloss.Color
}

func NewItemDelegate(appModel *AppModel) itemDelegate {
return itemDelegate{
appModel: appModel,
Expand Down Expand Up @@ -461,28 +461,28 @@ func quantColor(quant string) lipgloss.Color {
}

func sizeColor(size float64) lipgloss.Color {
if size < 1.0 {
return lipgloss.Color("316")
}
if size < 10 {
return lipgloss.Color("247")
}
if size < 20 {
return lipgloss.Color("325")
}
if size < 35 {
return lipgloss.Color("433")
}
if size < 50 {
return lipgloss.Color("424")
}
if size < 65 {
return lipgloss.Color("454")
}
if size < 80 {
return lipgloss.Color("455")
}
return lipgloss.Color("225")
if size < 1.0 {
return lipgloss.Color("316")
}
if size < 10 {
return lipgloss.Color("247")
}
if size < 20 {
return lipgloss.Color("325")
}
if size < 35 {
return lipgloss.Color("433")
}
if size < 50 {
return lipgloss.Color("424")
}
if size < 65 {
return lipgloss.Color("454")
}
if size < 80 {
return lipgloss.Color("455")
}
return lipgloss.Color("225")
}

// Render the list items
Expand All @@ -500,7 +500,7 @@ func (d itemDelegate) Render(w io.Writer, m list.Model, index int, item list.Ite

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

if index == m.Index() {

Expand Down

0 comments on commit 232a9b1

Please sign in to comment.