Better `lmcli prompt` input handling

This commit is contained in:
Matt Low 2023-11-04 22:53:09 +00:00
parent 6465ce5146
commit 4590f1db38
1 changed files with 8 additions and 2 deletions

View File

@ -68,7 +68,7 @@ var newCmd = &cobra.Command{
Short: "Start a new conversation",
Long: `Start a new conversation with the Large Language Model.`,
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 {
Fatal("Failed to get input: %v\n", err)
return
@ -103,9 +103,15 @@ var promptCmd = &cobra.Command{
Short: "Do a one-shot prompt",
Long: `Prompt the Large Language Model and get a response.`,
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{
{
OriginalContent: strings.Join(args, " "),
OriginalContent: message,
Role: "user",
},
}