LLM Code Review
Overview
llm-code-review is a command-line tool for automated code reviews of GitHub pull requests using OpenAI's GPT models or local models via Ollama. It fetches modified files, extracts diffs, retrieves full file contents for context, and generates concise, constructive code reviews.
Features
- Supports OpenAI API (
gpt-4o-mini, etc.) - Supports local models via Ollama
- Fetches diffs from GitHub pull requests
- Retrieves full file contents for context
- Provides AI-generated feedback with before/after code snippets
- Filters reviews to focus only on Python files
Installation
Install the package from PyPI:
pip install llm-code-review
Prerequisites
Before using the tool, you must set up the required API keys as environment variables:
- GitHub Token: To authenticate API requests, create a GitHub personal access token (with
reposcope for private repositories) and set it as an environment variable. - OpenAI API Key: Obtain an API key from OpenAI and set it as an environment variable.
Setting Up Environment Variables
Add the following lines to your shell profile (e.g., ~/.bashrc, ~/.zshrc):
export GITHUB_TOKEN="your_github_token"
export OPENAI_API_KEY="your_openai_api_key"
Then, reload your shell profile:
source ~/.bashrc # or source ~/.zshrc
Alternatively, you can store them in a .env file and use python-dotenv to load them.
Usage
Basic Command
To review a GitHub pull request:
llm-code-review owner/repository PR_NUMBER
Example:
llm-code-review octocat/hello-world 42
Using a Specific Model
OpenAI
llm-code-review octocat/hello-world 42 --model openai:gpt-4o-mini
Ollama (local model)
llm-code-review octocat/Hello-World 42 --model ollama:deepseek-r1:8b
This command fetches the pull request #42 from the octocat/Hello-World repository, retrieves modified Python files, and reviews the changes using OpenAI.
How It Works
- Fetches pull request details from GitHub.
- Retrieves the full content of modified Python files.
- Sends the diff and full file content to OpenAI for review.
- Displays feedback, focusing on potential improvements and critical issues.
Notes
- Only Python (
.py) files are reviewed. - The review focuses on changes in the PR while using the full file context.
- If a file has more than three issues, only the most important one is highlighted unless critical issues are found.
License
MIT License
Contributions
Feel free to open issues or submit pull requests!
Metadata
Release files for llm-code-review 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| llm_code_review-0.1.1.tar.gz | 4.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llm_code_review-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.2 kB
Release files / llm_code_review-0.1.1.tar.gz
| Download URL | llm_code_review-0.1.1.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8571f3e4703dba5af13a04aa46224fa251c2835f893ed9cc3c860a5ec0d57406
|
|
BLAKE2b-256 checksum How to use checksums |
806672977bed53cc26602a5d0c4084e932ca4c192fcfdbcfc198d7eb07a832a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.13
|
Release files / llm_code_review-0.1.1-py3-none-any.whl
| Download URL | llm_code_review-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e5a6f01a5ca82038f577acfe4bbd1091b4b8a8433e90c685364d7d6867733548
|
|
BLAKE2b-256 checksum How to use checksums |
643fd738336fddc2d38500803939fabe19977856d372f26615b70a4e5ee1f53c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.13
|