Skip to content

Commit a147bb6

Browse files
committed
Slow twosum solution
1 parent 67394ff commit a147bb6

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

.github/mode-context.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/github/context-server/main/schema.json",
3+
"name": "LLM Code Review Bot",
4+
"description": "A bot that uses LLMs to review pull request code diffs and post comments.",
5+
"app": {
6+
"name": "llm-code-review-bot",
7+
"version": "0.1.0"
8+
},
9+
"config": {
10+
"entrypoint": "reviewbot.main:main",
11+
"runtime": {
12+
"language": "python"
13+
}
14+
},
15+
"capabilities": {
16+
"pullRequestReview": true
17+
}
18+
}

reviewbot/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import requests
33
from reviewbot.utils import get_diff, post_pr_comment, get_pr_number
44

5+
llm_prompt = "Please reviiew thsi code diff, list improvements and potential optimizations in bullet points";
6+
57
def review_with_groq(diff):
68
api_key = os.environ.get("GROQ_API_KEY")
79
headers = {
@@ -12,7 +14,7 @@ def review_with_groq(diff):
1214
"model": "meta-llama/llama-4-scout-17b-16e-instruct",
1315
"messages": [
1416
{"role": "system", "content": "You are a senior software engineer doing code reviews."},
15-
{"role": "user", "content": f"Please review this code diff, list improvements in bullet points:\n\n{diff}"}
17+
{"role": "user", "content": f"{llm_prompt} given the following diff{diff}"}
1618
],
1719
"temperature": 0.3,
1820
}

reviewbot/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def get_pr_number():
1313
return event["pull_request"]["number"]
1414

1515
def get_diff():
16-
repo = os.environ.get("GITHUB_REPOSITORY") # e.g. "owner/repo"
16+
repo = os.environ.get("GITHUB_REPOSITORY")
1717
pr_number = get_pr_number()
1818

1919
token = os.environ.get("GITHUB_TOKEN")

test_module/hello.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Hello.py: A sample python script used for testing reviews
22

3-
def helloWorld():
4-
print("Hello World")
3+
def twoSum(array, targetSum):
4+
for i in range(0, len(array)):
5+
for j in range(i+1, len(array)):
6+
if array[i] + array[j] == targetSum:
7+
return ([array[i], array[j]])
8+
return []
59

6-
helloWorld()
10+
twoSum([2,7,11,15], 9)
11+

0 commit comments

Comments
 (0)