A GitHub bot that performs AI-assisted code reviews by analyzing diffs and providing intelligent comments.
- Receives GitHub webhook events for pull requests
- Analyzes code diffs using AI
- Posts review comments back to GitHub
- Built with FastAPI for high performance
- Async/await support for efficient processing
- Python 3.11+
- Poetry (install from https://python-poetry.org/docs/#installation)
- GitHub account and repository access
- Install dependencies:
poetry install- Configure your settings:
cp .env.example .env
# Edit .env with your GitHub token and AI API keysStart the development server:
poetry run uvicorn app.main:app --reload --host 0.0.0.0 --port 8000Or use the Poetry script:
poetry run startpoetry run pytestFormat code:
poetry run black app/ tests/Lint code:
poetry run flake8 app/ tests/
poetry run mypy app/Set these environment variables in your .env file:
GITHUB_TOKEN: Your GitHub personal access tokenGITHUB_WEBHOOK_SECRET: Secret for validating GitHub webhooksAI_API_KEY: API key for your AI service (e.g., OpenAI)AI_MODEL: AI model to use (e.g., gpt-4)AI_BASE_URL: (Optional) Custom base URL for OpenAI-compatible APIs (e.g., Azure OpenAI, LocalAI, Ollama)- If not set, defaults to OpenAI's official API endpoint
- Example for Azure:
https://YOUR-RESOURCE.openai.azure.com/v1 - Example for LocalAI:
http://localhost:8080/v1
app/main.py: FastAPI application entry pointapp/api/: API endpointsapp/services/: Business logic (GitHub integration, AI analysis)app/config.py: Configuration managementtests/: Test suite
- Go to your repository settings → Webhooks
- Add webhook with URL:
https://your-domain.com/webhooks/github - Select events: Pull requests
- Set the webhook secret matching your
GITHUB_WEBHOOK_SECRET
MIT