-
Notifications
You must be signed in to change notification settings - Fork 1
Minor Re-Formatting & Comments #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
|
|
@@ -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
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
|
@@ -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
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
|
@@ -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
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same issue as Hunk 3: use |
||
|
|
@@ -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() | ||
There was a problem hiding this comment.
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.