Skip to content

Commit

Permalink
feat: added the ability to set a default AI provider for serve
Browse files Browse the repository at this point in the history
Signed-off-by: Kay Yan <[email protected]>
  • Loading branch information
yankay committed Aug 7, 2024
1 parent ad117a5 commit 4ce9379
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cmd/serve/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ var ServeCmd = &cobra.Command{
os.Exit(1)
}
}

// Backend string will have high priority than a default provider
// Hence, use the default provider only if the backend is not specified by the user.
if configAI.DefaultProvider != "" && backend == "" {
backend = configAI.DefaultProvider
}
// Using default provider openai
if backend == "" {
backend = "openai"
}

if aiProvider == nil {
for _, provider := range configAI.Providers {
if backend == provider.Name {
Expand Down Expand Up @@ -197,6 +208,6 @@ func init() {
// add flag for backend
ServeCmd.Flags().StringVarP(&port, "port", "p", "8080", "Port to run the server on")
ServeCmd.Flags().StringVarP(&metricsPort, "metrics-port", "", "8081", "Port to run the metrics-server on")
ServeCmd.Flags().StringVarP(&backend, "backend", "b", "openai", "Backend AI provider")
ServeCmd.Flags().StringVarP(&backend, "backend", "b", "", "Backend AI provider")
ServeCmd.Flags().BoolVarP(&enableHttp, "http", "", false, "Enable REST/http using gppc-gateway")
}

0 comments on commit 4ce9379

Please sign in to comment.