Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: analyze command default backend bug #966

Merged
merged 2 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/analyze/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ var AnalyzeCmd = &cobra.Command{
withDoc,
interactiveMode,
)

if err != nil {
color.Red("Error: %v", err)
os.Exit(1)
Expand Down Expand Up @@ -124,7 +125,7 @@ func init() {
// explain flag
AnalyzeCmd.Flags().BoolVarP(&explain, "explain", "e", false, "Explain the problem to me")
// add flag for backend
AnalyzeCmd.Flags().StringVarP(&backend, "backend", "b", "openai", "Backend AI provider")
AnalyzeCmd.Flags().StringVarP(&backend, "backend", "b", "", "Backend AI provider")
// output as json
AnalyzeCmd.Flags().StringVarP(&output, "output", "o", "text", "Output format (text, json)")
// add language options for output
Expand Down
8 changes: 6 additions & 2 deletions pkg/analysis/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,15 @@ func NewAnalysis(
}

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

if backend == "" {
backend = "openai"
}

var aiProvider ai.AIProvider
for _, provider := range configAI.Providers {
if backend == provider.Name {
Expand Down
4 changes: 0 additions & 4 deletions pkg/server/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ func (h *handler) Analyze(ctx context.Context, i *schemav1.AnalyzeRequest) (
i.Output = "json"
}

if i.Backend == "" {
JuHyung-Son marked this conversation as resolved.
Show resolved Hide resolved
i.Backend = "openai"
}

if int(i.MaxConcurrency) == 0 {
i.MaxConcurrency = 10
}
Expand Down