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:
@@ -4,7 +4,8 @@ import (
|
||||
"time"
|
||||
|
||||
"git.mlow.ca/mlow/lmcli/pkg/api"
|
||||
"git.mlow.ca/mlow/lmcli/pkg/api/provider"
|
||||
"git.mlow.ca/mlow/lmcli/pkg/provider"
|
||||
"git.mlow.ca/mlow/lmcli/pkg/conversation"
|
||||
"git.mlow.ca/mlow/lmcli/pkg/tui/model"
|
||||
"github.com/charmbracelet/bubbles/cursor"
|
||||
"github.com/charmbracelet/bubbles/spinner"
|
||||
@@ -20,14 +21,12 @@ type (
|
||||
msgConversationTitleGenerated string
|
||||
// sent when the conversation has been persisted, triggers a reload of contents
|
||||
msgConversationPersisted struct {
|
||||
isNew bool
|
||||
conversation *api.Conversation
|
||||
messages []api.Message
|
||||
conversation *conversation.Conversation
|
||||
messages []conversation.Message
|
||||
}
|
||||
// sent when a conversation's messages are laoded
|
||||
msgConversationMessagesLoaded struct {
|
||||
messages []api.Message
|
||||
rootMessages []api.Message
|
||||
messages []conversation.Message
|
||||
}
|
||||
// a special case of common.MsgError that stops the response waiting animation
|
||||
msgChatResponseError struct {
|
||||
@@ -36,19 +35,19 @@ type (
|
||||
// sent on each chunk received from LLM
|
||||
msgChatResponseChunk provider.Chunk
|
||||
// sent on each completed reply
|
||||
msgChatResponse *api.Message
|
||||
msgChatResponse *conversation.Message
|
||||
// sent when the response is canceled
|
||||
msgChatResponseCanceled struct{}
|
||||
// sent when results from a tool call are returned
|
||||
msgToolResults []api.ToolResult
|
||||
// sent when the given message is made the new selected reply of its parent
|
||||
msgSelectedReplyCycled *api.Message
|
||||
msgSelectedReplyCycled *conversation.Message
|
||||
// sent when the given message is made the new selected root of the current conversation
|
||||
msgSelectedRootCycled *api.Message
|
||||
msgSelectedRootCycled *conversation.Message
|
||||
// sent when a message's contents are updated and saved
|
||||
msgMessageUpdated *api.Message
|
||||
msgMessageUpdated *conversation.Message
|
||||
// sent when a message is cloned, with the cloned message
|
||||
msgMessageCloned *api.Message
|
||||
msgMessageCloned *conversation.Message
|
||||
)
|
||||
|
||||
type focusState int
|
||||
@@ -84,7 +83,7 @@ type Model struct {
|
||||
selectedMessage int
|
||||
editorTarget editorTarget
|
||||
stopSignal chan struct{}
|
||||
replyChan chan api.Message
|
||||
replyChan chan conversation.Message
|
||||
chatReplyChunks chan provider.Chunk
|
||||
persistence bool // whether we will save new messages in the conversation
|
||||
|
||||
@@ -137,7 +136,7 @@ func Chat(app *model.AppModel) *Model {
|
||||
persistence: true,
|
||||
|
||||
stopSignal: make(chan struct{}),
|
||||
replyChan: make(chan api.Message),
|
||||
replyChan: make(chan conversation.Message),
|
||||
chatReplyChunks: make(chan provider.Chunk),
|
||||
|
||||
wrap: true,
|
||||
|
||||
Reference in New Issue
Block a user