Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# AI-Code-Context-Reviewer

An automated AI-Powered pull request reviewer.
## Python Dependency Management ( using `uv` )
Install `uv`: ( official site: [uv Installation Reference↗](https://docs.astral.sh/uv/getting-started/installation/))
```ruby
Expand Down
14 changes: 5 additions & 9 deletions server/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from fastapi import FastAPI, Header
from fastapi.middleware.cors import CORSMiddleware
# from fastapi.middleware.cors import CORSMiddleware
import os
import logging
import requests
Comment on lines 1 to 5
Copy link
Owner Author

Choose a reason for hiding this comment

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

Commenting out the CORSMiddleware import disables CORS handling. Either keep the import and the middleware call if cross‑origin requests are needed, or remove both consistently. Leaving the import commented may cause a NameError later.

Expand All @@ -10,7 +10,7 @@

load_dotenv()
app = FastAPI()
app.add_middleware(CORSMiddleware)
# app.add_middleware(CORSMiddleware)

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
Comment on lines 10 to 16
Copy link
Owner Author

Choose a reason for hiding this comment

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

The middleware registration is also commented out, matching the import removal. Ensure this is intentional; otherwise, re‑enable app.add_middleware(CORSMiddleware) to allow proper CORS support.

Expand Down Expand Up @@ -146,12 +146,12 @@ def handle_pr_event(payload: dict, x_github_event: str = Header(None)):
if x_github_event != "pull_request":
logger.info(f"Ignoring event: {x_github_event}")
return {"msg": "Ignored- not a PR event"}

'''Webhook for PR comments, its for giving review comments'''
if x_github_event == "issue_comment":
comment_response = payload["issue_comment"]["issue"]
if (
comment_response["pull_request"]
and comment_response["comment"] == "/review"
and comment_response["comment"].strip() == "/reviewai"
):
pr_url = comment_response["pull_request"]["url"]
pr_info = requests.get(pr_url, headers=headers)
Comment on lines 146 to 157
Copy link
Owner Author

Choose a reason for hiding this comment

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

Triple‑quoted strings are used as block comments, but they create a runtime string literal that is ignored. Replace them with # comments or proper docstrings to avoid unnecessary objects.

Expand Down Expand Up @@ -255,6 +255,7 @@ def handle_pr_event(payload: dict, x_github_event: str = Header(None)):
pr_response = payload["pull_request"]
logger.info("Received Github PR event")

'''Webhook for Pull request event, It's for Summarization of PR'''
if pr_response["state"] == "open":
system_prompt = """You are an Code Summarizer to help Maintainers/Reviewers. Based on the diffs and context provided by the Pull request with additional details,
you summarize what the PR is about with formatted description if necessary. Changes would be in a table format & related files can be grouped.
Comment on lines 255 to 261
Copy link
Owner Author

Choose a reason for hiding this comment

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

Same issue as Hunk 3: use # comments for explanatory notes instead of stray string literals.

Expand Down Expand Up @@ -309,10 +310,5 @@ def handle_pr_event(payload: dict, x_github_event: str = Header(None)):
return {"msg": "Summary Done"}


# @app.post("/webhook-comment") # some other endpoint name
# def handle_issue_comment_event():
# pass


if __name__ == "__main__":
main()