Skip to content

Commit

Permalink
Merge pull request k8sgpt-ai#118 from k8sgpt-ai/feat/exhaustion
Browse files Browse the repository at this point in the history
fix: short term solution for exhaustion
  • Loading branch information
AlexsJones authored Mar 28, 2023
2 parents d0e4684 + 5890e3a commit b3efdf8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cmd/analyze/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ var AnalyzeCmd = &cobra.Command{
if explain {
parsedText, err := analyzer.ParseViaAI(ctx, aiClient, analysis.Error, nocache)
if err != nil {
// Check for exhaustion
if strings.Contains(err.Error(), "status code: 429") {
color.Red("Exhausted API quota. Please try again later")
os.Exit(1)
}
color.Red("Error: %v", err)
continue
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func ParseViaAI(ctx context.Context, aiClient ai.IAI, prompt []string,
response, err := aiClient.GetCompletion(ctx, inputKey)
if err != nil {
color.Red("error getting completion: %v", err)
return "", nil
return "", err
}

if !viper.IsSet(sEnc) {
Expand Down

0 comments on commit b3efdf8

Please sign in to comment.