ai newsMi., 25. Nov.
EilmeldungYale’s Sonnenfeld: Nvidia is a ‘detriment’ to U.S. industrial might — not a champion

Private AI code review in VS Code with a local Ollama model

Most AI review tools want an account and send your diff to their servers. For client code that is often not allowed. A local model fixes that. Here is the setup I use. I wrote the extension in step 2 so take that part as coming from the author. 1. Install Ollama and pull a coding model ollama pull

dev.toMontag 07:27 · 23.11.2 Min. Lesezeit
Bild: dev.to

Posted on Nov 23 • Originally published at puzaricloud.in

Most AI review tools want an account and send your diff to their servers. For client code that is often not allowed. A local model fixes that. Here is the setup I use. I wrote the extension in step 2 so take that part as coming from the author.

1. Install Ollama and pull a coding model

ollama pull qwen2.5-coder:7b curl http://localhost:11434/api/tags Enter fullscreen mode Exit fullscreen mode A 7B model is about a 5 GB download and wants around 8 GB of free memory.

2. Install a review extension that can talk to Ollama

I use my own one called AI Code Review. It is on the VS Code Marketplace and on Open VSX. There is no sign in step.

Run "AI Code Review: Choose AI Provider and Model" from the Command Palette. Pick Ollama (local), keep http://localhost:11434 and pick the model. Then run "AI Code Review: Test Connection". The first call loads the model so give it a minute.

Open Source Control and press Review Uncommitted Changes. Findings show up as squiggles, in the Problems panel and in a tree grouped by file. Each one has a category (security, bug, performance, style) and a suggested fix on hover.

{ "aiCodeReview.profile": "quick", "aiCodeReview.maxTokensPerRequest": 6000 } Enter fullscreen mode Exit fullscreen mode The quick profile asks only for bugs and security problems. Small models are more accurate when asked for less. A lower token budget splits a big diff into more requests so nothing is cut off.

6. Check that nothing leaves your machine

Turn wifi off and run a review. It still works. Or watch connections with Little Snitch or LuLu while it runs. The only address called is localhost:11434.

On my Intel MacBook with no GPU an 8B model needed 165 seconds for a 15 line change. It found both bugs I planted but small models do invent findings sometimes. The model sees the diff and not the whole repository. Treat it as a second pair of eyes before a human review.

The local path is free with no limit. The extension also has a paid tier for branch review and applying fixes.

Longer version with a model table: https://puzaricloud.in/blog/ai-code-review-vscode-ollama-local-model

Which local model works best for you for review?

Quelle: dev.to (dev.to). Original öffnen