diff --git a/cmd/review/review.go b/cmd/review/review.go index 2c907dc..fd3cdb0 100644 --- a/cmd/review/review.go +++ b/cmd/review/review.go @@ -40,9 +40,10 @@ func processFiles(ctx context.Context, openAIClient *oAIClient.Client, diff *git continue } - if len(patch) > 3000 { + maxLength := 4096 - len(oAIClient.PromptReview) + if len(patch) > maxLength { fmt.Println("Patch is too long, truncating") - patch = fmt.Sprintf("%s...", patch[:3000]) + patch = fmt.Sprintf("%s...", patch[:maxLength]) } completion, err := openAIClient.ChatCompletion(ctx, []openai.ChatCompletionMessage{ { @@ -71,7 +72,10 @@ func processFiles(ctx context.Context, openAIClient *oAIClient.Client, diff *git fmt.Println("Review is good") continue } - for _, issue := range review.Issues { + for i, issue := range review.Issues { + if issue.Line == 0 { + issue.Line = i + 1 + } body := fmt.Sprintf("[%s] %s", issue.Type, issue.Description) comment := &github.PullRequestComment{ CommitID: diff.Commits[len(diff.Commits)-1].SHA, diff --git a/openai/openai.go b/openai/openai.go index 9ecf258..8d320d7 100644 --- a/openai/openai.go +++ b/openai/openai.go @@ -8,7 +8,7 @@ import ( "github.com/sashabaranov/go-openai" ) -//go:embed assets/review.txt +//go:embed prompt-review.txt var PromptReview string const ( diff --git a/openai/assets/review.txt b/openai/prompt-review.txt similarity index 100% rename from openai/assets/review.txt rename to openai/prompt-review.txt