A code review application powered by RAG and small local LLMs.
- Screenshot
- Prerequisites
- Setting Up Your Environment
- Executing a Code Review
- Configuration Options
- Testing & Evaluation
- Demo UI
- Performance Optimization Tips
- Additional Notes
- Clone the repository
- (Recommended) Create a virtual environment:
$ uv venv --python 3.12
- Install dependencies with uv
$ uv pip install -r requirements.lock
- Activate the environment
$ source .venv/bin/activate - Pull required models:
$ ollama pull llama3.1 $ ollama pull qwen2.5-coder:7b-instruct-q8_0 $ ollama pull nomic-embed-text
python -m src.code_reviewer --diff patch.txt \
--repo /Users/kiran/Sandbox/porter/kafka-client \
--planner-model llama3.1:latest \
--worker-model qwen2.5-coder:7b-instruct-q8_0 \
--embedding-model nomic-embed-text:latest \
--format comprehensive_htmlTo generate a patch file, use the following commands:
# For all changes in staging area
git diff > patch.txt
# For changes between branches
git diff main feature-branch > patch.txt
# For changes in specific files
git diff -- path/to/file1.py path/to/file2.py > patch.txt| Option | Description | Default |
|---|---|---|
--diff |
Path to git diff file | Required |
--repo |
Path to repository root | ./ (current directory) |
--prompt |
System prompt for the code review | "Perform a thorough code review..." |
--ollama-host |
Host of the Ollama API | http://localhost:11434 |
--planner-model |
Model for planning and summarization | llama3.1 |
--worker-model |
Model for worker agents | qwen2.5-coder:7b-instruct-q8_0 |
--embedding-model |
Model for text embeddings | nomic-embed-text |
--reindex |
Force reindexing of the codebase | false |
To run all tests:
$ pytestTo run evaluations, do the following:
# Install project as a package to enable running the evaluation script
$ pip install -e .
# Evaluate context (file + symbol) retrieval
$ python -m code_reviewer.evals.code_retrieval_eval --test-cases-file src/code_reviewer/evals/test_cases.json
# Evaluate symbol retrieval
$ python -m code_reviewer.evals.code_retrieval_eval --test-cases-file src/code_reviewer/evals/test_cases_symbol_lookup.json- The
.chromadirectory stores the code index and can be deleted to force a full reindex.
