Compare commits
2 Commits
f6ded3e20e
...
59e78669c8
Author | SHA1 | Date | |
---|---|---|---|
59e78669c8 | |||
1966ec881b |
@ -2,6 +2,7 @@ package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
@ -228,9 +229,9 @@ var lsCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
var rmCmd = &cobra.Command{
|
||||
Use: "rm <conversation>",
|
||||
Short: "Remove a conversation",
|
||||
Long: `Removes a conversation by its short name.`,
|
||||
Use: "rm <conversation>...",
|
||||
Short: "Remove conversations",
|
||||
Long: `Remove conversations by their short names.`,
|
||||
Args: func(cmd *cobra.Command, args []string) error {
|
||||
argCount := 1
|
||||
if err := cobra.MinimumNArgs(argCount)(cmd, args); err != nil {
|
||||
@ -239,7 +240,8 @@ var rmCmd = &cobra.Command{
|
||||
return nil
|
||||
},
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
shortName := args[0]
|
||||
var toRemove []*Conversation
|
||||
for _, shortName := range args {
|
||||
conversation, err := store.ConversationByShortName(shortName)
|
||||
if err != nil {
|
||||
Fatal("Could not search for conversation: %v\n", err)
|
||||
@ -247,17 +249,35 @@ var rmCmd = &cobra.Command{
|
||||
if conversation.ID == 0 {
|
||||
Fatal("Conversation not found with short name: %s\n", shortName)
|
||||
}
|
||||
err = store.DeleteConversation(conversation)
|
||||
toRemove = append(toRemove, conversation)
|
||||
}
|
||||
var errors []error
|
||||
for _, c := range toRemove {
|
||||
err := store.DeleteConversation(c)
|
||||
if err != nil {
|
||||
Fatal("Could not delete conversation: %v\n", err)
|
||||
errors = append(errors, fmt.Errorf("Could not remove conversation %s: %v", c.ShortName.String, err))
|
||||
}
|
||||
}
|
||||
for _, err := range errors {
|
||||
fmt.Fprintln(os.Stderr, err.Error())
|
||||
}
|
||||
if len(errors) > 0 {
|
||||
os.Exit(1)
|
||||
}
|
||||
},
|
||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
compMode := cobra.ShellCompDirectiveNoFileComp
|
||||
if len(args) != 0 {
|
||||
return nil, compMode
|
||||
var completions []string
|
||||
outer: for _, completion := range store.ConversationShortNameCompletions(toComplete) {
|
||||
parts := strings.Split(completion, "\t")
|
||||
for _, arg := range args {
|
||||
if parts[0] == arg {
|
||||
continue outer
|
||||
}
|
||||
return store.ConversationShortNameCompletions(toComplete), compMode
|
||||
}
|
||||
completions = append(completions, completion)
|
||||
}
|
||||
return completions, compMode
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ func CreateChatCompletion(model string, messages []Message, maxTokens int, repli
|
||||
messages = append(append(messages, assistantReply), toolReplies...)
|
||||
// Recurse into CreateChatCompletion with the tool call replies added
|
||||
// to the original messages
|
||||
return CreateChatCompletion(model, append(messages, toolReplies...), maxTokens, replies)
|
||||
return CreateChatCompletion(model, messages, maxTokens, replies)
|
||||
}
|
||||
|
||||
if replies != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user