File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : LLM Code Review
2+
3+ on :
4+ pull_request :
5+ types : [opened, synchronize]
6+
7+ jobs :
8+ review :
9+ runs-on : ubuntu-latest
10+ steps :
11+ - name : Checkout code
12+ uses : actions/checkout@v3
13+
14+ - name : Set up Python
15+ uses : actions/setup-python@v4
16+ with :
17+ python-version : ' 3.10'
18+
19+ - name : Install dependencies
20+ run : |
21+ pip install -r requirements.txt
22+
23+ - name : Run code review
24+ run : |
25+ python reviewbot/main.py
Original file line number Diff line number Diff line change 1+ # LLM Code Review Bot
Original file line number Diff line number Diff line change 1+ import os
2+ import requests
3+ from reviewbot .utils import get_diff
4+
5+ def review_with_groq (diff ):
6+ api_key = os .environ .get ("GROQ_API_KEY" )
7+ headers = {
8+ "Authorization" : f"Bearer { api_key } " ,
9+ "Content-Type" : "application/json" ,
10+ }
11+ payload = {
12+ "model" : "mixtral-8x7b-32768" ,
13+ "messages" : [
14+ {"role" : "system" , "content" : "You are a senior software engineer doing code reviews." },
15+ {"role" : "user" , "content" : f"Please review this code diff:\n \n { diff } " }
16+ ],
17+ "temperature" : 0.3 ,
18+ }
19+
20+ response = requests .post ("https://api.groq.com/openai/v1/chat/completions" , headers = headers , json = payload )
21+ return response .json ()["choices" ][0 ]["message" ]["content" ]
22+
23+ def main ():
24+ diff = get_diff ()
25+ review = review_with_groq (diff )
26+ print ("::notice file=test_module/hello.py,line=1::" + review .replace ("\n " , " " ))
27+
28+ if __name__ == "__main__" :
29+ main ()
Original file line number Diff line number Diff line change 1+ # reviewbot/utils.py
2+
3+ def get_diff ():
4+ # In real setup, parse `git diff` or PR files
5+ return "def hello(name):\n print('Hello ' + name)"
6+
7+ def fake_llm_review (diff ):
8+ if "print" in diff :
9+ return "Consider using logging instead of print for better production code quality."
10+ return "No issues found."
Original file line number Diff line number Diff line change 1+ # test_module/hello.py
2+
3+ def hello (name ):
4+ print ("Hello " + name )
5+
6+ hello ("World" )
You can’t perform that action at this time.
0 commit comments