Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,14 +13,22 @@ from Gradio_UI import GradioUI
|
|
| 13 |
ddg = DuckDuckGoSearchTool(max_results=5)
|
| 14 |
|
| 15 |
@tool
|
| 16 |
-
def github_issues(repo: str, state: str = "open", limit: int = 5) ->
|
| 17 |
"""
|
| 18 |
-
Fetch recent issues from a public GitHub repo.
|
| 19 |
|
| 20 |
Args:
|
| 21 |
repo: GitHub repo in the form "owner/name" (e.g. "facebook/react").
|
| 22 |
state: "open", "closed", or "all".
|
| 23 |
limit: Maximum number of issues to return (max GitHub default = 30).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
"""
|
| 25 |
url = f"https://api.github.com/repos/{repo}/issues"
|
| 26 |
params = {"state": state, "per_page": min(limit, 30)}
|
|
@@ -32,25 +40,33 @@ def github_issues(repo: str, state: str = "open", limit: int = 5) -> str:
|
|
| 32 |
except Exception as e:
|
| 33 |
return f"❌ GitHub request error: {e}"
|
| 34 |
|
| 35 |
-
|
|
|
|
| 36 |
for issue in data:
|
| 37 |
-
# Skip PRs (GitHub
|
| 38 |
if "pull_request" in issue:
|
| 39 |
continue
|
| 40 |
-
|
| 41 |
number = issue.get("number")
|
| 42 |
-
title = issue.get("title"
|
| 43 |
html_url = issue.get("html_url")
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
break
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
return f"ℹ️ No issues found for repo '{repo}' (state={state})"
|
| 52 |
-
|
| 53 |
-
return f"📌 GitHub issues for **{repo}** (state={state}):\n" + "\n".join(issues)
|
| 54 |
|
| 55 |
@tool
|
| 56 |
def web_search(query:str)-> str:
|
|
|
|
| 13 |
ddg = DuckDuckGoSearchTool(max_results=5)
|
| 14 |
|
| 15 |
@tool
|
| 16 |
+
def github_issues(repo: str, state: str = "open", limit: int = 5) -> List[Dict]:
|
| 17 |
"""
|
| 18 |
+
Fetch recent issues from a public GitHub repo.
|
| 19 |
|
| 20 |
Args:
|
| 21 |
repo: GitHub repo in the form "owner/name" (e.g. "facebook/react").
|
| 22 |
state: "open", "closed", or "all".
|
| 23 |
limit: Maximum number of issues to return (max GitHub default = 30).
|
| 24 |
+
|
| 25 |
+
Returns:
|
| 26 |
+
A list of issues, each as a dict with keys:
|
| 27 |
+
- number: int
|
| 28 |
+
- title: str
|
| 29 |
+
- url: str
|
| 30 |
+
- state: str
|
| 31 |
+
- labels: List[str]
|
| 32 |
"""
|
| 33 |
url = f"https://api.github.com/repos/{repo}/issues"
|
| 34 |
params = {"state": state, "per_page": min(limit, 30)}
|
|
|
|
| 40 |
except Exception as e:
|
| 41 |
return f"❌ GitHub request error: {e}"
|
| 42 |
|
| 43 |
+
issues_list: List[Dict] = []
|
| 44 |
+
|
| 45 |
for issue in data:
|
| 46 |
+
# Skip PRs (GitHub includes PRs in /issues endpoint)
|
| 47 |
if "pull_request" in issue:
|
| 48 |
continue
|
| 49 |
+
|
| 50 |
number = issue.get("number")
|
| 51 |
+
title = (issue.get("title") or "No title").strip()
|
| 52 |
html_url = issue.get("html_url")
|
| 53 |
+
state_ = issue.get("state")
|
| 54 |
+
labels = [lbl.get("name") for lbl in issue.get("labels", [])]
|
| 55 |
+
|
| 56 |
+
issues_list.append(
|
| 57 |
+
{
|
| 58 |
+
"number": number,
|
| 59 |
+
"title": title,
|
| 60 |
+
"url": html_url,
|
| 61 |
+
"state": state_,
|
| 62 |
+
"labels": labels,
|
| 63 |
+
}
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
if len(issues_list) >= limit:
|
| 67 |
break
|
| 68 |
+
|
| 69 |
+
return issues_list
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
@tool
|
| 72 |
def web_search(query:str)-> str:
|