Delete 'retried' messages in lmcli retry

This commit is contained in:
Matt Low 2023-11-29 04:50:45 +00:00
parent ed6ee9bea9
commit 4f37ed046b
2 changed files with 12 additions and 0 deletions

View File

@ -472,6 +472,14 @@ var retryCmd = &cobra.Command{
lastUserMessageIndex = i
break
}
if lastUserMessageIndex == 0 {
// haven't found the the last user message yet, delete this one
err = store.DeleteMessage(&messages[i])
if err != nil {
Warn("Could not delete previous reply: %v\n", err)
}
}
}
messages = messages[:lastUserMessageIndex+1]

View File

@ -97,6 +97,10 @@ func (s *Store) SaveMessage(message *Message) error {
return s.db.Create(message).Error
}
func (s *Store) DeleteMessage(message *Message) error {
return s.db.Delete(&message).Error
}
func (s *Store) Conversations() ([]Conversation, error) {
var conversations []Conversation
err := s.db.Find(&conversations).Error