AI for code analysis
P4 Code Review enhances the code review process by using an AI model (similar to those from OpenAI) to generate explanations for code diffs in a file, making it easier for developers to understand and review changes.
You can send the whole diff of a file for AI code analysis or just a selection.
To send the whole diff for AI code analysis, click the AI button in the numbered panel.
To send a selection of code, first select the code to send for AI code analysis, then click the AI button .
The AI code analysis is returned as text in a pop window.
Only the diff (or selected diff content), filename, and the file extension are sent to the AI vendor for analysis. P4 Code Review does not send the whole file.
P4 Code Review has been tested with the following AI vendors and models:
-
OpenAI -
gpt-4
-
LM Studio - all provided models which include:
lmstudio-community/gemma-3-1B-it-qat-GGUF
lmstudio-community/Qwen3-1.7B-GGUF
lmstudio-community/DeepSeek-R1-Distill-Llama-8B-GGUF
lmstudio-community/Meta-Llama-3.1-8B-Instruct-GGU
The configuration to integrate AI into P4 Code Review is specified within an ai_review block in the SWARM_ROOT/data/config.php
file. By default, ai_review block is disabled. To enable AI-driven code explanations for a diff, set enabled to true.