elismasilva commited on
Commit
a0bcd1f
·
1 Parent(s): 37cd7f5

fix validation inputs

Browse files
Files changed (3) hide show
  1. .gitignore +2 -1
  2. README.md +2 -1
  3. app.py +41 -13
.gitignore CHANGED
@@ -13,4 +13,5 @@ node_modules
13
  backend/**/templates/
14
  README_TEMPLATE.md
15
  .env
16
- *.pem
 
 
13
  backend/**/templates/
14
  README_TEMPLATE.md
15
  .env
16
+ *.pem
17
+ post.md
README.md CHANGED
@@ -61,8 +61,9 @@ This MCP Server provides a suite of **AI-powered tools** that act as an autonomo
61
 
62
  Read the announcement and join the discussion:
63
  - **[LinkedIn post link]**: [View on LinkedIn](https://www.linkedin.com/posts/elismasilva_mcpsfirstbirthdayhackathon-gradiohackathon-activity-7396911353602400256-PEk6?utm_source=share&utm_medium=member_desktop&rcm=ACoAAARdvBoBOi8NC3UXuKIGEUImbEK50Lgwp6E)
 
64
  - **[Twitter/X post link]** : [View on X](https://x.com/pelolisu/status/1991152303777149115)
65
- - **[HuggingFace Discord announcement link]**: [Read on discord]()
66
  ---
67
 
68
  ## 🛠️ Key Tools & Features
 
61
 
62
  Read the announcement and join the discussion:
63
  - **[LinkedIn post link]**: [View on LinkedIn](https://www.linkedin.com/posts/elismasilva_mcpsfirstbirthdayhackathon-gradiohackathon-activity-7396911353602400256-PEk6?utm_source=share&utm_medium=member_desktop&rcm=ACoAAARdvBoBOi8NC3UXuKIGEUImbEK50Lgwp6E)
64
+ - **[LinkedIn announcement link]**: [View on LinkedIn](https://www.linkedin.com/posts/elismasilva_mcp-modelcontextprotocol-aiagents-activity-7400313069454733312-cm5v?utm_source=share&utm_medium=member_desktop&rcm=ACoAAARdvBoBOi8NC3UXuKIGEUImbEK50Lgwp6E)
65
  - **[Twitter/X post link]** : [View on X](https://x.com/pelolisu/status/1991152303777149115)
66
+ - **[HuggingFace Discord announcement link]**: [Read on discord](https://discord.com/channels/879548962464493619/1439001549492719726/1444098108181970954)
67
  ---
68
 
69
  ## 🛠️ Key Tools & Features
app.py CHANGED
@@ -312,8 +312,16 @@ def analyze_github_issue(
312
 
313
  _validate_api_keys(llm_api_key, request)
314
 
315
- if not repo_url or not issue_number:
316
- return "## Error\nPlease provide both a repository URL and an issue number."
 
 
 
 
 
 
 
 
317
 
318
  try:
319
  repo_slug = "/".join(repo_url.strip().replace("https://github.com/", "").split("/")[:2])
@@ -506,10 +514,17 @@ def find_duplicate_issues(
506
  """
507
 
508
  _validate_api_keys(llm_api_key, request)
509
-
510
- if not repo_url or not issue_number:
511
- return "Please provide the repository and the main issue number."
512
-
 
 
 
 
 
 
 
513
  try:
514
  owner, repo = repo_url.strip().replace("https://github.com/", "").split("/")
515
  repo_slug = f"{owner}/{repo}"
@@ -526,7 +541,9 @@ def find_duplicate_issues(
526
 
527
  if not main_issue:
528
  conn.close()
529
- return "Main issue not found in cache. Please synchronize the repository first."
 
 
530
 
531
  # STEP 1: TIMELINE
532
  progress(0.2, desc="Fetching timeline for mentions...")
@@ -602,7 +619,7 @@ def find_duplicate_issues(
602
  )
603
 
604
  if rate_limit_warning:
605
- return f"{rate_limit_warning}\n\n{raw_output}"
606
 
607
  if "## Duplicate Analysis" not in raw_output:
608
  raw_output = f"## Duplicate Analysis for Issue #{issue_number}\n\n{raw_output}"
@@ -646,9 +663,10 @@ def prioritize_open_issues(
646
  _validate_api_keys(llm_api_key, request)
647
 
648
  if not repo_url:
649
- yield "Please provide the repository URL.", ""
650
- return
651
-
 
652
  try:
653
  repo_slug = "/".join(repo_url.strip().replace("https://github.com/", "").split("/")[:2])
654
 
@@ -785,10 +803,20 @@ def reply_and_close_issue(
785
  close_issue (bool): If True, changes the issue state to 'closed'.
786
  github_token (str): MANDATORY. A GitHub token with write permissions.
787
  """
788
- # Security check: This tool ALWAYS requires a token via API or UI
789
  if not github_token:
790
  raise gr.Error("⚠️ Write Permission Error: A GitHub Token is mandatory for posting comments or closing issues.")
791
-
 
 
 
 
 
 
 
 
 
 
792
  try:
793
  owner, repo = repo_url.strip().replace("https://github.com/", "").split("/")
794
  repo_slug = f"{owner}/{repo}"
 
312
 
313
  _validate_api_keys(llm_api_key, request)
314
 
315
+ if not repo_url:
316
+ error = "## Error\nPlease provide a repository URL."
317
+ gr.Info(f"⚠️ {error}")
318
+ return error, gr.skip()
319
+
320
+ if not issue_number or issue_number == 0:
321
+ error = "Please provide the issue number."
322
+ gr.Info(f"⚠️ {error}")
323
+ return error, gr.skip()
324
+
325
 
326
  try:
327
  repo_slug = "/".join(repo_url.strip().replace("https://github.com/", "").split("/")[:2])
 
514
  """
515
 
516
  _validate_api_keys(llm_api_key, request)
517
+
518
+ if not repo_url:
519
+ error = "Please provide the repository URL and the main issue number."
520
+ gr.Info(f"⚠️ {error}")
521
+ return error, gr.skip()
522
+
523
+ if not issue_number or issue_number == 0:
524
+ error = "Please provide the main issue number."
525
+ gr.Info(f"⚠️ {error}")
526
+ return error, gr.skip()
527
+
528
  try:
529
  owner, repo = repo_url.strip().replace("https://github.com/", "").split("/")
530
  repo_slug = f"{owner}/{repo}"
 
541
 
542
  if not main_issue:
543
  conn.close()
544
+ error = "Main issue not found in cache. Please synchronize the repository first."
545
+ gr.Info(f"⚠️ {error}")
546
+ return error, gr.skip()
547
 
548
  # STEP 1: TIMELINE
549
  progress(0.2, desc="Fetching timeline for mentions...")
 
619
  )
620
 
621
  if rate_limit_warning:
622
+ return f"{rate_limit_warning}\n\n{raw_output}", None
623
 
624
  if "## Duplicate Analysis" not in raw_output:
625
  raw_output = f"## Duplicate Analysis for Issue #{issue_number}\n\n{raw_output}"
 
663
  _validate_api_keys(llm_api_key, request)
664
 
665
  if not repo_url:
666
+ error = "Please provide the repository URL."
667
+ gr.Info(f"⚠️ {error}")
668
+ return error, gr.skip()
669
+
670
  try:
671
  repo_slug = "/".join(repo_url.strip().replace("https://github.com/", "").split("/")[:2])
672
 
 
803
  close_issue (bool): If True, changes the issue state to 'closed'.
804
  github_token (str): MANDATORY. A GitHub token with write permissions.
805
  """
806
+
807
  if not github_token:
808
  raise gr.Error("⚠️ Write Permission Error: A GitHub Token is mandatory for posting comments or closing issues.")
809
+
810
+ if not repo_url:
811
+ error = "Please provide the repository URL."
812
+ gr.Info(f"⚠️ {error}")
813
+ return error
814
+
815
+ if not issue_number or issue_number == 0:
816
+ error = "Please provide the issue number."
817
+ gr.Info(f"⚠️ {error}")
818
+ return error
819
+
820
  try:
821
  owner, repo = repo_url.strip().replace("https://github.com/", "").split("/")
822
  repo_slug = f"{owner}/{repo}"