diff --git a/cmd/cmd.go b/cmd/cmd.go index 710f49a72..d6cb8123c 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -241,6 +241,7 @@ func loadOrUnloadModel(cmd *cobra.Command, opts *runOptions) error { req := &api.GenerateRequest{ Model: opts.Model, + Options: opts.Options, KeepAlive: opts.KeepAlive, } @@ -264,10 +265,23 @@ func StopHandler(cmd *cobra.Command, args []string) error { func RunHandler(cmd *cobra.Command, args []string) error { interactive := true + rawParams, err := cmd.Flags().GetStringToString("parameter") + if err != nil { + return err + } + paramSingletons := make(map[string][]string) + for key, rawParam := range rawParams { + paramSingletons[key] = []string{rawParam} + } + parameters, err := api.FormatParams(paramSingletons) + if err != nil { + return err + } + opts := runOptions{ Model: args[0], WordWrap: os.Getenv("TERM") == "xterm-256color", - Options: map[string]interface{}{}, + Options: parameters, } format, err := cmd.Flags().GetString("format") @@ -276,6 +290,12 @@ func RunHandler(cmd *cobra.Command, args []string) error { } opts.Format = format + system, err := cmd.Flags().GetString("system") + if err != nil { + return err + } + opts.System = system + keepAlive, err := cmd.Flags().GetString("keepalive") if err != nil { return err @@ -1252,6 +1272,8 @@ func NewCLI() *cobra.Command { runCmd.Flags().Bool("insecure", false, "Use an insecure registry") runCmd.Flags().Bool("nowordwrap", false, "Don't wrap words to the next line automatically") runCmd.Flags().String("format", "", "Response format (e.g. json)") + runCmd.Flags().String("system", "", "Set system message") + runCmd.Flags().StringToString("parameter", map[string]string{}, "Set a parameter (e.g. num_ctx:4096)") stopCmd := &cobra.Command{ Use: "stop MODEL", diff --git a/cmd/interactive.go b/cmd/interactive.go index d85510d45..1afa62b39 100644 --- a/cmd/interactive.go +++ b/cmd/interactive.go @@ -123,6 +123,11 @@ func generateInteractive(cmd *cobra.Command, opts runOptions) error { scanner.HistoryDisable() } + if opts.System != "" { + newMessage := api.Message{Role: "system", Content: opts.System} + opts.Messages = append(opts.Messages, newMessage) + } + fmt.Print(readline.StartBracketedPaste) defer fmt.Printf(readline.EndBracketedPaste)