|
| 1 | +# LLM API Key Setup Guide |
| 2 | + |
| 3 | +This repository uses AI-powered code review through the Presubmit.ai workflow. To enable this feature, you need to configure the `LLM_API_KEY` secret. |
| 4 | + |
| 5 | +## Quick Setup |
| 6 | + |
| 7 | +### Step 1: Get Your Gemini API Key |
| 8 | + |
| 9 | +1. Visit [Google AI Studio](https://makersuite.google.com/app/apikey) |
| 10 | +2. Sign in with your Google account |
| 11 | +3. Click **"Create API Key"** |
| 12 | +4. Copy the generated API key |
| 13 | + |
| 14 | +### Step 2: Configure the Secret in GitHub |
| 15 | + |
| 16 | +1. Go to your repository: `https://github.com/[YOUR_USERNAME]/java-design-patterns` |
| 17 | +2. Click **Settings** → **Secrets and variables** → **Actions** |
| 18 | +3. Click **"New repository secret"** |
| 19 | +4. Set: |
| 20 | + - **Name**: `LLM_API_KEY` |
| 21 | + - **Secret**: Your Gemini API key from Step 1 |
| 22 | +5. Click **"Add secret"** |
| 23 | + |
| 24 | +### Step 3: Verify Setup |
| 25 | + |
| 26 | +After adding the secret, the next PR or workflow run will automatically use AI review. |
| 27 | + |
| 28 | +## Model Configuration |
| 29 | + |
| 30 | +The workflow is configured to use `gemini-1.5-flash` model. If you need to change this: |
| 31 | + |
| 32 | +1. Edit `.github/workflows/presubmit.yml` |
| 33 | +2. Update the `LLM_MODEL` environment variable |
| 34 | +3. Available models include: |
| 35 | + - `gemini-1.5-pro` |
| 36 | + - `gemini-1.5-flash` (default) |
| 37 | + - `gemini-pro` |
| 38 | + |
| 39 | +## Troubleshooting |
| 40 | + |
| 41 | +### Common Issues |
| 42 | + |
| 43 | +**Error: "LLM_API_KEY secret is not configured"** |
| 44 | +- Solution: Follow Step 2 above to add the secret |
| 45 | + |
| 46 | +**Error: "Model not found" or 404 errors** |
| 47 | +- Check if your API key has access to the specified model |
| 48 | +- Try using `gemini-1.5-pro` instead of `gemini-1.5-flash` |
| 49 | +- Verify your API key is valid and active |
| 50 | + |
| 51 | +**Workflow skips AI review** |
| 52 | +- This is normal behavior when `LLM_API_KEY` is not configured |
| 53 | +- The workflow will continue without AI review |
| 54 | +- Add the secret to enable AI review |
| 55 | + |
| 56 | +### Getting Help |
| 57 | + |
| 58 | +If you encounter issues: |
| 59 | +1. Check the GitHub Actions logs for detailed error messages |
| 60 | +2. Verify your API key is correct and has proper permissions |
| 61 | +3. Ensure you're using a supported model name |
| 62 | + |
| 63 | +## Benefits of AI Review |
| 64 | + |
| 65 | +When properly configured, the AI reviewer will: |
| 66 | +- ✅ Analyze code quality and suggest improvements |
| 67 | +- ✅ Check for potential bugs and security issues |
| 68 | +- ✅ Provide feedback on code style and best practices |
| 69 | +- ✅ Help maintain consistent coding standards |
| 70 | + |
| 71 | +The AI review is **optional** - the main CI/CD pipeline will work without it. |
0 commit comments