Skip to content

Commit

Permalink
feat: add role-file flag to support role configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
kardolus committed Dec 9, 2024
1 parent ec5a924 commit a487fbd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/chatgpt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var (
listThreads bool
hasPipe bool
promptFile string
roleFile string
threadName string
ServiceURL string
shell string
Expand Down Expand Up @@ -196,6 +197,15 @@ func run(cmd *cobra.Command, args []string) error {
return nil
}

if cmd.Flag("role-file").Changed {
role, err := utils.FileToString(roleFile)
if err != nil {
return err
}
cfg.Role = role
viper.Set("role", role)
}

if showConfig {
allSettings := viper.AllSettings()

Expand Down Expand Up @@ -599,6 +609,7 @@ func setupFlags(rootCmd *cobra.Command) {
rootCmd.PersistentFlags().BoolVarP(&newThread, "new-thread", "n", false, "Create a new thread with a random name and target it")
rootCmd.PersistentFlags().BoolVarP(&listModels, "list-models", "l", false, "List available models")
rootCmd.PersistentFlags().StringVarP(&promptFile, "prompt", "p", "", "Provide a prompt file")
rootCmd.PersistentFlags().StringVarP(&roleFile, "role-file", "", "", "Provide a role file")
rootCmd.PersistentFlags().BoolVarP(&listThreads, "list-threads", "", false, "List available threads")
rootCmd.PersistentFlags().StringVar(&threadName, "delete-thread", "", "Delete the specified thread")
rootCmd.PersistentFlags().BoolVar(&showHistory, "show-history", false, "Show the human-readable conversation history")
Expand Down

0 comments on commit a487fbd

Please sign in to comment.