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 2a8a9b4 commit 9787881
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
}

Check warning on line 144 in cmd/serve/serve.go

View check run for this annotation

Codecov / codecov/patch

cmd/serve/serve.go#L142-L144

Added lines #L142 - L144 were not covered by tests
// Using default provider openai
if backend == "" {
backend = "openai"
}

Check warning on line 148 in cmd/serve/serve.go

View check run for this annotation

Codecov / codecov/patch

cmd/serve/serve.go#L146-L148

Added lines #L146 - L148 were not covered by tests

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

Check warning on line 211 in cmd/serve/serve.go

View check run for this annotation

Codecov / codecov/patch

cmd/serve/serve.go#L211

Added line #L211 was not covered by tests
ServeCmd.Flags().BoolVarP(&enableHttp, "http", "", false, "Enable REST/http using gppc-gateway")
}

0 comments on commit 9787881

Please sign in to comment.