Large refactor - it compiles!
This refactor splits out all conversation concerns into a new `conversation` package. There is now a split between `conversation` and `api`s representation of `Message`, the latter storing the minimum information required for interaction with LLM providers. There is necessary conversation between the two when making LLM calls.
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"git.mlow.ca/mlow/lmcli/pkg/api"
|
||||
"git.mlow.ca/mlow/lmcli/pkg/conversation"
|
||||
"git.mlow.ca/mlow/lmcli/pkg/tui/styles"
|
||||
tuiutil "git.mlow.ca/mlow/lmcli/pkg/tui/util"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
@@ -44,7 +45,7 @@ var (
|
||||
footerStyle = lipgloss.NewStyle().Padding(0, 1)
|
||||
)
|
||||
|
||||
func (m *Model) renderMessageHeading(i int, message *api.Message) string {
|
||||
func (m *Model) renderMessageHeading(i int, message *conversation.Message) string {
|
||||
friendly := message.Role.FriendlyRole()
|
||||
style := systemStyle
|
||||
|
||||
@@ -70,15 +71,15 @@ func (m *Model) renderMessageHeading(i int, message *api.Message) string {
|
||||
prefix = " "
|
||||
}
|
||||
|
||||
if i == 0 && len(m.App.RootMessages) > 1 && m.App.Conversation.SelectedRootID != nil {
|
||||
if i == 0 && len(m.App.Conversation.RootMessages) > 1 && m.App.Conversation.SelectedRootID != nil {
|
||||
selectedRootIndex := 0
|
||||
for j, reply := range m.App.RootMessages {
|
||||
for j, reply := range m.App.Conversation.RootMessages {
|
||||
if reply.ID == *m.App.Conversation.SelectedRootID {
|
||||
selectedRootIndex = j
|
||||
break
|
||||
}
|
||||
}
|
||||
suffix += faintStyle.Render(fmt.Sprintf(" <%d/%d>", selectedRootIndex+1, len(m.App.RootMessages)))
|
||||
suffix += faintStyle.Render(fmt.Sprintf(" <%d/%d>", selectedRootIndex+1, len(m.App.Conversation.RootMessages)))
|
||||
}
|
||||
if i > 0 && len(m.App.Messages[i-1].Replies) > 1 {
|
||||
// Find the selected reply index
|
||||
@@ -230,9 +231,9 @@ func (m *Model) conversationMessagesView() string {
|
||||
|
||||
// Render a placeholder for the incoming assistant reply
|
||||
if m.state == pendingResponse && m.App.Messages[len(m.App.Messages)-1].Role != api.MessageRoleAssistant {
|
||||
heading := m.renderMessageHeading(-1, &api.Message{
|
||||
heading := m.renderMessageHeading(-1, &conversation.Message{
|
||||
Role: api.MessageRoleAssistant,
|
||||
Metadata: api.MessageMeta{
|
||||
Metadata: conversation.MessageMeta{
|
||||
GenerationModel: &m.App.Model,
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user