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