Skip to content

Minor Re-Formatting & Comments#3

Open
CosmoWorker wants to merge 1 commit intomainfrom
multi-check
Open

Minor Re-Formatting & Comments#3
CosmoWorker wants to merge 1 commit intomainfrom
multi-check

Conversation

@CosmoWorker
Copy link
Owner

  • Made minor changes in the main file with removing unnecessities.
  • Add a concise description to readme.

@CosmoWorker
Copy link
Owner Author

Pull Request Summary

This PR makes a small set of documentation, code‑clean‑up, and usability improvements:

File Change
README.md Added a concise project tagline – “An automated AI‑Powered pull request reviewer.”
server/main.py • Commented‑out the CORSMiddleware import and its registration (app.add_middleware).
• Inserted inline comments that clarify the purpose of the two webhook handlers (PR‑comment review and PR‑summary).
• Updated the trigger command for the review webhook from "/review" to "/reviewai" (trimmed whitespace).
• Minor formatting/whitespace tweaks.

Overall, the changes do not alter the core functionality of the service; they merely:

  • Clarify the repository’s purpose in the README.
  • Disable CORS middleware (likely for a local‑only deployment).
  • Make the review‑trigger command more explicit.
  • Add documentation comments for future maintainers.

Repository Structure (Mermaid)

flowchart TD
    root[Root Directory] --> README[README.md]
    root --> server[server/]
    server --> main[main.py]
Loading

The diagram reflects the current layout:

/ (root)
│─ README.md
└─ server/
   └─ main.py

@vercel
Copy link

vercel bot commented Jan 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
ai-pr-reviewer Ready Ready Preview, Comment Jan 4, 2026 7:09am

@CosmoWorker
Copy link
Owner Author

/review

Comment on lines 1 to 5
from fastapi import FastAPI, Header
from fastapi.middleware.cors import CORSMiddleware
# from fastapi.middleware.cors import CORSMiddleware
import os
import logging
import requests
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.

Comment on lines 10 to 16

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")
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.

Comment on lines 146 to 157
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)
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.

Comment on lines 255 to 261
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.
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.

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.

1 participant