Skip to content

Commit

Permalink
fix: Addded logger and prompt updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sauravpanda committed Apr 1, 2024
1 parent 43787de commit 1118bdf
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,5 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

.env
.env
*.pem
2 changes: 1 addition & 1 deletion api/github_helper/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
GITHUB_ENDPOINTS = {
"get_installations": urljoin(GITHUB_API_BASE_URL, "installations"),
"get_installation_access_token": urljoin(
GITHUB_API_BASE_URL, "installations/{installation_id}/access_tokens"
GITHUB_API_BASE_URL, "/app/installations/{installation_id}/access_tokens"
),
}
1 change: 1 addition & 0 deletions api/github_helper/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

def get_installations():
headers = utils.HEADERS
headers["Authorization"] = f"Bearer {utils.generate_jwt()}"
url = GITHUB_ENDPOINTS["get_installations"]
response = requests.get(url, headers=headers)
response.raise_for_status()
Expand Down
4 changes: 2 additions & 2 deletions api/github_helper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
GITHUB_APP_WEBHOOK_SECRET = os.environ.get("GITHUB_APP_WEBHOOK_SECRET")


HEADER = {
HEADERS = {
"Authorization": None,
"Accept": "application/vnd.github.v3+json",
"X-GitHub-Api-Version": "2022-11-28",
Expand All @@ -26,7 +26,7 @@ def generate_jwt():
"exp": expiration_time,
"iss": GITHUB_APP_ID
}
with open(".key.pem", "r") as f:
with open("GITHUB_APP_KEY.pem", "r") as f:
# Encode the JWT using the RS256 algorithm
encoded_jwt = jwt.encode(payload, f.read(), algorithm="RS256")
return encoded_jwt
Expand Down
5 changes: 4 additions & 1 deletion codecheck/actions/reviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
from codecheck.llms.provider import chat_completion
from codecheck.llms.prompts import CODE_REVIEW_PROMPT, CODE_REVIEW_SYSTEM_PROMPT
import requests
import logging

logger = logging.getLogger(__name__)


def review_pull_request(
Expand Down Expand Up @@ -39,4 +42,4 @@ def post_pull_request(url, data, access_token):
"Accept": "application/vnd.github.v3+json",
}
response = requests.post(url, headers=headers, json=data)
print("Post Pull request response: ", response.text)
logger.info(f"Post Pull request response: {response.text}")
2 changes: 2 additions & 0 deletions codecheck/llms/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@
8. **General Feedback**: Provide overall feedback on the code changes, highlighting strengths and areas for improvement.
Your code review should be thorough, constructive, and actionable, helping the developer understand your concerns and recommendations clearly. Point to the code while suggesting changes.
Respond as a json with the feedback in a list; example: {{"review": {{"Testing missing": ["details"], "Security Vulnerability": ["details"]}} }}
"""
131 changes: 130 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fastapi = "^0.110.0"
litellm = "^1.34.18"
flake8 = "^7.0.0"
black = "^24.3.0"
cryptography = "^42.0.5"


[build-system]
Expand Down

0 comments on commit 1118bdf

Please sign in to comment.