nikhmr1235 commited on
Commit
0735b43
·
verified ·
1 Parent(s): 38bf3ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -13,6 +13,8 @@ from langgraph.checkpoint.sqlite import SqliteSaver
13
  import os
14
  import logging
15
  import uuid
 
 
16
 
17
  # Load environment variables from .env file
18
  load_dotenv()
@@ -34,6 +36,18 @@ if not require_human_approval:
34
  print("require_human_approval key not found in environment variables.")
35
  print(f"Using require_human_approval key: {require_human_approval}")
36
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  # --- Build the Graph ---
39
  workflow = StateGraph(PRReviewState)
@@ -279,6 +293,7 @@ async def github_webhook(
279
  encoded_review_link = quote_plus(review_url)
280
  gradio_review_url = f"{GRADIO_SPACE_BASE_URL}?review_id={review_id}&review_link={encoded_review_link}"
281
 
 
282
  comment_body = f"""
283
  🤖 **Human Review Required!** 🤖
284
 
@@ -290,6 +305,7 @@ async def github_webhook(
290
  """
291
 
292
  try:
 
293
  repo = g.get_repo(repo_name)
294
  # In GitHub API, PR comments are typically added as "issue comments"
295
  # because PRs are a type of issue internally.
 
13
  import os
14
  import logging
15
  import uuid
16
+ from github import Github # pip install PyGithub
17
+ from urllib.parse import quote_plus
18
 
19
  # Load environment variables from .env file
20
  load_dotenv()
 
36
  print("require_human_approval key not found in environment variables.")
37
  print(f"Using require_human_approval key: {require_human_approval}")
38
 
39
+ google_api_key = os.getenv("GOOGLE_API_KEY")
40
+ if not google_api_key:
41
+ print("Google API key not found in environment variables.")
42
+ print(f"Using Google API key: {google_api_key[:4]}... (truncated for security)")
43
+
44
+ git_hub_token = os.getenv("GITHUB_token_ID")
45
+ if not git_hub_token:
46
+ print("git_hub_token not found in environment variables.")
47
+ print(f"git_hub_token : {git_hub_token[:4]}... (truncated for security)")
48
+
49
+
50
+
51
 
52
  # --- Build the Graph ---
53
  workflow = StateGraph(PRReviewState)
 
293
  encoded_review_link = quote_plus(review_url)
294
  gradio_review_url = f"{GRADIO_SPACE_BASE_URL}?review_id={review_id}&review_link={encoded_review_link}"
295
 
296
+ print(f"gradio_review_url:{gradio_review_url}\nencoded_review_link:{encoded_review_link}")
297
  comment_body = f"""
298
  🤖 **Human Review Required!** 🤖
299
 
 
305
  """
306
 
307
  try:
308
+ g = Github(git_hub_token)
309
  repo = g.get_repo(repo_name)
310
  # In GitHub API, PR comments are typically added as "issue comments"
311
  # because PRs are a type of issue internally.