Work to simplify model config handling
Keep a direct reference to a provider.ModelConfig in TUI's AppModel, rather than the names of the provider and model
This commit is contained in:
@@ -3,6 +3,7 @@ package settings
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"git.mlow.ca/mlow/lmcli/pkg/provider"
|
||||
"git.mlow.ca/mlow/lmcli/pkg/tui/bubbles/list"
|
||||
"git.mlow.ca/mlow/lmcli/pkg/tui/model"
|
||||
"git.mlow.ca/mlow/lmcli/pkg/tui/shared"
|
||||
@@ -21,11 +22,6 @@ type Model struct {
|
||||
height int
|
||||
}
|
||||
|
||||
type modelOpt struct {
|
||||
provider string
|
||||
model string
|
||||
}
|
||||
|
||||
const (
|
||||
modelListId int = iota + 1
|
||||
)
|
||||
@@ -72,9 +68,8 @@ func (m *Model) Update(msg tea.Msg) (shared.ViewModel, tea.Cmd) {
|
||||
case list.MsgOptionSelected:
|
||||
switch msg.ID {
|
||||
case modelListId:
|
||||
if modelOpt, ok := msg.Option.Value.(modelOpt); ok {
|
||||
m.App.Model = modelOpt.model
|
||||
m.App.ProviderName = modelOpt.provider
|
||||
if modelConfig, ok := msg.Option.Value.(provider.ModelConfig); ok {
|
||||
m.App.Model = modelConfig
|
||||
}
|
||||
return m, shared.ChangeView(m.prevView)
|
||||
}
|
||||
@@ -103,10 +98,10 @@ func (m *Model) getModelOptions() []list.OptionGroup {
|
||||
group := list.OptionGroup{
|
||||
Name: providerLabel,
|
||||
}
|
||||
for _, model := range p.Models() {
|
||||
for _, model := range m.App.Ctx.GetProviderModels(p) {
|
||||
group.Options = append(group.Options, list.Option{
|
||||
Label: model.Name,
|
||||
Value: modelOpt{provider, model.Name},
|
||||
Label: model.Model,
|
||||
Value: model,
|
||||
})
|
||||
}
|
||||
modelOpts = append(modelOpts, group)
|
||||
|
||||
Reference in New Issue
Block a user