Better lmcli prompt input handling

This commit is contained in:
Matt Low 2023-11-04 22:53:09 +00:00
parent 6465ce5146
commit 4590f1db38

View File

@ -68,7 +68,7 @@ var newCmd = &cobra.Command{
Short: "Start a new conversation", Short: "Start a new conversation",
Long: `Start a new conversation with the Large Language Model.`, Long: `Start a new conversation with the Large Language Model.`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
messageContents, err := InputFromEditor("# What would you like to say?", "message.*.md") messageContents, err := InputFromEditor("# What would you like to say?\n", "message.*.md")
if err != nil { if err != nil {
Fatal("Failed to get input: %v\n", err) Fatal("Failed to get input: %v\n", err)
return return
@ -103,9 +103,15 @@ var promptCmd = &cobra.Command{
Short: "Do a one-shot prompt", Short: "Do a one-shot prompt",
Long: `Prompt the Large Language Model and get a response.`, Long: `Prompt the Large Language Model and get a response.`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
message := strings.Join(args, " ")
if len(strings.Trim(message, " \t\n")) == 0 {
Fatal("No message was provided.\n")
return
}
messages := []Message{ messages := []Message{
{ {
OriginalContent: strings.Join(args, " "), OriginalContent: message,
Role: "user", Role: "user",
}, },
} }