Skip to content

Commit fb61f33

Browse files
committed
fix
1 parent d64c6e1 commit fb61f33

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

openai/openai.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
_ "embed"
66
"fmt"
7+
"time"
78

89
"github.com/sashabaranov/go-openai"
910
)
@@ -37,8 +38,21 @@ func (o *Client) ChatCompletion(ctx context.Context, messages []openai.ChatCompl
3738
)
3839

3940
if err != nil {
40-
fmt.Printf("ChatCompletion error: %v\n", err)
41-
return "", err
41+
fmt.Println("Error completing prompt:", err)
42+
fmt.Println("Retrying after 1 minute")
43+
// retry once after 1 minute
44+
time.Sleep(time.Minute)
45+
resp, err = o.client.CreateChatCompletion(
46+
ctx,
47+
openai.ChatCompletionRequest{
48+
Model: openai.GPT3Dot5Turbo,
49+
Messages: messages,
50+
Temperature: 0.1,
51+
},
52+
)
53+
if err != nil {
54+
return "", fmt.Errorf("error completing prompt: %w", err)
55+
}
4256
}
4357

4458
return resp.Choices[0].Message.Content, nil

review/review.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ func GenerateCommentsFromDiff(ctx context.Context, openAIClient Completer, diff
7979
fmt.Println("Review is good")
8080
continue
8181
}
82-
for i, issue := range review.Issues {
82+
for _, issue := range review.Issues {
8383
if issue.Line == 0 {
84-
issue.Line = i + 1
84+
fmt.Printf("Skipping file-level issue: %v\n", issue)
85+
continue // TODO: add support for file-level issues
8586
}
8687
body := fmt.Sprintf("[%s] %s", issue.Type, issue.Description)
8788
comment := &github.PullRequestComment{
@@ -101,7 +102,7 @@ func PushComments(ctx context.Context, prUpdated PullRequestUpdater, owner, repo
101102
for i, c := range comments {
102103
fmt.Printf("creating comment: %s %d/%d\n", *c.Path, i+1, len(comments))
103104
if _, err := prUpdated.CreatePullRequestComment(ctx, owner, repo, number, c); err != nil {
104-
return fmt.Errorf("error creating comment: %w", err)
105+
return fmt.Errorf("error creating comment: %w\n%+v\n", err, *c)
105106
}
106107
}
107108
return nil

0 commit comments

Comments
 (0)