-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathcli.go
More file actions
79 lines (61 loc) · 2.35 KB
/
cli.go
File metadata and controls
79 lines (61 loc) · 2.35 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package cmd
import (
"log"
"github.com/EinStack/glide/pkg/version"
"github.com/EinStack/glide/pkg/config"
"github.com/EinStack/glide/pkg"
"github.com/spf13/cobra"
)
var (
dotEnvFile string
cfgFile string
)
const Description = `
██████╗ ██╗ ██╗██████╗ ███████╗
██╔════╝ ██║ ██║██╔══██╗██╔════╝
██║ ███╗██║ ██║██║ ██║█████╗
██║ ██║██║ ██║██║ ██║██╔══╝
╚██████╔╝███████╗██║██████╔╝███████╗
╚═════╝ ╚══════╝╚═╝╚═════╝ ╚══════╝
🐦An open-source, lightweight, high-performance model gateway
to make your LLM applications production ready 🎉
📚Documentation: https://glide.einstack.ai
🛠️Source: https://github.com/EinStack/glide
💬Discord: https://discord.gg/pt53Ej7rrc
🐛Bug Tracker: https://github.com/EinStack/glide/issues
🏗️EinStack Community (mailto:contact@einstack.ai), 2024-Present (c)
`
// NewCLI Create a Glide CLI
func NewCLI() *cobra.Command {
// TODO: Chances are we could use the build in flags module in this is all we need from CLI
cli := &cobra.Command{
Use: "github.com/EinStack/glide",
Short: "🐦Glide is an open-source, lightweight, high-performance model gateway",
Long: Description,
Version: version.FullVersion,
RunE: func(cmd *cobra.Command, _ []string) error {
configProvider := config.NewProvider()
err := configProvider.LoadDotEnv(dotEnvFile)
if err != nil {
log.Println("⚠️failed to load dotenv file: ", err) // don't have an inited logger at this moment
} else {
log.Printf("🔧dot env file is loaded (%v)", dotEnvFile)
}
_, err = configProvider.Load(cfgFile)
if err != nil {
return err
}
gateway, err := pkg.NewGateway(configProvider)
if err != nil {
return err
}
return gateway.Run(cmd.Context())
},
SilenceUsage: true,
SilenceErrors: true,
}
cli.PersistentFlags().StringVarP(&dotEnvFile, "env", "e", ".env", "dotenv file")
cli.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file")
_ = cli.MarkPersistentFlagRequired("config")
return cli
}