Private
Public Access
1
0

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:
2025-07-29 01:41:58 +00:00
parent 5335b5c28f
commit 0cf0a4ff0d
5 changed files with 90 additions and 90 deletions

View File

@@ -261,7 +261,7 @@ func (m *Model) conversationMessagesView() string {
heading := m.renderMessageHeading(-1, &conversation.Message{
Role: api.MessageRoleAssistant,
Metadata: conversation.MessageMeta{
GenerationModel: &m.App.Model,
GenerationModel: &m.App.Model.Model,
},
})
sb.WriteString(heading)

View File

@@ -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)