package cmd import ( "fmt" cmdutil "git.mlow.ca/mlow/lmcli/pkg/cmd/util" "git.mlow.ca/mlow/lmcli/pkg/lmcli" "git.mlow.ca/mlow/lmcli/pkg/lmcli/model" "github.com/spf13/cobra" ) func PromptCmd(ctx *lmcli.Context) *cobra.Command { cmd := &cobra.Command{ Use: "prompt [message]", Short: "Do a one-shot prompt", Long: `Prompt the Large Language Model and get a response.`, RunE: func(cmd *cobra.Command, args []string) error { input := inputFromArgsOrEditor(args, "# Write your prompt below\n", "") if input == "" { return fmt.Errorf("No message was provided.") } var messages []model.Message // TODO: stop supplying system prompt as a message system := ctx.GetSystemPrompt() if system != "" { messages = append(messages, model.Message{ Role: model.MessageRoleSystem, Content: system, }) } messages = append(messages, model.Message{ Role: model.MessageRoleUser, Content: input, }) _, err := cmdutil.Prompt(ctx, messages, nil) if err != nil { return fmt.Errorf("Error fetching LLM response: %v", err) } return nil }, } applyPromptFlags(ctx, cmd) return cmd }