δΈζζζ‘£ | English
An intelligent Pull Request code review bot based on Gemini AI that automatically performs in-depth code reviews on GitHub PRs and provides constructive improvement suggestions.
- π€ Intelligent code review based on Google Gemini AI
- π Automatic generation of detailed review reports with issue identification and improvement suggestions
- π Support for automatic Webhook triggers and manual comment triggers (
/review
) - π Smart file context analysis for more accurate review opinions
- π·οΈ Automatic addition of review labels
- β‘ Support for retry mechanisms and error handling
- π οΈ Flexible environment variable configuration
View actual operation results: Example PR Review
git clone <repository-url>
cd pr-review-bot
pip install -r requirements.txt
Copy the example configuration file and fill in actual values:
cp env.example .env
Then edit the .env
file, or directly set the following environment variables:
# GitHub Personal Access Token (requires repo permissions)
# How to get: GitHub Settings β Developer settings β Personal access tokens β Tokens
# Required permissions: Pull requests, Issues
GITHUB_TOKEN=your_github_token
# Google Gemini API Key
GEMINI_API_KEY=your_gemini_api_key
# AI model configuration
AI_MODEL_NAME=gemini-2.5-pro # Default: gemini-2.5-pro
# Review configuration
REVIEW_LABEL=ReviewedByUllrAI # Default: ReviewedByUllrAI
MAX_PROMPT_LENGTH=200000 # Default: 200000
INCLUDE_FILE_CONTEXT=true # Default: true
CONTEXT_MAX_LINES=400 # Default: 400
CONTEXT_SURROUNDING_LINES=50 # Default: 50
MAX_FILES_PER_REVIEW=50 # Default: 50
# Output language configuration
OUTPUT_LANGUAGE=english # Default: english (can be any language like "Chinese", "Japanese", etc.)
# Network and retry configuration
MAX_RETRY_ATTEMPTS=3 # Default: 3
RETRY_DELAY=2.0 # Default: 2.0
REQUEST_TIMEOUT=60 # Default: 60
# Server configuration
PORT=5001 # Default: 5001
python app.py
The service will start on the specified port (default 5001).
Configure Webhook in your GitHub repository:
- Go to repository settings β Webhooks β Add webhook
- Payload URL:
http://your-server:5001/webhook
- Content type:
application/json
- Events: Select
Pull requests
andIssue comments
Note: Currently no Webhook signature verification is required, no need to configure secret.
The bot will automatically review the following events:
- When PR is created (
pull_request.opened
) - When PR is updated (
pull_request.synchronize
) - When PR is reopened (
pull_request.reopened
)
Enter /review
in PR comments to manually trigger code review.
GITHUB_TOKEN
: GitHub Personal Access Token, requiresrepo
permissionsGEMINI_API_KEY
: Google Gemini API key
AI_MODEL_NAME
: Gemini model name to useMAX_PROMPT_LENGTH
: Maximum prompt length sent to AIINCLUDE_FILE_CONTEXT
: Whether to include complete file context for analysis
CONTEXT_MAX_LINES
: Maximum line limit for complete filesCONTEXT_SURROUNDING_LINES
: Number of context lines for code snippetsMAX_FILES_PER_REVIEW
: Maximum number of files per review
OUTPUT_LANGUAGE
: Specifies the language for AI review comments (default: english). Can be set to any language like "Chinese", "Japanese", "French", etc. If set to "english" or not configured, no language instruction will be added to AI prompts.
MAX_RETRY_ATTEMPTS
: Number of retries when API calls failRETRY_DELAY
: Retry interval time (seconds)REQUEST_TIMEOUT
: HTTP request timeout (seconds)
GET /health
Returns service status and configuration information.