Skip to content

Conversation

@EuclidStellar
Copy link

PR : Ollama Model Setup and AI code Review with qwen3:14B using GitHub Action

This workflow automates code review for pull requests using the Ollama LLM and the qwen3:14b model. It fetches the PR diff, sends it to the LLM for review, and posts the review as a comment on the PR.


📋 Workflow Overview

Step Description
1 Checkout Repository: Fetches the full repo history for accurate diffs.
2 Install Ollama: Installs the Ollama LLM runtime.
3 Start Ollama & Pull Model: Starts Ollama and downloads the qwen3:14b model.
4 Get PR Diff: Computes the code changes between the PR branch and its base.
5 Review with Ollama: Sends the diff and a review prompt to the LLM.
6 Remove LLM Thinking Process: Filters out non-actionable LLM output.
7 Set Review Output: Prepares the review for posting.
8 Create PR Comment: Posts the review as a comment on the PR.
9 Cleanup: Stops the Ollama service.
10 Show Diff File: Prints the diff for debugging.

🔍 Example PR Review

PR Title Model Used Link
Example PR reviewed qwen3:14b View PR

🛠️ Key Features

  • Automated LLM code review for every PR.
  • Removes LLM "thinking process" from comments for clean, actionable feedback.
  • Easy to extend for other models or prompts.

🧩 Workflow Table

Name Purpose Key Command/Action
Checkout Repository Fetch full git history for accurate diffs actions/checkout@v4
Install Ollama Install Ollama LLM runtime curl -fsSL https://ollama.com/install.sh | sh
Start Ollama & Pull Model Start Ollama server and pull the model ollama serve, ollama pull qwen3:14b
Get PR Diff Generate diff between PR and base branch git diff origin/${{ github.base_ref }}...HEAD
Review PR with Ollama Send diff and prompt to LLM, save output ollama run qwen3:14b
Remove LLM thinking process from review Filter out "Thinking..." sections from LLM output awk script
Set review output as environment var Prepare review for posting cat ollama_clean_review.txt
Create PR Comment Post review as PR comment actions/github-script@v6
Stop Ollama Service (Cleanup) Kill Ollama server process kill $OLLAMA_PID
Show diff file Print diff for debugging cat pr_diff.txt

📝 How It Works

  1. On PR or manual trigger, the workflow checks out the code and installs Ollama.
  2. Ollama is started and the qwen3:14b model is pulled.
  3. The workflow generates a git diff between the PR branch and its base.
  4. The diff is sent to the LLM with a detailed review prompt.
  5. The LLM's "thinking process" (if present) is filtered out for clarity.
  6. The actionable review is posted as a comment on the PR.
  7. Ollama is stopped and the diff is shown for debugging.

🛡️ Permissions

Permission Why Needed
contents: read To checkout code
pull-requests: write To post review comments
issues: write For general issue comments

🧩 Requirements

  • GitHub Actions runner: Ubuntu (Linux)
  • Ollama model: Sufficient disk space and memory for model download

@keploy
Copy link

keploy bot commented Jul 1, 2025

No significant changes currently retry

Copy link
Member

@khareyash05 khareyash05 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets Test

@khareyash05 khareyash05 merged commit 8774366 into keploy:dev-review-setup Jul 1, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants