-
Notifications
You must be signed in to change notification settings - Fork 125
Expand file tree
/
Copy pathconfigure.go
More file actions
54 lines (49 loc) · 1.56 KB
/
configure.go
File metadata and controls
54 lines (49 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package commands
import (
"fmt"
"github.com/docker/model-runner/cmd/cli/commands/completion"
"github.com/spf13/cobra"
)
func newConfigureCmd() *cobra.Command {
var flags ConfigureFlags
c := &cobra.Command{
Use: "configure [--context-size=<n>] [--speculative-draft-model=<model>] [--hf_overrides=<json>] [--gpu-memory-utilization=<float>] [--mode=<mode>] [--think] MODEL [-- <runtime-flags...>]",
Aliases: []string{"config"},
Short: "Manage model runtime configurations",
Hidden: true,
Args: func(cmd *cobra.Command, args []string) error {
argsBeforeDash := cmd.ArgsLenAtDash()
if argsBeforeDash == -1 {
// No "--" used, so we need exactly 1 total argument.
if len(args) != 1 {
return fmt.Errorf(
"Exactly one model must be specified, got %d: %v\n\n"+
"See 'docker model configure --help' for more information",
len(args), args)
}
} else {
// Has "--", so we need exactly 1 argument before it.
if argsBeforeDash != 1 {
return fmt.Errorf(
"Exactly one model must be specified before --, got %d\n\n"+
"See 'docker model configure --help' for more information",
argsBeforeDash)
}
}
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
model := args[0]
opts, err := flags.BuildConfigureRequest(model)
if err != nil {
return err
}
opts.RuntimeFlags = args[1:]
return desktopClient.ConfigureBackend(opts)
},
ValidArgsFunction: completion.ModelNames(getDesktopClient, -1),
}
flags.RegisterFlags(c)
c.AddCommand(newConfigureShowCmd())
return c
}