github.com/pluralsh/plural-cli@v0.9.5/cmd/plural/help.go (about) 1 package plural 2 3 import ( 4 "fmt" 5 "time" 6 7 "github.com/briandowns/spinner" 8 "github.com/fatih/color" 9 "github.com/pluralsh/plural-cli/pkg/api" 10 "github.com/pluralsh/plural-cli/pkg/utils" 11 "github.com/urfave/cli" 12 ) 13 14 const intro = "What can we do to help you with Plural, using open source, or kubernetes?" 15 16 func (p *Plural) aiHelp(c *cli.Context) error { 17 p.InitPluralClient() 18 chat := []*api.ChatMessage{{Role: "system", Content: intro}} 19 utils.Success("Plural AI:\n") 20 fmt.Printf("%s\n\n", intro) 21 22 for { 23 prompt, err := utils.ReadLine(color.New(color.FgYellow).Sprintf("You:\n")) 24 if err != nil { 25 return err 26 } 27 chat = append(chat, &api.ChatMessage{Role: "user", Content: prompt}) 28 fmt.Print("\n") 29 30 utils.Success("Plural AI:\n") 31 s := spinner.New(spinner.CharSets[32], 100*time.Millisecond) 32 s.Prefix = "Thinking " 33 s.Start() 34 35 msg, err := p.Client.Chat(chat) 36 if err != nil { 37 return err 38 } 39 s.Stop() 40 41 fmt.Printf("%s\n\n", msg.Content) 42 chat = append(chat, msg) 43 } 44 }