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:
@@ -22,11 +22,11 @@ func EditCmd(ctx *lmcli.Context) *cobra.Command {
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
shortName := args[0]
|
||||
conversation := cmdutil.LookupConversation(ctx, shortName)
|
||||
c := cmdutil.LookupConversation(ctx, shortName)
|
||||
|
||||
messages, err := ctx.Store.PathToLeaf(conversation.SelectedRoot)
|
||||
messages, err := ctx.Conversations.PathToLeaf(c.SelectedRoot)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Could not retrieve messages for conversation: %s", conversation.Title)
|
||||
return fmt.Errorf("Could not retrieve messages for conversation: %s", c.Title)
|
||||
}
|
||||
|
||||
offset, _ := cmd.Flags().GetInt("offset")
|
||||
@@ -62,11 +62,11 @@ func EditCmd(ctx *lmcli.Context) *cobra.Command {
|
||||
// Update the message in-place
|
||||
inplace, _ := cmd.Flags().GetBool("in-place")
|
||||
if inplace {
|
||||
return ctx.Store.UpdateMessage(&toEdit)
|
||||
return ctx.Conversations.UpdateMessage(&toEdit)
|
||||
}
|
||||
|
||||
// Otherwise, create a branch for the edited message
|
||||
message, _, err := ctx.Store.CloneBranch(toEdit)
|
||||
message, _, err := ctx.Conversations.CloneBranch(toEdit)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -74,11 +74,11 @@ func EditCmd(ctx *lmcli.Context) *cobra.Command {
|
||||
if desiredIdx > 0 {
|
||||
// update selected reply
|
||||
messages[desiredIdx-1].SelectedReply = message
|
||||
err = ctx.Store.UpdateMessage(&messages[desiredIdx-1])
|
||||
err = ctx.Conversations.UpdateMessage(&messages[desiredIdx-1])
|
||||
} else {
|
||||
// update selected root
|
||||
conversation.SelectedRoot = message
|
||||
err = ctx.Store.UpdateConversation(conversation)
|
||||
c.SelectedRoot = message
|
||||
err = ctx.Conversations.UpdateConversation(c)
|
||||
}
|
||||
return err
|
||||
},
|
||||
@@ -87,7 +87,7 @@ func EditCmd(ctx *lmcli.Context) *cobra.Command {
|
||||
if len(args) != 0 {
|
||||
return nil, compMode
|
||||
}
|
||||
return ctx.Store.ConversationShortNameCompletions(toComplete), compMode
|
||||
return ctx.Conversations.ConversationShortNameCompletions(toComplete), compMode
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user