Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
github concurrency limits (#381)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by openai -->
### Summary by OpenAI

**New Feature:**
- Introduced a new input `github_concurrency_limit` with a default value
of 6 to control the concurrency of retrieving file contents.
- Increased the default values for `openai_concurrency_limit`.

**Refactor:**
- Replaced `console.log` calls with `warning` calls in the `onRateLimit`
and `onSecondaryRateLimit` functions.

**Documentation:**
- Updated README.md with improved formatting, grammar, punctuation,
installation instructions, and examples.

> 🎉 With limits set and warnings in place, 🚀
> Our code now runs at a smoother pace. 🏃‍♂️💨
> Docs polished with a shiny face, ✨
> Making it easier for all to embrace. 🤗🌐
<!-- end of auto-generated comment: release notes by openai -->
  • Loading branch information
harjotgill authored Jul 25, 2023
1 parent ae22296 commit a116595
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 95 deletions.
37 changes: 19 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## AI based PR reviewer and summarizer
# AI-based PR reviewer and summarizer

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

<div>
<a href="https://github.com/coderabbitai/openai-pr-reviewer)/commits/main">
<img alt="GitHub" src="https://img.shields.io/github/last-commit/coderabbitai/openai-pr-reviewer/main?style=for-the-badge" height="20">
Expand All @@ -8,14 +10,15 @@

## Overview

CodeRabbit `ai-pr-reviewer` is an open-source project built on AI, designed to
enhance developer productivity and efficiency by performing automated reviews of
pull requests. Features:

CodeRabbit ai-pr-reviewer is an open-source project built on AI, designed to enhance developer productivity and efficiency by performing automated reviews of pull requests.
Features:

- **PR Summarization**: It generates a summary and release notes of the changes in the pull request.
- **Line-by-line code change suggestions**: Reviews the changes line
by line and provides code change suggestions that can be directly committed
from the GitHub UI.
- **PR Summarization**: It generates a summary and release notes of the changes
in the pull request.
- **Line-by-line code change suggestions**: Reviews the changes line by line and
provides code change suggestions that can be directly committed from the
GitHub UI.
- **Continuous, incremental reviews**: Reviews are performed on each commit
within a pull request, rather than a one-time review on the entire pull
request.
Expand All @@ -37,8 +40,10 @@ Features:
`summarize_release_notes` prompts to focus on specific aspects of the review
process or even change the review objective.

To use this tool, you need to add the provided YAML file to your repository and configure the required environment variables, such as GITHUB_TOKEN and OPENAI_API_KEY.
For more information on usage, examples, contributing, and FAQs, you can refer to the sections below.
To use this tool, you need to add the provided YAML file to your repository and
configure the required environment variables, such as `GITHUB_TOKEN` and
`OPENAI_API_KEY`. For more information on usage, examples, contributing, and
FAQs, you can refer to the sections below.

- [Overview](#overview)
- [Install instructions](#install-instructions)
Expand All @@ -48,9 +53,9 @@ For more information on usage, examples, contributing, and FAQs, you can refer t
- [FAQs](#faqs)

## Install instructions
ai-pr-reviewer runs as a GitHub Action.
Add the below file to your repository at
`.github/workflows/openai-pr-reviewer.yml`

`ai-pr-reviewer` runs as a GitHub Action. Add the below file to your repository
at `.github/workflows/openai-pr-reviewer.yml`

```yaml
name: Code Review
Expand Down Expand Up @@ -85,7 +90,6 @@ jobs:
review_comment_lgtm: false
```
#### Environment variables
- `GITHUB_TOKEN`: This should already be available to the GitHub Action
Expand Down Expand Up @@ -146,7 +150,6 @@ system_message: |
</details>
## Conversation with OpenAI
You can reply to a review comment made by this action and get a response based
Expand All @@ -170,8 +173,8 @@ To ignore a PR, add the following keyword in the PR description:
@openai: ignore
```


## Examples

Some of the reviews done by ai-pr-reviewer

![PR Summary](./docs/images/openai-pr-summary.png)
Expand All @@ -185,7 +188,6 @@ Some of the reviews done by ai-pr-reviewer
Any suggestions or pull requests for improving the prompts are highly
appreciated.


## Contribute

### Developing
Expand All @@ -205,7 +207,6 @@ Build the typescript and package it for distribution
$ npm run build && npm run package
```


## FAQs

### Review pull requests from forks
Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ inputs:
openai_concurrency_limit:
required: false
description: 'How many concurrent API calls to make to OpenAI servers?'
default: '4'
default: '6'
github_concurrency_limit:
required: false
description: 'How many concurrent API calls to make to GitHub?'
default: '6'
system_message:
required: false
description: 'System message to be sent to OpenAI'
Expand Down
29 changes: 17 additions & 12 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ async function run(): Promise<void> {
getInput('openai_retries'),
getInput('openai_timeout_ms'),
getInput('openai_concurrency_limit'),
getInput('github_concurrency_limit'),
getInput('openai_base_url')
)

Expand Down
10 changes: 5 additions & 5 deletions src/octokit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {getInput} from '@actions/core'
import {getInput, warning} from '@actions/core'
import {Octokit} from '@octokit/action'
import {retry} from '@octokit/plugin-retry'
import {throttling} from '@octokit/plugin-throttling'
Expand All @@ -13,22 +13,22 @@ export const octokit = new RetryAndThrottlingOctokit({
onRateLimit: (
retryAfter: number,
options: any,
_o: typeof Octokit,
_o: any,
retryCount: number
) => {
console.log(
warning(
`Request quota exhausted for request ${options.method} ${options.url}
Retry after: ${retryAfter} seconds
Retry count: ${retryCount}
`
)
if (retryCount <= 3) {
console.log(`Retrying after ${retryAfter} seconds!`)
warning(`Retrying after ${retryAfter} seconds!`)
return true
}
},
onSecondaryRateLimit: (retryAfter: number, options: any) => {
console.log(
warning(
`SecondaryRateLimit detected for request ${options.method} ${options.url} ; retry after ${retryAfter} seconds`
)
}
Expand Down
6 changes: 5 additions & 1 deletion src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class Options {
openaiRetries: number
openaiTimeoutMS: number
openaiConcurrencyLimit: number
githubConcurrencyLimit: number
lightTokenLimits: TokenLimits
heavyTokenLimits: TokenLimits
apiBaseUrl: string
Expand All @@ -35,7 +36,8 @@ export class Options {
openaiModelTemperature = '0.0',
openaiRetries = '3',
openaiTimeoutMS = '120000',
openaiConcurrencyLimit = '4',
openaiConcurrencyLimit = '6',
githubConcurrencyLimit = '6',
apiBaseUrl = 'https://api.openai.com/v1'
) {
this.debug = debug
Expand All @@ -52,6 +54,7 @@ export class Options {
this.openaiRetries = parseInt(openaiRetries)
this.openaiTimeoutMS = parseInt(openaiTimeoutMS)
this.openaiConcurrencyLimit = parseInt(openaiConcurrencyLimit)
this.githubConcurrencyLimit = parseInt(githubConcurrencyLimit)
this.lightTokenLimits = new TokenLimits(openaiLightModel)
this.heavyTokenLimits = new TokenLimits(openaiHeavyModel)
this.apiBaseUrl = apiBaseUrl
Expand All @@ -73,6 +76,7 @@ export class Options {
info(`openai_retries: ${this.openaiRetries}`)
info(`openai_timeout_ms: ${this.openaiTimeoutMS}`)
info(`openai_concurrency_limit: ${this.openaiConcurrencyLimit}`)
info(`github_concurrency_limit: ${this.githubConcurrencyLimit}`)
info(`summary_token_limits: ${this.lightTokenLimits.string()}`)
info(`review_token_limits: ${this.heavyTokenLimits.string()}`)
info(`api_base_url: ${this.apiBaseUrl}`)
Expand Down
Loading

0 comments on commit a116595

Please sign in to comment.