Merge 15225bd99ddd98d69514cff88e9bbbac548abba8 into e27e4a3c1b9cb3a34178d5476debf805910e990a

This commit is contained in:
pacien 2025-03-17 14:51:04 +01:00 committed by GitHub
commit a4441cbf0b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 1 deletions

View File

@ -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",

View File

@ -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)