Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,46 @@ from Gradio_UI import GradioUI
|
|
| 12 |
|
| 13 |
ddg = DuckDuckGoSearchTool(max_results=5)
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
@tool
|
| 16 |
def web_search(query:str)-> str:
|
| 17 |
"""A tool that runs a DuckDuckGo search and returns a formatted result.
|
|
@@ -63,7 +103,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 63 |
|
| 64 |
agent = CodeAgent(
|
| 65 |
model=model,
|
| 66 |
-
tools=[final_answer, get_current_time_in_timezone, web_search, visit_webpage, image_generation_tool], ## add your tools here (don't remove final answer)
|
| 67 |
max_steps=6,
|
| 68 |
verbosity_level=1,
|
| 69 |
grammar=None,
|
|
|
|
| 12 |
|
| 13 |
ddg = DuckDuckGoSearchTool(max_results=5)
|
| 14 |
|
| 15 |
+
@tool
|
| 16 |
+
def github_issues(repo: str, state: str = "open", limit: int = 5) -> str:
|
| 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)}
|
| 27 |
+
|
| 28 |
+
try:
|
| 29 |
+
res = requests.get(url, params=params, timeout=8)
|
| 30 |
+
res.raise_for_status()
|
| 31 |
+
data = res.json()
|
| 32 |
+
except Exception as e:
|
| 33 |
+
return f"❌ GitHub request error: {e}"
|
| 34 |
+
|
| 35 |
+
issues = []
|
| 36 |
+
for issue in data:
|
| 37 |
+
# Skip PRs (GitHub API includes them in /issues endpoint)
|
| 38 |
+
if "pull_request" in issue:
|
| 39 |
+
continue
|
| 40 |
+
|
| 41 |
+
number = issue.get("number")
|
| 42 |
+
title = issue.get("title", "No title").strip()
|
| 43 |
+
html_url = issue.get("html_url")
|
| 44 |
+
|
| 45 |
+
issues.append(f"- #{number}: [{title}]({html_url})")
|
| 46 |
+
|
| 47 |
+
if len(issues) >= limit:
|
| 48 |
+
break
|
| 49 |
+
|
| 50 |
+
if not issues:
|
| 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:
|
| 57 |
"""A tool that runs a DuckDuckGo search and returns a formatted result.
|
|
|
|
| 103 |
|
| 104 |
agent = CodeAgent(
|
| 105 |
model=model,
|
| 106 |
+
tools=[final_answer, get_current_time_in_timezone, web_search, visit_webpage, image_generation_tool, github_issues], ## add your tools here (don't remove final answer)
|
| 107 |
max_steps=6,
|
| 108 |
verbosity_level=1,
|
| 109 |
grammar=None,
|