-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfig.go
More file actions
48 lines (39 loc) · 1.22 KB
/
config.go
File metadata and controls
48 lines (39 loc) · 1.22 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
package cmd
import (
"fmt"
"github.com/inference-gateway/cli/config"
"github.com/spf13/cobra"
)
var configCmd = &cobra.Command{
Use: "config",
Short: "Manage CLI configuration",
Long: `Manage the Inference Gateway CLI configuration settings.`,
}
var setModelCmd = &cobra.Command{
Use: "set-model [MODEL_NAME]",
Short: "Set the default model for chat sessions",
Long: `Set the default model for chat sessions. When a default model is configured,
the chat command will skip the model selection view and use the configured model directly.`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
modelName := args[0]
return setDefaultModel(modelName)
},
}
func setDefaultModel(modelName string) error {
cfg, err := config.LoadConfig("")
if err != nil {
return fmt.Errorf("failed to load config: %w", err)
}
cfg.Chat.DefaultModel = modelName
if err := cfg.SaveConfig(""); err != nil {
return fmt.Errorf("failed to save config: %w", err)
}
fmt.Printf("✅ Default model set to: %s\n", modelName)
fmt.Println("The chat command will now use this model by default and skip model selection.")
return nil
}
func init() {
configCmd.AddCommand(setModelCmd)
rootCmd.AddCommand(configCmd)
}