diff --git a/main.go b/main.go index af57fb3..bd5d550 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "fmt" "os" + "strings" "github.com/spf13/cobra" ) @@ -117,8 +118,30 @@ var newCmd = &cobra.Command{ }, } +var promptCmd = &cobra.Command{ + Use: "prompt", + Short: "Do a one-shot prompt", + Long: `Prompt the Large Language Model and get a response.`, + Run: func(cmd *cobra.Command, args []string) { + messages := []Message{ + { + OriginalContent: strings.Join(args, " "), + Role: "user", + }, + } + + err := CreateChatCompletionStream("You are a helpful assistant.", messages, os.Stdout) + if err != nil { + fmt.Fprintf(os.Stderr, "An error occured: %v\n", err) + os.Exit(1) + } + + fmt.Println() + }, +} + func main() { - rootCmd.AddCommand(newCmd) // Add other commands similarly + rootCmd.AddCommand(newCmd, promptCmd) if err := rootCmd.Execute(); err != nil { fmt.Println(err) os.Exit(1)